aboutsummaryrefslogtreecommitdiff
path: root/plugins/render_math/mathjax_script_template
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-01-03 20:10:08 +0100
committerSébastien Dailly <sebastien@chimrod.com>2021-01-04 10:50:59 +0100
commit0c09a00a0b298cbd3bbd0082cc1026e22db9b1c5 (patch)
tree90a346ea34bffbd882a727c5dfd25f6c2ab54841 /plugins/render_math/mathjax_script_template
parent536bb26052fa4ada16d9d09a6cc140a4d3293af8 (diff)
New article, and blog application
Diffstat (limited to 'plugins/render_math/mathjax_script_template')
-rwxr-xr-xplugins/render_math/mathjax_script_template61
1 files changed, 61 insertions, 0 deletions
diff --git a/plugins/render_math/mathjax_script_template b/plugins/render_math/mathjax_script_template
new file mode 100755
index 0000000..db8aeba
--- /dev/null
+++ b/plugins/render_math/mathjax_script_template
@@ -0,0 +1,61 @@
+if (!document.getElementById('mathjaxscript_pelican_#%@#$@#')) {{
+ var align = "{align}",
+ indent = "{indent}",
+ linebreak = "{linebreak_automatic}";
+
+ if ({responsive}) {{
+ align = (screen.width < {responsive_break}) ? "left" : align;
+ indent = (screen.width < {responsive_break}) ? "0em" : indent;
+ linebreak = (screen.width < {responsive_break}) ? 'true' : linebreak;
+ }}
+
+ var mathjaxscript = document.createElement('script');
+ mathjaxscript.id = 'mathjaxscript_pelican_#%@#$@#';
+ mathjaxscript.type = 'text/javascript';
+ mathjaxscript.src = {source};
+
+ var configscript = document.createElement('script');
+ configscript.type = 'text/x-mathjax-config';
+ configscript[(window.opera ? "innerHTML" : "text")] =
+ "MathJax.Hub.Config({{" +
+ " config: ['MMLorHTML.js']," +
+ " TeX: {{ extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'{tex_extensions}], equationNumbers: {{ autoNumber: '{equation_numbering}' }} }}," +
+ " jax: ['input/TeX','input/MathML','output/HTML-CSS']," +
+ " extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']," +
+ " displayAlign: '"+ align +"'," +
+ " displayIndent: '"+ indent +"'," +
+ " showMathMenu: {show_menu}," +
+ " messageStyle: '{message_style}'," +
+ " tex2jax: {{ " +
+ " inlineMath: [ ['\\\\(','\\\\)'] ], " +
+ " displayMath: [ ['$$','$$'] ]," +
+ " processEscapes: {process_escapes}," +
+ " preview: '{latex_preview}'," +
+ " }}, " +
+ " 'HTML-CSS': {{ " +
+ " availableFonts: {font_list}," +
+ " preferredFont: 'STIX'," +
+ " styles: {{ '.MathJax_Display, .MathJax .mo, .MathJax .mi, .MathJax .mn': {{color: '{color} ! important'}} }}," +
+ " linebreaks: {{ automatic: "+ linebreak +", width: '90% container' }}," +
+ " }}, " +
+ "}}); " +
+ "if ('{mathjax_font}' !== 'default') {{" +
+ "MathJax.Hub.Register.StartupHook('HTML-CSS Jax Ready',function () {{" +
+ "var VARIANT = MathJax.OutputJax['HTML-CSS'].FONTDATA.VARIANT;" +
+ "VARIANT['normal'].fonts.unshift('MathJax_{mathjax_font}');" +
+ "VARIANT['bold'].fonts.unshift('MathJax_{mathjax_font}-bold');" +
+ "VARIANT['italic'].fonts.unshift('MathJax_{mathjax_font}-italic');" +
+ "VARIANT['-tex-mathit'].fonts.unshift('MathJax_{mathjax_font}-italic');" +
+ "}});" +
+ "MathJax.Hub.Register.StartupHook('SVG Jax Ready',function () {{" +
+ "var VARIANT = MathJax.OutputJax.SVG.FONTDATA.VARIANT;" +
+ "VARIANT['normal'].fonts.unshift('MathJax_{mathjax_font}');" +
+ "VARIANT['bold'].fonts.unshift('MathJax_{mathjax_font}-bold');" +
+ "VARIANT['italic'].fonts.unshift('MathJax_{mathjax_font}-italic');" +
+ "VARIANT['-tex-mathit'].fonts.unshift('MathJax_{mathjax_font}-italic');" +
+ "}});" +
+ "}}";
+
+ (document.body || document.getElementsByTagName('head')[0]).appendChild(configscript);
+ (document.body || document.getElementsByTagName('head')[0]).appendChild(mathjaxscript);
+}}