mathjax_script_template 2.9 KB

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