mathjax_script_template 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. if (!document.getElementById('mathjaxscript_pelican_#%@#$@#')) {{
  2. var align = "{align}",
  3. indent = "{indent}",
  4. linebreak = "{linebreak_automatic}";
  5. if ({responsive}) {{
  6. align = (screen.width < {responsive_break}) ? "left" : align;
  7. indent = (screen.width < {responsive_break}) ? "0em" : indent;
  8. linebreak = (screen.width < {responsive_break}) ? 'true' : linebreak;
  9. }}
  10. var mathjaxscript = document.createElement('script');
  11. var location_protocol = ({force_tls}) ? 'https' : document.location.protocol;
  12. if (location_protocol !== 'http' && location_protocol !== 'https') location_protocol = 'https:';
  13. mathjaxscript.id = 'mathjaxscript_pelican_#%@#$@#';
  14. mathjaxscript.type = 'text/javascript';
  15. mathjaxscript.src = location_protocol + {source};
  16. mathjaxscript[(window.opera ? "innerHTML" : "text")] =
  17. "MathJax.Hub.Config({{" +
  18. " config: ['MMLorHTML.js']," +
  19. " TeX: {{ extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'{tex_extensions}], equationNumbers: {{ autoNumber: 'AMS' }} }}," +
  20. " jax: ['input/TeX','input/MathML','output/HTML-CSS']," +
  21. " extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']," +
  22. " displayAlign: '"+ align +"'," +
  23. " displayIndent: '"+ indent +"'," +
  24. " showMathMenu: {show_menu}," +
  25. " messageStyle: '{message_style}'," +
  26. " tex2jax: {{ " +
  27. " inlineMath: [ ['\\\\(','\\\\)'] ], " +
  28. " displayMath: [ ['$$','$$'] ]," +
  29. " processEscapes: {process_escapes}," +
  30. " preview: '{latex_preview}'," +
  31. " }}, " +
  32. " 'HTML-CSS': {{ " +
  33. " styles: {{ '.MathJax_Display, .MathJax .mo, .MathJax .mi, .MathJax .mn': {{color: '{color} ! important'}} }}," +
  34. " linebreaks: {{ automatic: "+ linebreak +", width: '90% container' }}," +
  35. " }}, " +
  36. "}}); " +
  37. "if ('{mathjax_font}' !== 'default') {{" +
  38. "MathJax.Hub.Register.StartupHook('HTML-CSS Jax Ready',function () {{" +
  39. "var VARIANT = MathJax.OutputJax['HTML-CSS'].FONTDATA.VARIANT;" +
  40. "VARIANT['normal'].fonts.unshift('MathJax_{mathjax_font}');" +
  41. "VARIANT['bold'].fonts.unshift('MathJax_{mathjax_font}-bold');" +
  42. "VARIANT['italic'].fonts.unshift('MathJax_{mathjax_font}-italic');" +
  43. "VARIANT['-tex-mathit'].fonts.unshift('MathJax_{mathjax_font}-italic');" +
  44. "}});" +
  45. "MathJax.Hub.Register.StartupHook('SVG Jax Ready',function () {{" +
  46. "var VARIANT = MathJax.OutputJax.SVG.FONTDATA.VARIANT;" +
  47. "VARIANT['normal'].fonts.unshift('MathJax_{mathjax_font}');" +
  48. "VARIANT['bold'].fonts.unshift('MathJax_{mathjax_font}-bold');" +
  49. "VARIANT['italic'].fonts.unshift('MathJax_{mathjax_font}-italic');" +
  50. "VARIANT['-tex-mathit'].fonts.unshift('MathJax_{mathjax_font}-italic');" +
  51. "}});" +
  52. "}}";
  53. (document.body || document.getElementsByTagName('head')[0]).appendChild(mathjaxscript);
  54. }}