Newer
Older
XML / modules / miscellaneous-symbols.xml
<?xml version="1.0" encoding="utf-8"?>

<!--
	Miscellaneous typographic symbols, including punctuation marks and logos (e.g., for LaTeX).
	
	Technically we don't need to disable output escaping for all of these, but it's probably better to code them all consistently, rather than trying to figure out which ones do need it (e.g., &#160; for a non-breaking space) and which ones don't (e.g., &amp;).

	The "strip" mode forms of the templates are for use in the context of an HTML <title> element (so the mode is only relevant to the HTML formats). Embedding HTML markup inside the <title> element causes the markup to appear verbatim in the window title, i.e., <title><em>foo</em> bar</title> will appear in the window title as "<em>foo</em> bar", not "foo bar". Putting the stylesheet into strip mode means that it will only output text nodes unless otherwise specified for a particular element. Generally the "strip" templates will simply call-template to the original, unless the original contains markup that needs to be eliminated (e.g., see space below).
	
	The downside of this approach, of course, is that you need "strip" mode templates for quite a lot of things, but that can't really be helped.
-->

<stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


	<!-- Sharp/number symbol (#). -->
	
	<template name="sharp-sign" match="sharp|hash|number-sign">
		<common formats="/latex/xelatex/"><xsl:text>{\#}</xsl:text></common>
		<!-- U+0023 NUMBER SIGN -->
		<common formats="/html/xhtml/"><xsl:text>#</xsl:text></common>
	</template>

	<template name="sharp-sign-strip" match="sharp|hash|number-sign" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="sharp-sign" />
		</common>
	</template>

	
	<!-- Dollar sign ($). -->
	
	<template name="dollar" match="dollar|dollar-sign">
		<common formats="/latex/xelatex/"><xsl:text>{\$}</xsl:text></common>
		<!-- U+0024 DOLLAR SIGN -->
		<common formats="/html/xhtml/"><xsl:text>$</xsl:text></common>
	</template>

	<template name="dollar-strip" match="dollar|dollar-sign" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="dollar" />
		</common>
	</template>

	
	<!-- Percent sign (%). -->
	
	<template name="percent-sign" match="percent-sign|percentage-sign|percent">
		<common formats="/latex/xelatex/"><xsl:text>{\%}</xsl:text></common>
		<!-- U+0025 PERCENT SIGN -->
		<common formats="/html/xhtml/"><xsl:text>%</xsl:text></common>
	</template>

	<template name="percent-sign-strip" match="percent-sign|percentage-sign|percent" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="percent-sign" />
		</common>
	</template>

	
	<!-- Ampersand (&). -->
	
	<template name="ampersand" match="ampersand">
		<common formats="/latex/xelatex/"><xsl:text>{\&amp;}</xsl:text></common>
		<!-- Would be U+0026 AMPERSAND, except it has special meaning in XML. -->
		<common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes">&amp;amp;</xsl:text></common>
	</template>

	<template name="ampersand-strip" match="ampersand" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="ampersand" />
		</common>
	</template>

	
	<!-- Backslash (\). -->
	
	<template name="backslash" match="backslash">
		<common formats="/latex/xelatex/"><xsl:text>\(\backslash\)</xsl:text></common>
		<!-- U+005C REVERSE SOLIDUS -->
		<common formats="/html/xhtml/"><xsl:text>\</xsl:text></common>
	</template>

	<template name="backslash-strip" match="backslash" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="backslash" />
		</common>
	</template>

	
	<!-- Underscore (_). Use this for literal underscores that appear outside code blocks. Such things cause LaTeX to wig out. -->
	
	<template name="underscore" match="underscore|low-line">
		<common formats="/latex/xelatex/"><xsl:text>\_</xsl:text></common>
		<!-- U+005F LOW LINE -->
		<common formats="/html/xhtml/"><xsl:text>_</xsl:text></common>
	</template>

	<template name="underscore-strip" match="underscore|low-line" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="underscore" />
		</common>
	</template>

	
	<!-- Left brace ({). -->
	
	<template name="left-curly-bracket" match="left-curly-bracket|left-curly-brace|left-brace">
		<common formats="/latex/xelatex/"><xsl:text>\ensuremath{\{}</xsl:text></common>
		<!-- U+007B LEFT CURLY BRACKET -->
		<common formats="/html/xhtml/"><xsl:text>{</xsl:text></common>
	</template>

	<template name="left-curly-bracket-strip" match="left-curly-bracket|left-curly-brace|left-brace" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="left-curly-bracket" />
		</common>
	</template>

	
	<!-- Right brace (}). -->
	
	<template name="right-curly-bracket" match="right-curly-bracket|right-curly-brace|right-brace">
		<common formats="/latex/xelatex/"><xsl:text>\ensuremath{\}}</xsl:text></common>
		<!-- U+007D LEFT CURLY BRACKET -->
		<common formats="/html/xhtml/"><xsl:text>}</xsl:text></common>
	</template>

	<template name="right-curly-bracket-strip" match="right-curly-bracket|right-curly-brace|right-brace" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="right-curly-bracket" />
		</common>
	</template>
	
	
	<!-- Degree symbol (°). -->
	
	<template name="degree-sign" match="degree-sign|degrees">
		<common formats="/latex/xelatex/"><xsl:text>\ensuremath{^{\circ}}</xsl:text></common>
		<html><xsl:text disable-output-escaping="yes">&amp;deg;</xsl:text></html>
		<!-- U+0080 DEGREE SIGN -->
		<xhtml><xsl:text>°</xsl:text></xhtml>
	</template>

	<template name="degree-sign-strip" match="degree-sign|degrees" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="degree-sign" />
		</common>
	</template>

	
	<!-- Section symbol (§). -->
	
	<template name="section-sign" match="section-sign">
		<common formats="/latex/xelatex/"><xsl:text>{\S}</xsl:text></common>
		<html><xsl:text disable-output-escaping="yes">&amp;sect;</xsl:text></html>
		<!-- U+00A7 SECTION SIGN -->
		<xhtml><xsl:text>§</xsl:text></xhtml>
	</template>

	<template name="section-sign-strip" match="section-sign" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="section-sign" />
		</common>
	</template>

	
	<!-- Copyright symbol (©). -->
	
	<template name="copyright-sign" match="copyright-sign">
		<common formats="/latex/xelatex/"><xsl:text>{\copyright}</xsl:text></common>
		<html><xsl:text disable-output-escaping="yes">&amp;copy;</xsl:text></html>
		<!-- U+00A9 COPYRIGHT SIGN -->
		<xhtml><xsl:text>©</xsl:text></xhtml>
	</template>

	<template name="copyright-sign-strip" match="copyright-sign" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="copyright-sign" />
		</common>
	</template>

	
	<!-- Paragraph/pilcrow symbol (¶). -->
	
	<template name="paragraph-sign" match="paragraph-sign|pilcrow|pilcrow-sign">
		<common formats="/latex/xelatex/"><xsl:text>{\P}</xsl:text></common>
		<html><xsl:text disable-output-escaping="yes">&amp;para;</xsl:text></html>
		<!-- U+00B6 PILCROW SIGN -->
		<xhtml><xsl:text>¶</xsl:text></xhtml>
	</template>

	<template name="paragraph-sign-strip" match="paragraph-sign|pilcrow|pilcrow-sign" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="paragraph-sign" />
		</common>
	</template>

	
	<!-- Figure/number dash (‒). -->
	
	<template name="figure-dash" match="figure-dash|number-dash">	
		<common formats="/latex/xelatex/"><xsl:text>--</xsl:text></common>
		<!-- &ndash; is close enough. -->
		<html><xsl:text disable-output-escaping="yes">&amp;ndash;</xsl:text></html>
		<!-- U+2012 FIGURE DASH -->
		<xhtml><xsl:text>‒</xsl:text></xhtml>
	</template>

	<template name="figure-dash-strip" match="figure-dash|number-dash" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="figure-dash" />
		</common>
	</template>

	
	<!-- En dash (–). -->
	
	<template name="endash" match="endash|en-dash|ndash|n-dash">	
		<common formats="/latex/xelatex/"><xsl:text>--</xsl:text></common>
		<html><xsl:text disable-output-escaping="yes">&amp;ndash;</xsl:text></html>
		<!-- U+2013 EN DASH -->
		<xhtml><xsl:text>–</xsl:text></xhtml>
	</template>

	<template name="endash-strip" match="endash|en-dash|ndash|n-dash" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="endash" />
		</common>
	</template>

	
	<!-- Em dash (—). -->
	
	<template name="emdash" match="emdash|em-dash|mdash|m-dash">
		<common formats="/latex/xelatex/"><xsl:text>---</xsl:text></common>
		<html><xsl:text disable-output-escaping="yes">&amp;mdash;</xsl:text></html>
		<xhtml><xsl:text>—</xsl:text></xhtml>
		<!-- U+2014 EM DASH -->
	</template>
	
	<template name="emdash-strip" match="emdash|em-dash|mdash|m-dash" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="emdash" />
		</common>
	</template>
	
	
	<!-- Apostrophe (’). -->
	
	<template name="apostrophe" match="apostrophe|right-single-quotation-mark">
		<common formats="/latex/xelatex/"><xsl:text>'</xsl:text></common>
		<html><xsl:text disable-output-escaping="yes">&amp;rsquo;</xsl:text></html>
		<!-- U+2019 RIGHT SINGLE QUOTATION MARK -->
		<xhtml><xsl:text>’</xsl:text></xhtml>
	</template>

	<template name="apostrophe-strip" match="apostrophe|right-single-quotation-mark" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="apostrophe" />
		</common>
	</template>

	
	<!-- Ellipsis (…). -->
	
	<template name="ellipsis-sign" match="ellipsis-sign|etc|ellipsis|dots|horizontal-ellipsis">
		<common formats="/latex/xelatex/"><xsl:text>{\ldots}</xsl:text></common>
		<html><xsl:text disable-output-escaping="yes">&amp;hellip;</xsl:text></html>
		<!-- U+2026 HORIZONTAL ELLIPSIS -->
		<xhtml><xsl:text>…</xsl:text></xhtml>
	</template>

	<template name="ellipsis-sign-strip" match="ellipsis-sign|etc|ellipsis|dots|horizontal-ellipsis" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="ellipsis-sign" />
		</common>
	</template>

	
	<!-- Trademark symbol (™). -->
	
	<template name="trademark-sign" match="trademark-sign|trademark|tm|trade-mark-sign">
		<common formats="/latex/xelatex/"><xsl:text>{\texttrademark}</xsl:text></common>
		<html><xsl:text disable-output-escaping="yes">&amp;trade;</xsl:text></html>
		<!-- U+2122 TRADE MARK SIGN -->
		<xhtml><xsl:text>™</xsl:text></xhtml>
	</template>

	<template name="trademark-sign-strip" match="trademark-sign|trademark|tm|trade-mark-sign" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="trademark-sign" />
		</common>
	</template>
	
	
	<!-- The LaTeX logo. Technically this isn't a "symbol", but this is the most logical place to put it. -->
	
	<template name="LaTeX" match="LaTeX|latex">
		<common formats="/latex/xelatex/"><xsl:text>{\LaTeX}</xsl:text></common>
		<common formats="/html/xhtml/">L<sup>A</sup>T<sub>E</sub>X</common>
	</template>

	<template name="LaTeX-strip" match="LaTeX|latex" mode="strip">
		<common formats="/html/xhtml/"><xsl:text>LaTeX</xsl:text></common>
	</template>
	
	
</stylesheet>