Initial commit of mal2latex stylesheets
This commit is contained in:
commit
c21a0c8c42
|
@ -0,0 +1,167 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
|
||||
<!--
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; see the file COPYING.LGPL. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:mal="http://projectmallard.org/1.0/"
|
||||
exclude-result-prefixes="mal"
|
||||
version="1.0">
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="mal:comment"/>
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="mal:code">
|
||||
<xsl:variable name="first" select="node()[1]/self::text()"/>
|
||||
<xsl:variable name="last" select="node()[last()]/self::text()"/>
|
||||
<xsl:text>\begin{boxedminipage}{\textwidth}
</xsl:text>
|
||||
<xsl:text>\begin{alltt}
</xsl:text>
|
||||
<xsl:if test="$first">
|
||||
<xsl:variable name="text">
|
||||
<xsl:call-template name="utils.strip_newlines">
|
||||
<xsl:with-param name="string" select="$first"/>
|
||||
<xsl:with-param name="leading" select="true()"/>
|
||||
<xsl:with-param name="trailing" select="count(node()) = 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="mal2latex.inline.escape">
|
||||
<xsl:with-param name="node" select="$first"/>
|
||||
<xsl:with-param name="text" select="$text"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"
|
||||
select="node()[not(self::text() and (position() = 1 or position() = last()))]"/>
|
||||
<xsl:if test="$last and (count(node()) != 1)">
|
||||
<xsl:variable name="text">
|
||||
<xsl:call-template name="utils.strip_newlines">
|
||||
<xsl:with-param name="string" select="$last"/>
|
||||
<xsl:with-param name="leading" select="false()"/>
|
||||
<xsl:with-param name="trailing" select="true()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="mal2latex.inline.escape">
|
||||
<xsl:with-param name="node" select="$last"/>
|
||||
<xsl:with-param name="text" select="$text"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:text>\end{alltt}
</xsl:text>
|
||||
<xsl:text>\end{boxedminipage}
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="mal:example">
|
||||
<xsl:text>\begin{malexample}
</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.block.mode"/>
|
||||
<xsl:text>\end{malexample}
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="mal:list">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type = 'numbered'">
|
||||
<xsl:text>\begin{enumerate}
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>\begin{itemize}
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:for-each select="mal:item">
|
||||
<xsl:text>\item </xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.block.mode"/>
|
||||
</xsl:for-each>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type = 'numbered'">
|
||||
<xsl:text>\end{enumerate}
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>\end{itemize}
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="mal:note">
|
||||
<xsl:text>\begin{malnote}
</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.block.mode"/>
|
||||
<xsl:text>\end{malnote}
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="mal:screen">
|
||||
<xsl:variable name="first" select="node()[1]/self::text()"/>
|
||||
<xsl:variable name="last" select="node()[last()]/self::text()"/>
|
||||
<xsl:text>\begin{malscreen}
</xsl:text>
|
||||
<xsl:if test="$first">
|
||||
<xsl:variable name="text">
|
||||
<xsl:call-template name="utils.strip_newlines">
|
||||
<xsl:with-param name="string" select="$first"/>
|
||||
<xsl:with-param name="leading" select="true()"/>
|
||||
<xsl:with-param name="trailing" select="count(node()) = 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="mal2latex.inline.escape">
|
||||
<xsl:with-param name="node" select="$first"/>
|
||||
<xsl:with-param name="text" select="$text"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"
|
||||
select="node()[not(self::text() and (position() = 1 or position() = last()))]"/>
|
||||
<xsl:if test="$last and (count(node()) != 1)">
|
||||
<xsl:variable name="text">
|
||||
<xsl:call-template name="utils.strip_newlines">
|
||||
<xsl:with-param name="string" select="$last"/>
|
||||
<xsl:with-param name="leading" select="false()"/>
|
||||
<xsl:with-param name="trailing" select="true()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="mal2latex.inline.escape">
|
||||
<xsl:with-param name="node" select="$last"/>
|
||||
<xsl:with-param name="text" select="$text"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:text>\end{malscreen}
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="mal:steps">
|
||||
<xsl:text>\begin{malsteps}
</xsl:text>
|
||||
<xsl:for-each select="mal:item">
|
||||
<xsl:text>\item </xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.block.mode"/>
|
||||
</xsl:for-each>
|
||||
<xsl:text>\end{malsteps}
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="mal:synopsis">
|
||||
<xsl:message>
|
||||
<xsl:text>FIXME: synopsis</xsl:text>
|
||||
</xsl:message>
|
||||
<xsl:apply-templates mode="mal2latex.block.mode"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="mal:p">
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
<xsl:text>

</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="mal:title">
|
||||
<xsl:text>{\bf </xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
<xsl:text>}

</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="*">
|
||||
<xsl:message>
|
||||
<xsl:text>Unmatched block element: </xsl:text>
|
||||
<xsl:value-of select="local-name(.)"/>
|
||||
</xsl:message>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -0,0 +1,192 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
|
||||
<!--
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; see the file COPYING.LGPL. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:mal="http://projectmallard.org/1.0/"
|
||||
xmlns:str="http://exslt.org/strings"
|
||||
exclude-result-prefixes="mal str"
|
||||
version="1.0">
|
||||
|
||||
<xsl:template mode="mal.link.content.mode" match="*">
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode" select="."/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:app">
|
||||
<xsl:text>\textit{</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
<xsl:text>}</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:cmd">
|
||||
<xsl:text>\framebox{\texttt{</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
<xsl:text>}}</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:code">
|
||||
<xsl:text>\texttt{</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
<xsl:text>}</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:em">
|
||||
<xsl:text>\textit{</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
<xsl:text>}</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:file">
|
||||
<xsl:text>\texttt{</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
<xsl:text>}</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:gui">
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:guiseq">
|
||||
<xsl:for-each select="* | text()[normalize-space(.) != '']">
|
||||
<xsl:if test="position() != 1">
|
||||
<xsl:text> \verb|>| </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode" select="."/>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:input">
|
||||
<xsl:text>\texttt{</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
<xsl:text>}</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:key">
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:keyseq">
|
||||
<xsl:variable name="joinchar">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type = 'sequence'">
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(concat(' ', @style, ' '), ' hyphen ')">
|
||||
<xsl:text>-</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>+</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:for-each select="* | text()[normalize-space(.) != '']">
|
||||
<xsl:if test="position() != 1">
|
||||
<xsl:value-of select="$joinchar"/>
|
||||
</xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="./self::text()">
|
||||
<xsl:value-of select="normalize-space(.)"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode" select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:link">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@xref and normalize-space(.) = ''">
|
||||
<xsl:call-template name="mal.link.content">
|
||||
<xsl:with-param name="role" select="@role"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:span">
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:output">
|
||||
<xsl:text>\texttt{</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
<xsl:text>}</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:sys">
|
||||
<xsl:text>\texttt{</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
<xsl:text>}</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="mal:var">
|
||||
<xsl:text>\textit{</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
<xsl:text>}</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="*">
|
||||
<xsl:message>
|
||||
<xsl:text>Unmatched inline element: </xsl:text>
|
||||
<xsl:value-of select="local-name(.)"/>
|
||||
</xsl:message>
|
||||
<xsl:apply-templates mode="mal2latex.inline.mode"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.inline.mode" match="text()"
|
||||
name="mal2latex.inline.escape">
|
||||
<xsl:param name="node" select="."/>
|
||||
<xsl:param name="text" select="string(.)"/>
|
||||
<xsl:variable name="verbatim"
|
||||
select="$node/ancestor::mal:code or $node/ancestor::mal:screen "/>
|
||||
<xsl:for-each select="str:split($text, '')">
|
||||
<xsl:choose>
|
||||
<xsl:when test=". = '
'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$verbatim">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test=". = '<'">
|
||||
<xsl:text>{\textless}</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=". = '>'">
|
||||
<xsl:text>{\textgreater}</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=". = '\'">
|
||||
<xsl:text>{\textbackslash}</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('$&#_{}', .)">
|
||||
<xsl:text>\</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -0,0 +1,118 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
|
||||
<!--
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; see the file COPYING.LGPL. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:exsl="http://exslt.org/common"
|
||||
xmlns:mal="http://projectmallard.org/1.0/"
|
||||
exclude-result-prefixes="exsl mal"
|
||||
version="1.0">
|
||||
|
||||
<xsl:template name="_repeat_cols">
|
||||
<xsl:param name="num"/>
|
||||
<xsl:if test="$num > 0">
|
||||
<mal:col/>
|
||||
<xsl:call-template name="_repeat_cols">
|
||||
<xsl:with-param name="num" select="$num - 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="mal2latex.block.mode" match="mal:table">
|
||||
<xsl:variable name="cols">
|
||||
<xsl:choose>
|
||||
<xsl:when test="mal:col | mal:colgroup">
|
||||
<xsl:copy-of select="mal:col | mal:colgroup"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:for-each select=".//mal:tr[1]/mal:td">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@colspan">
|
||||
<xsl:call-template name="_repeat_cols">
|
||||
<xsl:with-param name="num" select="number(@colspan)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<mal:col/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="colrules">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(concat(' ', @rules, ' '), 'cols')">
|
||||
<xsl:text>cols</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(concat(' ', @rules, ' '), 'colgroups')">
|
||||
<xsl:text>colgroups</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="@rules = 'all'">
|
||||
<xsl:text>cols</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="@rules = 'colgroups'">
|
||||
<xsl:text>colgroups</xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:text>\begin{tabular}{</xsl:text>
|
||||
<xsl:for-each select="exsl:node-set($cols)/*">
|
||||
<xsl:choose>
|
||||
<xsl:when test="self::mal:colgroup">
|
||||
<xsl:if test="$colrules = 'colgroups'">
|
||||
<xsl:text>|</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:for-each select="mal:col">
|
||||
<xsl:if test="$colrules = 'cols'">
|
||||
<xsl:text>|</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>l</xsl:text>
|
||||
</xsl:for-each>
|
||||
</xsl:when>
|
||||
<xsl:when test="self::mal:col">
|
||||
<xsl:if test="$colrules = 'cols'">
|
||||
<xsl:text>|</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>l</xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
<xsl:if test="$colrules != ''">
|
||||
<xsl:text>|</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>}
</xsl:text>
|
||||
<xsl:for-each select="mal:tr | mal:thead/mal:tr | mal:tfoot/mal:tr | mal:tbody/mal:tr">
|
||||
<xsl:for-each select="mal:td">
|
||||
<xsl:text>\begin{minipage}{1in}
</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.block.mode"/>
|
||||
<xsl:text>\end{minipage}</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="position() = last()">
|
||||
<xsl:text>\\
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text> & </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
<xsl:text>\end{tabular}
</xsl:text>
|
||||
<xsl:text>\par
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -0,0 +1,223 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
|
||||
<!--
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; see the file COPYING.LGPL. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:exsl="http://exslt.org/common"
|
||||
xmlns:cache="http://projectmallard.org/cache/1.0/"
|
||||
xmlns:mal="http://projectmallard.org/1.0/"
|
||||
exclude-result-prefixes="exsl mal"
|
||||
version="1.0">
|
||||
|
||||
<xsl:import href="/usr/share/yelp-xsl/xslt/common/color.xsl"/>
|
||||
<xsl:import href="/usr/share/yelp-xsl/xslt/common/utils.xsl"/>
|
||||
<xsl:import href="/usr/share/yelp-xsl/xslt/mallard/common/mal-link.xsl"/>
|
||||
<xsl:import href="/usr/share/yelp-xsl/xslt/mallard/common/mal-sort.xsl"/>
|
||||
|
||||
<xsl:include href="mal2latex-block.xsl"/>
|
||||
<xsl:include href="mal2latex-inline.xsl"/>
|
||||
<xsl:include href="mal2latex-table.xsl"/>
|
||||
|
||||
<xsl:output method="text"/>
|
||||
|
||||
<xsl:param name="mal.cache" select="/cache:cache"/>
|
||||
|
||||
<xsl:template name="hex2dec">
|
||||
<xsl:param name="hex"/>
|
||||
<xsl:variable name="l">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains('0123456789', substring($hex, 1, 1))">
|
||||
<xsl:value-of select="number(substring($hex, 1, 1))"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Aa', substring($hex, 1, 1))">
|
||||
<xsl:value-of select="10"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Bb', substring($hex, 1, 1))">
|
||||
<xsl:value-of select="11"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Cc', substring($hex, 1, 1))">
|
||||
<xsl:value-of select="12"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Dd', substring($hex, 1, 1))">
|
||||
<xsl:value-of select="13"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Ee', substring($hex, 1, 1))">
|
||||
<xsl:value-of select="14"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Ff', substring($hex, 1, 1))">
|
||||
<xsl:value-of select="15"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="r">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains('0123456789', substring($hex, 2, 1))">
|
||||
<xsl:value-of select="number(substring($hex, 2, 1))"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Aa', substring($hex, 2, 1))">
|
||||
<xsl:value-of select="10"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Bb', substring($hex, 2, 1))">
|
||||
<xsl:value-of select="11"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Cc', substring($hex, 2, 1))">
|
||||
<xsl:value-of select="12"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Dd', substring($hex, 2, 1))">
|
||||
<xsl:value-of select="13"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Ee', substring($hex, 2, 1))">
|
||||
<xsl:value-of select="14"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains('Ff', substring($hex, 2, 1))">
|
||||
<xsl:value-of select="15"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="(16 * $l) + $r"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="convert.color">
|
||||
<xsl:param name="color"/>
|
||||
<xsl:call-template name="hex2dec">
|
||||
<xsl:with-param name="hex" select="substring($color, 2, 2)"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>,</xsl:text>
|
||||
<xsl:call-template name="hex2dec">
|
||||
<xsl:with-param name="hex" select="substring($color, 4, 2)"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>,</xsl:text>
|
||||
<xsl:call-template name="hex2dec">
|
||||
<xsl:with-param name="hex" select="substring($color, 6, 2)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:variable name="blue_border">
|
||||
<xsl:call-template name="convert.color">
|
||||
<xsl:with-param name="color" select="$color.blue_border"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="gray_background">
|
||||
<xsl:call-template name="convert.color">
|
||||
<xsl:with-param name="color" select="$color.gray_background"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="yellow_background">
|
||||
<xsl:call-template name="convert.color">
|
||||
<xsl:with-param name="color" select="$color.yellow_background"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="yellow_border">
|
||||
<xsl:call-template name="convert.color">
|
||||
<xsl:with-param name="color" select="$color.yellow_border"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:template name="sty">
|
||||
<xsl:text>
|
||||
\usepackage{fullpage}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{alltt}
|
||||
\usepackage{boxedminipage}
|
||||
\usepackage{color}
|
||||
\definecolor{blueborder}{RGB}{</xsl:text><xsl:value-of select="$blue_border"/><xsl:text>}
|
||||
\definecolor{grayback}{RGB}{</xsl:text><xsl:value-of select="$gray_background"/><xsl:text>}
|
||||
\definecolor{yellowback}{RGB}{</xsl:text><xsl:value-of select="$yellow_background"/><xsl:text>}
|
||||
\definecolor{yellowborder}{RGB}{</xsl:text><xsl:value-of select="$yellow_border"/><xsl:text>}
|
||||
\setlength{\parindent}{0in}
|
||||
\setlength{\parskip}{1em}
|
||||
\newenvironment{malexample}%
|
||||
{\hskip -10pt \vrule width 2pt \hskip 8pt%
|
||||
\begin{minipage}{\textwidth}%
|
||||
\setlength{\parskip}{1em}}%
|
||||
{\end{minipage}%
|
||||
\par}
|
||||
\newsavebox{\malnotecontainer}
|
||||
\newenvironment{malnote}{%
|
||||
\begin{lrbox}{\malnotecontainer}%
|
||||
\begin{minipage}{\textwidth}}%
|
||||
{\end{minipage}%
|
||||
\end{lrbox}%
|
||||
\fcolorbox{yellowborder}{yellowback}{\usebox{\malnotecontainer}}\par}
|
||||
\newsavebox{\malscreencontainer}
|
||||
\newenvironment{malscreen}{%
|
||||
\begin{lrbox}{\malscreencontainer}%
|
||||
\begin{minipage}{\textwidth}%
|
||||
\begin{alltt}}%
|
||||
{\end{alltt}%
|
||||
\end{minipage}%
|
||||
\end{lrbox}%
|
||||
\fcolorbox{grayback}{grayback}{\usebox{\malscreencontainer}}\par}
|
||||
\newsavebox{\malstepscontainer}
|
||||
\newenvironment{malsteps}{%
|
||||
\begin{lrbox}{\malstepscontainer}%
|
||||
\begin{minipage}{\textwidth}%
|
||||
\begin{enumerate}}%
|
||||
{\end{enumerate}%
|
||||
\end{minipage}%
|
||||
\end{lrbox}%
|
||||
\fcolorbox{blueborder}{yellowback}{\usebox{\malstepscontainer}}\par}
|
||||
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="/cache:cache">
|
||||
<xsl:text>\documentclass{article}
</xsl:text>
|
||||
<xsl:call-template name="sty"/>
|
||||
<xsl:text>\begin{document}
</xsl:text>
|
||||
<xsl:variable name="sorted">
|
||||
<xsl:call-template name="mal.sort.tsort"/>
|
||||
</xsl:variable>
|
||||
<xsl:for-each select="exsl:node-set($sorted)/mal:link">
|
||||
<xsl:variable name="linkid">
|
||||
<xsl:call-template name="mal.link.xref.linkid"/>
|
||||
</xsl:variable>
|
||||
<xsl:for-each select="$mal.cache">
|
||||
<xsl:apply-templates select="document(key('mal.cache.key', $linkid)/@cache:href, /)/mal:page"/>
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
<xsl:text>
\end{document}
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="mal:page">
|
||||
<xsl:text>\pagebreak
\section{</xsl:text>
|
||||
<xsl:value-of select="mal:title"/>
|
||||
<xsl:text>}
</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.block.mode"
|
||||
select="*[not(self::mal:info or self::mal:title or self::mal:subtitle or self::mal:section)]"/>
|
||||
<xsl:apply-templates select="mal:section"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="mal:section">
|
||||
<xsl:choose>
|
||||
<xsl:when test="count(ancestor::mal:section) = 0">
|
||||
<xsl:text>\subsection*{</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>\subsubsection*{</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="mal:title"/>
|
||||
<xsl:text>}
</xsl:text>
|
||||
<xsl:apply-templates mode="mal2latex.block.mode"
|
||||
select="*[not(self::mal:info or self::mal:title or self::mal:subtitle or self::mal:section)]"/>
|
||||
<xsl:apply-templates select="mal:section"/>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
Reference in New Issue