Return the snippet of HTML code to put in HTML HEAD tag, in order to
    enable MathJax support.
    @param https: when using the CDN, whether to use the HTTPS URL rather
        than the HTTP one.
    @type https: bool
    @note: with new releases of MathJax, update this function toghether with
           $MJV variable in the root Makefile.am

def get_mathjax_header(https=False):
    """
    Return the snippet of HTML code to put in HTML HEAD tag, in order to
    enable MathJax support.
    @param https: when using the CDN, whether to use the HTTPS URL rather
        than the HTTP one.
    @type https: bool
    @note: with new releases of MathJax, update this function toghether with
           $MJV variable in the root Makefile.am
    """
    if cfg['CFG_MATHJAX_HOSTING'].lower() == 'cdn':
        if https:
            mathjax_path = "https://d3eoax9i5htok0.cloudfront.net/mathjax/2.1-latest"
        else:
            mathjax_path = "http://cdn.mathjax.org/mathjax/2.1-latest"
    else:
        mathjax_path = "/vendors/MathJax"

    if cfg['CFG_MATHJAX_RENDERS_MATHML']:
        mathjax_config = "TeX-AMS-MML_HTMLorMML"
    else:
        mathjax_config = "TeX-AMS_HTML"

    return """<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: {inlineMath: [['$','$']],
            processEscapes: true},
  showProcessingMessages: false,
  messageStyle: "none"
});
</script>
<script src="%(mathjax_path)s/MathJax.js?config=%(mathjax_config)s" type="text/javascript">
</script>""" % {
        'mathjax_path': mathjax_path,
        'mathjax_config': mathjax_config,
    }