<?xml version='1.0' encoding=“UTF-8”?> <xsl:stylesheet xmlns:xsl=“www.w3.org/1999/XSL/Transform”
xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:inst="http://instructure.com/functions" extension-element-prefixes="inst" version='1.0'> <xsl:template match="m:mi|m:mn|m:mo|m:mtext|m:ms"> <xsl:call-template name="CommonTokenAtr"/> </xsl:template> <xsl:template name="mi"> <xsl:choose> <xsl:when test="string-length(normalize-space(.))>1 and not(@mathvariant)"> <xsl:text>\mathrm{</xsl:text> <xsl:value-of select="inst:fetch_symbols(normalize-space(.))" /> <xsl:text>}</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="inst:fetch_symbols(normalize-space(.))" /> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="mn"> <xsl:apply-templates/> </xsl:template> <xsl:template name="mo"> <xsl:choose> <xsl:when test="@largeop = 'true'">\mbox{\large$</xsl:when> <xsl:when test="local-name(preceding-sibling::*[1]) = 'mi'"><xsl:text>\operatorname </xsl:text></xsl:when> </xsl:choose> <xsl:variable name="content"> <xsl:choose> <xsl:when test=".='⏜'">⌢</xsl:when> <xsl:when test=".='⏝'">⌣</xsl:when> <xsl:otherwise><xsl:value-of select="normalize-space(.)"/></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:value-of select="inst:fetch_symbols($content)" /> <xsl:choose> <xsl:when test="@largeop = 'true'">$}</xsl:when> <xsl:otherwise></xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="mtext"> <xsl:variable name="content"> <xsl:call-template name="replaceMtextEntities"> <xsl:with-param name="content" select="."/> </xsl:call-template> </xsl:variable> <xsl:text>\text{</xsl:text> <xsl:value-of select="$content"/> <xsl:text>}</xsl:text> </xsl:template> <xsl:template match="m:mspace"> <xsl:text>\phantom{\rule</xsl:text> <xsl:if test="@depth"> <xsl:text>[-</xsl:text> <xsl:value-of select="@depth"/> <xsl:text>]</xsl:text> </xsl:if> <xsl:text>{</xsl:text> <xsl:if test="not(@width)"> <xsl:text>0ex</xsl:text> </xsl:if> <xsl:value-of select="@width"/> <xsl:text>}{</xsl:text> <xsl:if test="not(@height)"> <xsl:text>0ex</xsl:text> </xsl:if> <xsl:value-of select="@height"/> <xsl:text>}}</xsl:text> </xsl:template> <xsl:template name="ms"> <xsl:choose> <xsl:when test="@lquote"><xsl:value-of select="@lquote"/></xsl:when> <xsl:otherwise><xsl:text>"</xsl:text></xsl:otherwise> </xsl:choose><xsl:apply-templates/><xsl:choose> <xsl:when test="@rquote"><xsl:value-of select="@rquote"/></xsl:when> <xsl:otherwise><xsl:text>"</xsl:text></xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="CommonTokenAtr"> <xsl:if test="@mathbackground"> <xsl:text>\colorbox[rgb]{</xsl:text> <xsl:call-template name="color"> <xsl:with-param name="color" select="@mathbackground"/> </xsl:call-template> <xsl:text>}{$</xsl:text> </xsl:if> <xsl:if test="@color or @mathcolor"> <!-- Note: @color is deprecated in MathML 2.0 --> <xsl:text>\textcolor[rgb]{</xsl:text> <xsl:call-template name="color"> <xsl:with-param name="color" select="@color|@mathcolor"/> </xsl:call-template> <xsl:text>}{</xsl:text> </xsl:if> <xsl:if test="@mathvariant"> <xsl:choose> <xsl:when test="@mathvariant='bold'"> <xsl:text>\mathbf{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='italic'"> <xsl:text>\mathit{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='bold-italic'"> <!-- Required definition --> <xsl:text>\mathbit{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='double-struck'"> <!-- Required amsfonts --> <xsl:text>\mathbb{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='bold-fraktur'"> <!-- Error --> <xsl:text>{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='script'"> <xsl:text>\mathcal{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='bold-script'"> <!-- Error --> <xsl:text>\mathsc{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='fraktur'"> <!-- Required amsfonts --> <xsl:text>\mathfrak{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='sans-serif'"> <xsl:text>\mathsf{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='bold-sans-serif'"> <!-- Required definition --> <xsl:text>\mathbsf{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='sans-serif-italic'"> <!-- Required definition --> <xsl:text>\mathsfit{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='sans-serif-bold-italic'"> <!-- Error --> <xsl:text>\mathbsfit{</xsl:text> </xsl:when> <xsl:when test="@mathvariant='monospace'"> <xsl:text>\mathtt{</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>{</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:if> <xsl:call-template name="selectTemplate"/> <xsl:if test="@mathvariant"> <xsl:text>}</xsl:text> </xsl:if> <xsl:if test="@color or @mathcolor"> <xsl:text>}</xsl:text> </xsl:if> <xsl:if test="@mathbackground"> <xsl:text>$}</xsl:text> </xsl:if> </xsl:template> <xsl:template name="selectTemplate"> <xsl:choose> <xsl:when test="local-name(.)='mi'"> <xsl:call-template name="mi"/> </xsl:when> <xsl:when test="local-name(.)='mn'"> <xsl:call-template name="mn"/> </xsl:when> <xsl:when test="local-name(.)='mo'"> <xsl:call-template name="mo"/> </xsl:when> <xsl:when test="local-name(.)='mtext'"> <xsl:call-template name="mtext"/> </xsl:when> <xsl:when test="local-name(.)='ms'"> <xsl:call-template name="ms"/> </xsl:when> </xsl:choose> </xsl:template> <xsl:template name="replaceMtextEntities"> <xsl:param name="content"/> <xsl:choose> <xsl:when test="contains($content,'   ')"> <!-- ThickSpace - space of width 5/18 em --> <xsl:call-template name="replaceMtextEntities"> <xsl:with-param name="content" select="concat(substring-before($content,'   '),'\hspace{0.28em}',substring-after($content,'   '))"/> </xsl:call-template> </xsl:when> <xsl:when test="contains($content,' ')"> <!-- ThinSpace - space of width 3/18 em --> <xsl:call-template name="replaceMtextEntities"> <xsl:with-param name="content" select="concat(substring-before($content,' '),'\hspace{0.17em}',substring-after($content,' '))"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="normalize-space($content)"/> </xsl:otherwise> </xsl:choose> </xsl:template>
</xsl:stylesheet>