GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
1
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
XML
Browse code
- Reformatted code and made more consistent use of xsl:text.
- Refactored <span> generation into a parameterised template.
master
1 parent
6453fc2
commit
e162bb87dc8754d6217dac4db9efbdb94355f846
nstanger
authored
on 7 Oct 2011
Patch
Showing
1 changed file
modules/fonts.xml
Ignore Space
Show notes
View
modules/fonts.xml
<?xml version="1.0" encoding="utf-8"?> <!-- Font and typeface control. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Typewriter (monospaced) type. --> <template name="typewriter" match="typewriter|monospace|tt"> <common formats="/latex/xelatex/"> <xsl:text>\texttt{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <tt><xsl:apply-templates /></tt> </common> </template> <!-- Sans serif type. --> <template name="sans-serif" match="sans-serif|sans|ss|sf"> <common formats="/latex/xelatex/"> <xsl:text>\textsf{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <font face="sans-serif"><xsl:apply-templates /></font> </common> </template> <!-- Font sizing, using relative font size elements borrowed from LaTeX. Note that we use CSS relative font sizes (smaller and larger), which means that we have to string a bunch of them together to achieve the same effect as a single command in LaTeX. We can't use absolute sizes in CSS as they would probably look different on different machines. --> <template name="tiny" match="tiny"> <common formats="/latex/xelatex/"> <xsl:text>{\tiny </xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:call-template name="generate-html-fontsize"> <xsl:with-param name="repetitions">4</xsl:with-param> <xsl:with-param name="size" >smaller</xsl:with-param> </xsl:call-template> </common> </template> <template name="scriptsize" match="scriptsize"> <common formats="/latex/xelatex/"> <xsl:text>{\scriptsize </xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:call-template name="generate-html-fontsize"> <xsl:with-param name="repetitions">3</xsl:with-param> <xsl:with-param name="size" >smaller</xsl:with-param> </xsl:call-template> </common> </template> <template name="footnotesize" match="footnotesize"> <common formats="/latex/xelatex/"> <xsl:text>{\footnotesize </xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:call-template name="generate-html-fontsize"> <xsl:with-param name="repetitions">2</xsl:with-param> <xsl:with-param name="size" >smaller</xsl:with-param> </xsl:call-template> </common> </template> <template name="small" match="small"> <common formats="/latex/xelatex/"> <xsl:text>{\small </xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:call-template name="generate-html-fontsize"> <xsl:with-param name="repetitions">1</xsl:with-param> <xsl:with-param name="size" >smaller</xsl:with-param> </xsl:call-template> </common> </template> <template name="large" match="large"> <common formats="/latex/xelatex/"> <xsl:text>{\large </xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:call-template name="generate-html-fontsize"> <xsl:with-param name="repetitions">1</xsl:with-param> <xsl:with-param name="size" >larger</xsl:with-param> </xsl:call-template> </common> </template> <!-- Fortunately, XML is case-sensitive. --> <template name="Large" match="Large"> <common formats="/latex/xelatex/"> <xsl:text>{\Large </xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:call-template name="generate-html-fontsize"> <xsl:with-param name="repetitions">2</xsl:with-param> <xsl:with-param name="size" >larger</xsl:with-param> </xsl:call-template> </common> </template> <template name="LARGE" match="LARGE"> <common formats="/latex/xelatex/"> <xsl:text>{\LARGE </xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:call-template name="generate-html-fontsize"> <xsl:with-param name="repetitions">3</xsl:with-param> <xsl:with-param name="size" >larger</xsl:with-param> </xsl:call-template> </common> </template> <template name="huge" match="huge"> <common formats="/latex/xelatex/"> <xsl:text>{\huge </xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:call-template name="generate-html-fontsize"> <xsl:with-param name="repetitions">4</xsl:with-param> <xsl:with-param name="size" >larger</xsl:with-param> </xsl:call-template> </common> </template> <template name="Huge" match="Huge"> <common formats="/latex/xelatex/"> <xsl:text>{\Huge </xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:call-template name="generate-html-fontsize"> <xsl:with-param name="repetitions">5</xsl:with-param> <xsl:with-param name="size" >larger</xsl:with-param> </xsl:call-template> </common> </template> <!-- Utility template to generate the appropriate number of <span> elements to set the relative font size correctly in HTML. $repetitions: The number of times to repeat the <span>. [default 1] $size: The "direction" of the relative font size. 'smaller' [default] 'larger' --> <template name="generate-html-fontsize"> <common formats="/html/xhtml/"> <xsl:param name="repetitions">1</xsl:param> <xsl:param name="size">smaller</xsl:param> <xsl:for-each select="1 to $repetitions"> <!-- Unfortunately, we have to generate the <span> elements as raw text rather than proper elements because of the separation of the opening and closing tags across different loops. --> <xsl:text disable-output-escaping="yes"><span style="font-size:</xsl:text> <xsl:value-of select="$size" /> <xsl:text disable-output-escaping="yes">;"></xsl:text> </xsl:for-each> <xsl:apply-templates /> <xsl:for-each select="1 to $repetitions"> <xsl:text disable-output-escaping="yes"></span></xsl:text> </xsl:for-each> </common> </template> <!-- Non-maths super- and subscript. --> <template name="superscript" match="superscript"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{^{\mathrm{</xsl:text> <xsl:apply-templates /> <xsl:text>}}}</xsl:text> </common> <common formats="/html/xhtml/"> <sup><xsl:apply-templates /></sup> </common> </template> <template name="subscript" match="subscript"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{_{\mathrm{</xsl:text> <xsl:apply-templates /> <xsl:text>}}}</xsl:text> </common> <common formats="/html/xhtml/"> <sub><xsl:apply-templates /></sub> </common> </template> </stylesheet>
<?xml version="1.0" encoding="utf-8"?> <!-- Font and typeface control. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Typewriter (monospaced) type. --> <template name="typewriter" match="typewriter|monospace|tt"> <common formats="/latex/xelatex/">\texttt{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><tt><xsl:apply-templates /></tt></common> </template> <!-- Sans serif type. --> <template name="sans-serif" match="sans-serif|sans|ss|sf"> <common formats="/latex/xelatex/">\textsf{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><font face="sans-serif"><xsl:apply-templates /></font></common> </template> <!-- Font sizing, using relative font size elements borrowed from LaTeX. Note that we use CSS relative font sizes (smaller and larger), which means that we have to string a bunch of them together to achieve the same effect as a single command in LaTeX. We can't use absolute sizes in CSS as they would probably look different on different machines. --> <template name="tiny" match="tiny"> <common formats="/latex/xelatex/">{\tiny <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </span> </span> </span> </common> </template> <template name="scriptsize" match="scriptsize"> <common formats="/latex/xelatex/">{\scriptsize <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </span> </span> </common> </template> <template name="footnotesize" match="footnotesize"> <common formats="/latex/xelatex/">{\footnotesize <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </span> </common> </template> <template name="small" match="small"> <common formats="/latex/xelatex/">{\small <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </common> </template> <template name="large" match="large"> <common formats="/latex/xelatex/">{\large <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </common> </template> <!-- Fortunately, XML is case-sensitive. --> <template name="Large" match="Large"> <common formats="/latex/xelatex/">{\Large <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </common> </template> <template name="LARGE" match="LARGE"> <common formats="/latex/xelatex/">{\LARGE <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </span> </common> </template> <template name="huge" match="huge"> <common formats="/latex/xelatex/">{\huge <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </span> </span> </common> </template> <template name="Huge" match="Huge"> <common formats="/latex/xelatex/">{\Huge <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </span> </span> </span> </common> </template> <!-- Non-maths super- and subscript. --> <template name="superscript" match="superscript"> <common formats="/latex/xelatex/">\ensuremath{^{\mathrm{<xsl:apply-templates />}}}</common> <common formats="/html/xhtml/"><sup><xsl:apply-templates /></sup></common> </template> <template name="subscript" match="subscript"> <common formats="/latex/xelatex/">\ensuremath{_{\mathrm{<xsl:apply-templates />}}}</common> <common formats="/html/xhtml/"><sub><xsl:apply-templates /></sub></common> </template> </stylesheet>
Show line notes below