121 lines
3.8 KiB
HTML
121 lines
3.8 KiB
HTML
## mako
|
|
## File: templates/mathjax_include.html
|
|
##
|
|
## Note that this file is only used by LMS.
|
|
## MathJax configuration for Studio lives in
|
|
## cms/js/require-config.js.
|
|
|
|
<%page args="disable_fast_preview=True" expression_filter="h"/>
|
|
|
|
## Avoid loading mathjax if already loaded on the page
|
|
|
|
%if context.get('load_mathjax', True):
|
|
|
|
%if disable_fast_preview:
|
|
<script type="text/javascript">
|
|
// Fast Preview was introduced in 2.5. However, it
|
|
// causes undesirable flashing/font size changes when
|
|
// MathJax is used for interactive preview (equation editor).
|
|
// Setting processSectionDelay to 0 (see below) fully eliminates
|
|
// fast preview, but to reduce confusion, we are also setting
|
|
// the option as displayed in the context menu to false.
|
|
// When upgrading to 2.6, check if this variable name changed.
|
|
window.MathJax = {
|
|
menuSettings: {CHTMLpreview: false}
|
|
};
|
|
</script>
|
|
%endif
|
|
|
|
%if mathjax_mode is not Undefined and mathjax_mode == 'wiki':
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({
|
|
CommonHTML: { linebreaks: { automatic: true } },
|
|
SVG: { linebreaks: { automatic: true } },
|
|
"HTML-CSS": { linebreaks: { automatic: true } },
|
|
tex2jax: {inlineMath: [ ['$','$'], ["\\(","\\)"]],
|
|
displayMath: [ ['$$','$$'], ["\\[","\\]"]]}
|
|
});
|
|
</script>
|
|
%else:
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({
|
|
messageStyle: "none",
|
|
CommonHTML: { linebreaks: { automatic: true } },
|
|
SVG: { linebreaks: { automatic: true } },
|
|
"HTML-CSS": { linebreaks: { automatic: true } },
|
|
tex2jax: {
|
|
inlineMath: [
|
|
["\\(","\\)"],
|
|
['[mathjaxinline]','[/mathjaxinline]']
|
|
],
|
|
displayMath: [
|
|
["\\[","\\]"],
|
|
['[mathjax]','[/mathjax]']
|
|
]
|
|
}
|
|
});
|
|
</script>
|
|
%endif
|
|
<script type="text/x-mathjax-config">
|
|
|
|
%if disable_fast_preview:
|
|
// In order to eliminate all flashing during interactive
|
|
// preview, it is necessary to set processSectionDelay to 0
|
|
// (remove delay between input and output phases). This
|
|
// effectively disables fast preview, regardless of
|
|
// the fast preview setting as shown in the context menu.
|
|
MathJax.Hub.processSectionDelay = 0;
|
|
%endif
|
|
|
|
MathJax.Hub.signal.Interest(function(message) {
|
|
if(message[0] === "End Math") {
|
|
set_mathjax_display_div_settings();
|
|
}
|
|
});
|
|
function set_mathjax_display_div_settings() {
|
|
$('.MathJax_Display').each(function( index ) {
|
|
this.setAttribute('tabindex', '0');
|
|
this.setAttribute('aria-live', 'off');
|
|
this.removeAttribute('role');
|
|
this.removeAttribute('aria-readonly');
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
// Activating Mathjax accessibility files
|
|
window.MathJax = {
|
|
menuSettings: {
|
|
collapsible: true,
|
|
autocollapse: false,
|
|
explorer: true
|
|
}
|
|
};
|
|
window.addEventListener('resize', MJrenderer);
|
|
|
|
let t = -1;
|
|
let delay = 1000;
|
|
let oldWidth = document.documentElement.scrollWidth;
|
|
function MJrenderer() {
|
|
// don't rerender if the window is the same size as before
|
|
if (t >= 0) {
|
|
window.clearTimeout(t);
|
|
}
|
|
if (oldWidth !== document.documentElement.scrollWidth) {
|
|
t = window.setTimeout(function() {
|
|
oldWidth = document.documentElement.scrollWidth;
|
|
MathJax.Hub.Queue(
|
|
["Rerender", MathJax.Hub],
|
|
);
|
|
t = -1;
|
|
}, delay);
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<!-- This must appear after all mathjax-config blocks, so it is after the imports from the other templates.
|
|
It can't be run through static.url because MathJax uses crazy url introspection to do lazy loading of
|
|
MathJax extension libraries -->
|
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/mathjax@2.7.5/MathJax.js?config=TeX-MML-AM_SVG"></script>
|
|
%endif
|