|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
XSLT Stylesheet DocBook -> LaTeX
|
|
Packit |
0f19cf |
############################################################################ -->
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:template match="text()">
|
|
Packit |
0f19cf |
<xsl:call-template name="scape">
|
|
Packit |
0f19cf |
<xsl:with-param name="string" select="."/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:template>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:template match="text()" mode="latex.verbatim">
|
|
Packit |
0f19cf |
<xsl:value-of select="."/>
|
|
Packit |
0f19cf |
</xsl:template>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:template name="do.slash.hyphen">
|
|
Packit |
0f19cf |
<xsl:param name="str"/>
|
|
Packit |
0f19cf |
<xsl:choose>
|
|
Packit |
0f19cf |
<xsl:when test="contains($str,'/')">
|
|
Packit |
0f19cf |
<xsl:call-template name="scape">
|
|
Packit |
0f19cf |
<xsl:with-param name="string" select="substring-before($str,'/')"/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
<xsl:text>/\-</xsl:text>
|
|
Packit |
0f19cf |
<xsl:call-template name="do.slash.hyphen">
|
|
Packit |
0f19cf |
<xsl:with-param name="str" select="substring-after($str,'/')"/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:when>
|
|
Packit |
0f19cf |
<xsl:otherwise>
|
|
Packit |
0f19cf |
<xsl:call-template name="scape">
|
|
Packit |
0f19cf |
<xsl:with-param name="string" select="$str"/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:otherwise>
|
|
Packit |
0f19cf |
</xsl:choose>
|
|
Packit |
0f19cf |
</xsl:template>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:template match="text()" mode="slash.hyphen">
|
|
Packit |
0f19cf |
<xsl:choose>
|
|
Packit |
0f19cf |
<xsl:when test="contains(.,'://')">
|
|
Packit |
0f19cf |
<xsl:call-template name="scape">
|
|
Packit |
0f19cf |
<xsl:with-param name="string">
|
|
Packit |
0f19cf |
<xsl:value-of select="substring-before(.,'://')"/>
|
|
Packit |
0f19cf |
</xsl:with-param>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
<xsl:value-of select="'://'"/>
|
|
Packit |
0f19cf |
<xsl:call-template name="do.slash.hyphen">
|
|
Packit |
0f19cf |
<xsl:with-param name="str" select="substring-after(.,'://')"/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:when>
|
|
Packit |
0f19cf |
<xsl:otherwise>
|
|
Packit |
0f19cf |
<xsl:call-template name="do.slash.hyphen">
|
|
Packit |
0f19cf |
<xsl:with-param name="str" select="."/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:otherwise>
|
|
Packit |
0f19cf |
</xsl:choose>
|
|
Packit |
0f19cf |
</xsl:template>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:template name="scape.index">
|
|
Packit |
0f19cf |
<xsl:param name="string"/>
|
|
Packit |
0f19cf |
<xsl:call-template name="scape-replace">
|
|
Packit |
0f19cf |
<xsl:with-param name="from">@</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="to">"@</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="string">
|
|
Packit |
0f19cf |
<xsl:call-template name="scape-replace">
|
|
Packit |
0f19cf |
<xsl:with-param name="from">!</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="to">"!</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="string">
|
|
Packit |
0f19cf |
<xsl:call-template name="scape-replace">
|
|
Packit |
0f19cf |
<xsl:with-param name="from">|</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="to">\ensuremath{"|}</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="string">
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
index term, latex indexing fails.
|
|
Packit |
0f19cf |
so use a macro to avoid this side effect -->
|
|
Packit |
0f19cf |
<xsl:call-template name="scape-replace">
|
|
Packit |
0f19cf |
<xsl:with-param name="from">\tbleft </xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="to">\textbraceleft{}</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="string">
|
|
Packit |
0f19cf |
<xsl:call-template name="scape-replace">
|
|
Packit |
0f19cf |
<xsl:with-param name="from">\tbright </xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="to">\textbraceright{}</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="string">
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:call-template name="scape-replace">
|
|
Packit |
0f19cf |
<xsl:with-param name="from">{</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="to">\tbleft </xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="string">
|
|
Packit |
0f19cf |
<xsl:call-template name="scape-replace">
|
|
Packit |
0f19cf |
<xsl:with-param name="from">}</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="to">\tbright </xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="string">
|
|
Packit |
0f19cf |
<xsl:call-template name="scape-replace">
|
|
Packit |
0f19cf |
<xsl:with-param name="from">"</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="to">""</xsl:with-param>
|
|
Packit |
0f19cf |
<xsl:with-param name="string">
|
|
Packit |
0f19cf |
<xsl:call-template name="normalize-scape">
|
|
Packit |
0f19cf |
<xsl:with-param name="string" select="$string"/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:with-param>
|
|
Packit |
0f19cf |
</xsl:call-template></xsl:with-param>
|
|
Packit |
0f19cf |
</xsl:call-template></xsl:with-param>
|
|
Packit |
0f19cf |
</xsl:call-template></xsl:with-param>
|
|
Packit |
0f19cf |
</xsl:call-template></xsl:with-param>
|
|
Packit |
0f19cf |
</xsl:call-template></xsl:with-param>
|
|
Packit |
0f19cf |
</xsl:call-template></xsl:with-param>
|
|
Packit |
0f19cf |
</xsl:call-template></xsl:with-param>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:template>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
See verbatim.xsl for an overview of the verbatim environment design
|
|
Packit |
0f19cf |
that explains the need of probing.
|
|
Packit |
0f19cf |
-->
|
|
Packit |
0f19cf |
<xsl:template match="text()" mode="latex.programlisting">
|
|
Packit |
0f19cf |
<xsl:param name="probe" select="0"/>
|
|
Packit |
0f19cf |
<xsl:if test="$probe = 0">
|
|
Packit |
0f19cf |
<xsl:value-of select="."/>
|
|
Packit |
0f19cf |
</xsl:if>
|
|
Packit |
0f19cf |
</xsl:template>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:template name="normalize-scape" >
|
|
Packit |
0f19cf |
<xsl:param name="string"/>
|
|
Packit |
0f19cf |
<xsl:call-template name="scape">
|
|
Packit |
0f19cf |
<xsl:with-param name="string" select="normalize-space($string)"/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:template>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
before and after actual text, but keeping in-between blank lines.
|
|
Packit |
0f19cf |
-->
|
|
Packit |
0f19cf |
<xsl:template name="normalize-border" >
|
|
Packit |
0f19cf |
<xsl:param name="string"/>
|
|
Packit |
0f19cf |
<xsl:param name="step" select="'start'"/>
|
|
Packit |
0f19cf |
<xsl:variable name="left" select="substring-before($string,'
')"/>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:choose>
|
|
Packit |
0f19cf |
<xsl:when test="not(contains($string,'
'))">
|
|
Packit |
0f19cf |
<xsl:value-of select="$string"/>
|
|
Packit |
0f19cf |
</xsl:when>
|
|
Packit |
0f19cf |
<xsl:when test="$step='start'">
|
|
Packit |
0f19cf |
<xsl:choose>
|
|
Packit |
0f19cf |
<xsl:when test="string-length(normalize-space($left))=0">
|
|
Packit |
0f19cf |
<xsl:call-template name="normalize-border">
|
|
Packit |
0f19cf |
<xsl:with-param name="string" select="substring-after($string,'
')"/>
|
|
Packit |
0f19cf |
<xsl:with-param name="step" select="$step"/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:when>
|
|
Packit |
0f19cf |
<xsl:otherwise>
|
|
Packit |
0f19cf |
<xsl:value-of select="$left"/>
|
|
Packit |
0f19cf |
<xsl:text>
</xsl:text>
|
|
Packit |
0f19cf |
<xsl:call-template name="normalize-border">
|
|
Packit |
0f19cf |
<xsl:with-param name="string" select="substring-after($string,'
')"/>
|
|
Packit |
0f19cf |
<xsl:with-param name="step" select="'cont'"/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:otherwise>
|
|
Packit |
0f19cf |
</xsl:choose>
|
|
Packit |
0f19cf |
</xsl:when>
|
|
Packit |
0f19cf |
<xsl:otherwise>
|
|
Packit |
0f19cf |
<xsl:value-of select="$left"/>
|
|
Packit |
0f19cf |
<xsl:text>
</xsl:text>
|
|
Packit |
0f19cf |
<xsl:variable name="right" select="substring-after($string,'
')"/>
|
|
Packit |
0f19cf |
<xsl:if test="string-length(normalize-space($right))!=0">
|
|
Packit |
0f19cf |
<xsl:call-template name="normalize-border">
|
|
Packit |
0f19cf |
<xsl:with-param name="string" select="$right"/>
|
|
Packit |
0f19cf |
<xsl:with-param name="step" select="'cont'"/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:if>
|
|
Packit |
0f19cf |
</xsl:otherwise>
|
|
Packit |
0f19cf |
</xsl:choose>
|
|
Packit |
0f19cf |
</xsl:template>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
replace all occurences of the character(s) `from'
|
|
Packit |
0f19cf |
by the string `to' in the string `string'.
|
|
Packit |
0f19cf |
-->
|
|
Packit |
0f19cf |
<xsl:template name="string-replace" >
|
|
Packit |
0f19cf |
<xsl:param name="string"/>
|
|
Packit |
0f19cf |
<xsl:param name="from"/>
|
|
Packit |
0f19cf |
<xsl:param name="to"/>
|
|
Packit |
0f19cf |
<xsl:choose>
|
|
Packit |
0f19cf |
<xsl:when test="contains($string,$from)">
|
|
Packit |
0f19cf |
<xsl:value-of select="substring-before($string,$from)"/>
|
|
Packit |
0f19cf |
<xsl:value-of select="$to"/>
|
|
Packit |
0f19cf |
<xsl:call-template name="string-replace">
|
|
Packit |
0f19cf |
<xsl:with-param name="string" select="substring-after($string,$from)"/>
|
|
Packit |
0f19cf |
<xsl:with-param name="from" select="$from"/>
|
|
Packit |
0f19cf |
<xsl:with-param name="to" select="$to"/>
|
|
Packit |
0f19cf |
</xsl:call-template>
|
|
Packit |
0f19cf |
</xsl:when>
|
|
Packit |
0f19cf |
<xsl:otherwise>
|
|
Packit |
0f19cf |
<xsl:value-of select="$string"/>
|
|
Packit |
0f19cf |
</xsl:otherwise>
|
|
Packit |
0f19cf |
</xsl:choose>
|
|
Packit |
0f19cf |
</xsl:template>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
</xsl:stylesheet>
|