diff options
Diffstat (limited to 'utility')
-rw-r--r-- | utility/formatter.xsl | 28 | ||||
-rw-r--r-- | utility/master.xsl | 4 | ||||
-rw-r--r-- | utility/xhtml.xsl | 18 |
3 files changed, 43 insertions, 7 deletions
diff --git a/utility/formatter.xsl b/utility/formatter.xsl index eae9395..21cdff4 100644 --- a/utility/formatter.xsl +++ b/utility/formatter.xsl @@ -17,7 +17,25 @@ )/self::command/node()"/> </xsl:template> -<xsl:template name="highlighter"> +<xsl:template name="math_highlighter"> + <xsl:param name="source"/> + + <xsl:variable name="formatted_expression"> + <xsl:call-template name="plain_formatter"> + <xsl:with-param name="format"> + <xsl:text>tex2html --inline '</xsl:text> + <xsl:value-of select="$source"/> + <xsl:text>'</xsl:text> + </xsl:with-param> + </xsl:call-template> + </xsl:variable> + + <p class="math"> + <xsl:copy-of select="xalan:nodeset($formatted_expression)/node()"/> + </p> +</xsl:template> + +<xsl:template name="code_highlighter"> <xsl:param name="source"/> <xsl:param name="language"/> @@ -55,7 +73,7 @@ </xsl:template> <xsl:template match="pre" mode="embellish"> - <xsl:call-template name="highlighter"> + <xsl:call-template name="code_highlighter"> <xsl:with-param name="source" select="code/text()"/> <xsl:with-param name="language"> <xsl:choose> @@ -70,6 +88,12 @@ </xsl:call-template> </xsl:template> +<xsl:template match="script" mode="embellish"> + <xsl:call-template name="math_highlighter"> + <xsl:with-param name="source" select="text()"/> + </xsl:call-template> +</xsl:template> + <xsl:template name="formatter"> <xsl:param name="source"/> diff --git a/utility/master.xsl b/utility/master.xsl index 0fc400e..605cf6f 100644 --- a/utility/master.xsl +++ b/utility/master.xsl @@ -28,6 +28,10 @@ <link rel="stylesheet" type="text/css" href="/main.css" /> <link rel="shortcut icon" type="image/x-icon" href="/media/favicon.ico" /> + <xsl:if test="//p[@class = 'math']"> + <link rel="stylesheet" type="text/css" href="/math.css" /> + </xsl:if> + <title> <xsl:call-template name="title-text"/> @ <xsl:value-of select="$root/meta/title"/> </title> diff --git a/utility/xhtml.xsl b/utility/xhtml.xsl index 7347962..8b768fa 100644 --- a/utility/xhtml.xsl +++ b/utility/xhtml.xsl @@ -5,14 +5,22 @@ > <xsl:template match="*" mode="xhtml"> - <xsl:element name="{local-name()}" namespace="http://www.w3.org/1999/xhtml"> - <xsl:copy-of select="@*"/> - <xsl:apply-templates select="node()" mode="xhtml"/> - </xsl:element> + <xsl:element name="{local-name()}" namespace="http://www.w3.org/1999/xhtml"> + <xsl:copy-of select="@*"/> + <xsl:apply-templates select="node()" mode="xhtml"/> + </xsl:element> +</xsl:template> + +<xsl:template match="span" mode="xhtml"> + <span> + <xsl:copy-of select="@*"/> + <xsl:apply-templates select="node()" mode="xhtml"/> + <xsl:comment></xsl:comment> + </span> </xsl:template> <xsl:template match="comment() | processing-instruction()" mode="xhtml"> - <xsl:copy/> + <xsl:copy/> </xsl:template> </xsl:stylesheet> |