@@ -13147,152 +13147,32 @@ TODO:
1314713147<!-- Autobold extension is critical for captions (bold'ed) that -->
1314813148<!-- have mathematics in them (suggested by P. Krautzberger) -->
1314913149<xsl:template name="mathjax">
13150- <!-- mathjax configuration -->
13151- <xsl:element name="script">
13152- <xsl:text>
</xsl:text>
13153- <xsl:text>var runestoneMathReady = new Promise((resolve) => window.rsMathReady = resolve);
</xsl:text>
13154- <xsl:text>window.MathJax = </xsl:text>
13155- <xsl:call-template name="json">
13156- <xsl:with-param name="content">
13157- <map xmlns="http://www.w3.org/2005/xpath-functions">
13158- <map key="tex">
13159- <array key="inlineMath">
13160- <array>
13161- <string>\(</string>
13162- <string>\)</string>
13163- </array>
13164- </array>
13165- <string key="tags">none</string>
13166- <string key="tagSide">right</string>
13167- <string key="tagIndent">.8em</string>
13168- <map key="packages">
13169- <array key="[+]">
13170- <string>base</string>
13171- <string>ams</string>
13172- <string>amscd</string>
13173- <string>color</string>
13174- <string>newcommand</string>
13175- <!-- necessary for \text{} in math -->
13176- <string>textmacros</string>
13177- <string>knowl</string>
13178- </array>
13179- </map>
13180- </map>
13181- <map key="options">
13182- <string key="ignoreHtmlClass">tex2jax_ignore|ignore-math</string>
13183- <string key="processHtmlClass">process-math</string>
13184- <xsl:if test="$b-has-webwork-reps or $b-has-sage">
13185- <map key="renderActions">
13186- <array key="findScript">
13187- <number>10</number>
13188- <raw>
13189- <xsl:text>function (doc) {
</xsl:text>
13190- <xsl:text> document.querySelectorAll('script[type^="math/tex"]').forEach(function(node) {
</xsl:text>
13191- <xsl:text> var display = !!node.type.match(/; *mode=display/);
</xsl:text>
13192- <xsl:text> var math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
</xsl:text>
13193- <xsl:text> var text = document.createTextNode('');
</xsl:text>
13194- <xsl:text> node.parentNode.replaceChild(text, node);
</xsl:text>
13195- <xsl:text> math.start = {node: text, delim: '', n: 0};
</xsl:text>
13196- <xsl:text> math.end = {node: text, delim: '', n: 0};
</xsl:text>
13197- <xsl:text> doc.math.push(math);
</xsl:text>
13198- <xsl:text> });
</xsl:text>
13199- <xsl:text> }</xsl:text>
13200- </raw>
13201- <string></string>
13202- </array>
13203- </map>
13204- </xsl:if>
13205- </map>
13206- <map key="chtml">
13207- <number key="scale">0.98</number>
13208- <boolean key="mtextInheritFont">true</boolean>
13209- </map>
13210- <map key="loader">
13211- <array key="load">
13212- <string>input/asciimath</string>
13213- <string>[tex]/amscd</string>
13214- <string>[tex]/color</string>
13215- <string>[tex]/newcommand</string>
13216- <!-- necessary for \text{} in math -->
13217- <string>[tex]/textmacros</string>
13218- <string>[pretext]/mathjaxknowl3.js</string>
13219- </array>
13220- <map key="paths">
13221- <string key="pretext">
13222- <xsl:value-of select="$html.js.dir"/>
13223- </string>
13224- </map>
13225- </map>
13226- <map key="startup">
13227- <xsl:choose>
13228- <xsl:when test="$b-debug-react">
13229- <boolean key="typeset">false</boolean>
13230- </xsl:when>
13231- <xsl:otherwise>
13232- <!-- tell Runestone components that MathJax is all loaded -->
13233- <raw>
13234- <xsl:text>pageReady() {
</xsl:text>
13235- <xsl:text> return MathJax.startup.defaultPageReady().then(function () {
</xsl:text>
13236- <xsl:text> console.log("in ready function");
</xsl:text>
13237- <xsl:text> rsMathReady();
</xsl:text>
13238- <xsl:text> }
</xsl:text>
13239- <xsl:text> )}</xsl:text>
13240- </raw>
13241- </xsl:otherwise>
13242- </xsl:choose>
13243- </map>
13244- <!-- optional presentation mode gets clickable, large math -->
13245- <xsl:if test="$b-html-presentation">
13246- <map key="options">
13247- <map key="menuOptions">
13248- <map key="settings">
13249- <string key="zoom">Click</string>
13250- <string key="zscale">300%</string>
13251- </map>
13252- </map>
13253- </map>
13254- </xsl:if>
13255- </map>
13256- </xsl:with-param>
13257- </xsl:call-template>
13258- <xsl:text>;</xsl:text>
13259- <xsl:text>
</xsl:text>
13260- </xsl:element>
13261- <!-- mathjax javascript -->
13262- <xsl:element name="script">
13263- <!-- probably should be universal, but only adding for MJ 4 -->
13264- <!-- TODO: make a literal "script" element with this attribute -->
13265- <xsl:if test="$mathjax4-testing">
13266- <xsl:attribute name="type">
13267- <xsl:text>text/javascript</xsl:text>
13268- </xsl:attribute>
13269- </xsl:if>
13150+ <!-- MathJax 4 configuration via JavaScript module -->
13151+ <script type="module">
13152+ <xsl:text>import { startMathJax } from './</xsl:text>
13153+ <xsl:value-of select="$html.js.dir"/>
13154+ <xsl:text>/mathjax_startup.js';
</xsl:text>
13155+ <xsl:text>startMathJax({
</xsl:text>
13156+ <xsl:text>hasWebworkReps: </xsl:text><xsl:value-of select="$b-has-webwork-reps"/><xsl:text>,
</xsl:text>
13157+ <xsl:text>hasSage: </xsl:text><xsl:value-of select="$b-has-sage"/><xsl:text>,
</xsl:text>
13158+ <xsl:text>isReact: </xsl:text><xsl:value-of select="$b-debug-react"/><xsl:text>,
</xsl:text>
13159+ <xsl:text>htmlPresentation: </xsl:text><xsl:value-of select="$b-html-presentation"/><xsl:text>,
</xsl:text>
13160+ <xsl:text>});
</xsl:text>
13161+ </script>
13162+ <!-- MathJax 4 CDN -->
13163+ <script defer="true">
1327013164 <xsl:attribute name="src">
13165+ <xsl:text>https://cdn.jsdelivr.net/npm/mathjax@4/</xsl:text>
1327113166 <xsl:choose>
13272- <xsl:when test="$mathjax4-testing">
13273- <xsl:text>https://cdn.jsdelivr.net/npm/mathjax@4/</xsl:text>
13274- </xsl:when>
13275- <xsl:otherwise>
13276- <xsl:text>https://cdn.jsdelivr.net/npm/mathjax@3/es5/</xsl:text>
13277- </xsl:otherwise>
13278- </xsl:choose>
13279- <!-- CHTML is the default, SVG is for debugging -->
13280- <xsl:choose>
13281- <!-- SVG filename identical for v3, v4 -->
13282- <!-- NB: is tex-mml-svg.js new for v4? -->
1328313167 <xsl:when test="$debug.mathjax.svg = 'yes'">
1328413168 <xsl:text>tex-svg.js</xsl:text>
1328513169 </xsl:when>
13286- <!-- new filename (default) for v4 -->
13287- <xsl:when test="$mathjax4-testing">
13288- <xsl:text>tex-mml-chtml.js</xsl:text>
13289- </xsl:when>
1329013170 <xsl:otherwise>
13291- <xsl:text>tex-chtml.js</xsl:text>
13171+ <xsl:text>tex-mml- chtml.js</xsl:text>
1329213172 </xsl:otherwise>
1329313173 </xsl:choose>
1329413174 </xsl:attribute>
13295- </xsl:element >
13175+ </script >
1329613176</xsl:template>
1329713177
1329813178<!-- SageCell Javascript-->
0 commit comments