<?xml version="1.0" encoding="utf-8"?> <!-- Inline code and code blocks (preformatted text, in HTML terms). --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Inline code. --> <template name="code" match="code"> <!-- <latex>\code{<xsl:apply-templates />}</latex> --> <!-- Using \verb is quite handy because things like underscores don't bother it. However, it seems it can't be used inside hyperlinks. Maybe create another template that just does a \texttt on the contents? OK, but then we need an <underscore> element to stop them from freaking LaTeX out. --> <common formats="/latex/xelatex/"> <xsl:text>\verb`</xsl:text> <xsl:apply-templates /> <xsl:text>`</xsl:text> </common> <common formats="/html/xhtml/"> <code><xsl:apply-templates /></code> </common> </template> <!-- Code block. We can decide later whether to use plain verbatim or listings. --> <template name="code-block" match="code-block"> <common formats="/latex/xelatex/"> <xsl:call-template name="newline-internal" /> <!-- If the code-block specifies "allow-breaks='no'", wrap the verbatim inside a minipage to avoid page breaks within the code. --> <xsl:if test="@allow-breaks = 'no'"> <xsl:text>\vskip\baselineskip</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:text>\begin{minipage}{\textwidth}</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:if> <xsl:text>\begin{verbatim}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:apply-templates /> <xsl:call-template name="newline-internal" /> <xsl:text>\end{verbatim}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:if test="@allow-breaks = 'no'"> <xsl:text>\end{minipage}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:text>\vskip\baselineskip</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:if> <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <pre class="code"><xsl:apply-templates /></pre> </common> </template> <!-- This is for stuff that should unequivocally be treated verbatim (e.g. problem code). I'm pretty sure that previously this was distinguished from "code-block" because it (code-block) used to use listings instead of verbatim. Now that they're both using verbatim there is probably no need for them both (but we might switch back to using listings for code-block). --> <template name="verbatim" match="verbatim"> <common formats="/latex/xelatex/"> <xsl:call-template name="newline-internal" /> <xsl:text>\begin{verbatim}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:apply-templates /> <xsl:call-template name="newline-internal" /> <xsl:text>\end{verbatim}</xsl:text> <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <pre><xsl:apply-templates /></pre> </common> </template> </stylesheet>