mathjax_script_template 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. " tex2jax: {{ " +
  24. " inlineMath: [ ['\\\\(','\\\\)'] ], " +
  25. " displayMath: [ ['$$','$$'] ]," +
  26. " processEscapes: {process_escapes}," +
  27. " preview: '{latex_preview}'," +
  28. " }}, " +
  29. " 'HTML-CSS': {{ " +
  30. " styles: {{ '.MathJax_Display, .MathJax .mo, .MathJax .mi, .MathJax .mn': {{color: '{color} ! important'}} }}," +
  31. " linebreaks: {{ automatic: "+ linebreak +", width: '90% container' }}," +
  32. " }}, " +
  33. "}}); ";
  34. (document.body || document.getElementsByTagName('head')[0]).appendChild(mathjaxscript);
  35. }}