- Reformatted code and made more effective use of xsl:text and newline-internal.
1 parent 067e8c2 commit c4b11914851c32f0078e0e3dc117374fb8103de2
nstanger authored on 7 Oct 2011
Showing 1 changed file
View
31
modules/code-formatting.xml
-->
 
<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/">\verb`<xsl:apply-templates />`</common>
<common formats="/html/xhtml/"><code><xsl:apply-templates /></code></common>
<!--
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. -->
<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>
<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/">