html.xsl revision 39926890ef5576499f1bd78a1412b43e79f2f694
2058N/A<
xsl:
stylesheet version="1.0" 2058N/A<!-- ==================================================================== --> 2058N/A<!-- Ordinary HTML that must be converted to latex --> 2058N/A<!-- ==================================================================== --> 6033N/A<
xsl:
text>\begin{description}
3996N/A<
xsl:
text>\item[</
xsl:
text><
xsl:
apply-
templates/>
2058N/A<!-- Latex doesn't like successive line breaks, so replace any 2058N/A sequence of two or more br separated only by white-space with 3789N/A one line break followed by smallskips. --> 4070N/A<
xsl:
when test="name(preceding-sibling::node()[1])='br'">
2058N/A<
xsl:
text>\smallskip </
xsl:
text>
2058N/A<
xsl:
when test="name(preceding-sibling::node()[2])='br'">
2058N/A <
xsl:
when test="normalize-space(preceding-sibling::node()[1])=''">
2058N/A <
xsl:
text>\smallskip </
xsl:
text>
<
xsl:
template match="code">
<
xsl:
text>\texttt{</
xsl:
text>
<
xsl:
template match="strong">
<
xsl:
text>\textbf{</
xsl:
text>
<
xsl:
template match="em">
<
xsl:
text>\textit{</
xsl:
text>
<!-- Value-of used here explicitly because we don't wan't latex-escaping performed. Of course, this will conflict with html where some tags are <
xsl:
template match="pre">
<
xsl:
text>\begin{verbatim}
<
xsl:
value-
of select="."/>
<
xsl:
template match="blockquote">
<
xsl:
text>\begin{quotation}
<
xsl:
text>\end{quotation}
<!-- XXX: We need to deal with table headers --> <
xsl:
template match="table">
<
xsl:
text>\begin{tabular}{</
xsl:
text>
<
xsl:
when test="columnspec">
<
xsl:
for-
each select="tr[1]/*">
<
xsl:
apply-
templates select="tr"/>
<
xsl:
template match="tr">
<
xsl:
apply-
templates select="td"/>
<
xsl:
template match="td">
<
xsl:
variable name="pos" select="position()"/>
<
xsl:
text>\begin{minipage}[t]{</
xsl:
text>
<
xsl:
value-
of select="1 div last()"/>
<
xsl:
text>\linewidth}</
xsl:
text>
<
xsl:
text>\end{minipage}</
xsl:
text>
<
xsl:
if test="not(position()=last())">
<
xsl:
text> & </
xsl:
text>
This is a horrible hack, but it seems to mostly work. It does a 1. Transforms references starting in http:// to footnotes with the appropriate hyperref macro to make them clickable. (This needs to be expanded to deal with news: and needs to be adjusted to deal with "#", which is creating bad links at the moment.) 2. For intra-document references, constructs the appropriate absolute reference using a latex \pageref. This involves applying a simplified version of the general URL resolution rules to deal with ../. It only works for one level of subdirectory. 3. It is also necessary to deal with the fact that index pages <
xsl:
variable name="relpath" select="document(/*/@metafile)/metafile/relpath" />
<
xsl:
variable name="path" select="document(/*/@metafile)/metafile/path" />
<
xsl:
variable name="fileref">
<
xsl:
when test="contains(@href, '.html')">
<
xsl:
value-
of select="substring-before(@href, '.html')"/>
<
xsl:
value-
of select="concat(@href, 'index')"/>
<
xsl:
when test="starts-with(@href, 'http:') or starts-with(@href, 'news:') or starts-with(@href, 'mailto:')">
<
xsl:
if test="not(.=@href)">
<
xsl:
text>\footnote{</
xsl:
text>
<
xsl:
text>\href{</
xsl:
text>
<
xsl:
value-
of select="@href"/>
<
xsl:
call-
template name="htescape">
<
xsl:
with-
param name="string" select="@href"/>
<
xsl:
when test="starts-with(@href, '#')">
<!-- Don't do inter-section references --> <
xsl:
text> (p.\ \pageref{</
xsl:
text>
<
xsl:
call-
template name="replace-string">
<
xsl:
with-
param name="replace" select="'#'"/>
<
xsl:
with-
param name="with" select="':'"/>
<
xsl:
with-
param name="text">
<
xsl:
when test="$relpath='.'">
<
xsl:
value-
of select="concat('/',$fileref)"/>
<
xsl:
when test="starts-with($fileref,'..')">
<
xsl:
value-
of select="substring-after($fileref,'..')"/>
<
xsl:
value-
of select="concat($path,$fileref)"/>
<
xsl:
template match="img">
<
xsl:
text>[Image not coverted]</
xsl:
text>
<xsl:variable name="path" select="document(/*/@metafile)/metafile/path" /> <xsl:text>\includegraphics{</xsl:text> <xsl:value-of select="concat('.',$path,@src)"/>