Support inline MathML with MathJax.
--- a/publish.xsl Fri May 18 12:22:50 2012 +1000
+++ b/publish.xsl Fri May 18 12:38:19 2012 +1000
@@ -171,6 +171,10 @@
<xsl:apply-templates select='head/*[not(self::link) and not(self::meta) and not(self::title)]'/>
<xsl:apply-templates select='head/link[not(@rel="stylesheet" and contains(@href, "StyleSheets/TR") or @media="print")]'/>
<link rel='stylesheet' href='{if ($local-style-sheets) then "style/" else "http://www.w3.org/StyleSheets/TR/"}W3C-{$maturity-short}{if ($local-style-sheets) then ".css" else ""}' type='text/css' media='screen'/>
+ <xsl:if test='body//m:*'>
+ <!-- If there were an "MML_SVG" config we should use that, to avoid the overhead of looking for TeX-style math. -->
+ <script src="http://cdn.mathjax.org/mathjax/2.0-latest/MathJax.js?config=TeX-AMS-MML_SVG"><xsl:text> </xsl:text></script>
+ </xsl:if>
</head>
<body>
<xsl:attribute name='class'>
--- a/single-page.xsl Fri May 18 12:22:50 2012 +1000
+++ b/single-page.xsl Fri May 18 12:38:19 2012 +1000
@@ -30,6 +30,9 @@
<xsl:call-template name='do-chapters-style'>
<xsl:with-param name='cs' select='concat($chapters, " ")'/>
</xsl:call-template>
+ <xsl:call-template name='do-chapters-script'>
+ <xsl:with-param name='cs' select='concat($chapters, " ")'/>
+ </xsl:call-template>
</xsl:copy>
</xsl:template>
@@ -71,6 +74,7 @@
</xsl:template>
<xsl:template match='h:script[@src="style/expanders.js"]'/>
+ <xsl:template match='h:script[contains(@src, "mathjax")]'/>
<xsl:template match='node()|@*'>
<xsl:param name='c'/>
@@ -111,4 +115,26 @@
</xsl:call-template>
</xsl:if>
</xsl:template>
+
+ <xsl:template name='do-chapters-script'>
+ <xsl:param name='cs'/>
+ <xsl:variable name='c' select='concat(substring-before($cs, " "), "-")'/>
+ <xsl:if test='$c != "" and $c != "-"'>
+ <xsl:variable name="mathjax" select='document(concat($publish, "/", substring($c, 1, string-length($c) - 1), ".html"))/h:html/h:head/h:script[contains(@src, "mathjax")]'/>
+ <xsl:message>looking at chapter <xsl:value-of select="$c"/></xsl:message>
+ <xsl:message>count($mathjax) = <xsl:value-of select="count($mathjax)"/></xsl:message>
+ <xsl:choose>
+ <xsl:when test="count($mathjax) != 0">
+ <xsl:message>a</xsl:message>
+ <xsl:copy-of select="$mathjax[1]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>b</xsl:message>
+ <xsl:call-template name='do-chapters-script'>
+ <xsl:with-param name='cs' select='substring-after($cs, " ")'/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:template>
</xsl:stylesheet>