- Split off miscellaneous symbols and emoticons into separate modules.
1 parent 1084c5d commit 18ebf504c6cf1c6b3a8fdeb27d79b2cf4b98cff0
nstanger authored on 31 Aug 2011
Showing 3 changed files
View
291
format-master.xml
<common formats="/latex/xelatex/">\-</common>
<!-- Could use U+00AD SOFT HYPHEN for XHTML? -->
</template>
<!--
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;).
-->
<template name="ellipsis-sign" match="ellipsis-sign|etc|ellipsis|dots|horizontal-ellipsis">
<common formats="/latex/xelatex/">{\ldots}</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>
 
<!-- Misc typographic symbols -->
<template name="endash" match="endash|en-dash|ndash|n-dash">
<common formats="/latex/xelatex/">--</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>
 
<template name="emdash" match="emdash|em-dash|mdash|m-dash">
<common formats="/latex/xelatex/">---</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>
 
<!-- 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/">\_</common>
<!-- U+005F LOW LINE -->
<common formats="/html/xhtml/">_</common>
</template>
 
<template name="underscore-strip" match="underscore|low-line" mode="strip">
<common formats="/html/xhtml/">
<xsl:call-template name="underscore" />
</common>
</template>
 
<template name="backslash" match="backslash">
<common formats="/latex/xelatex/">\(\backslash\)</common>
<!-- U+005C REVERSE SOLIDUS -->
<common formats="/html/xhtml/">\</common>
</template>
 
<template name="backslash-strip" match="backslash" mode="strip">
<common formats="/html/xhtml/">
<xsl:call-template name="backslash" />
</common>
</template>
 
<template name="apostrophe" match="apostrophe|right-single-quotation-mark">
<common formats="/latex/xelatex/">'</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>
 
<template name="dollar" match="dollar|dollar-sign">
<common formats="/latex/xelatex/">{\$}</common>
<!-- U+0024 DOLLAR SIGN -->
<common formats="/html/xhtml/">$</common>
</template>
 
<template name="space-dollar" match="dollar|dollar-sign" mode="strip">
<common formats="/html/xhtml/">
<xsl:call-template name="dollar" />
</common>
</template>
 
<template name="percent-sign" match="percent-sign|percentage-sign|percent">
<common formats="/latex/xelatex/">{\%}</common>
<!-- U+0025 PERCENT SIGN -->
<common formats="/html/xhtml/">%</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>
 
<template name="ampersand" match="ampersand">
<common formats="/latex/xelatex/">{\&amp;}</common>
<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>
 
<template name="trademark-sign" match="trademark-sign|trademark|tm|trade-mark-sign">
<common formats="/latex/xelatex/">{\texttrademark}</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>
 
<template name="copyright-sign" match="copyright-sign">
<common formats="/latex/xelatex/">{\copyright}</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>
 
<template name="degree-sign" match="degree-sign|degrees">
<common formats="/latex/xelatex/">\ensuremath{^{\circ}}</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>
 
<template name="section-sign" match="section-sign">
<common formats="/latex/xelatex/">{\S}</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>
 
<template name="sharp-sign" match="sharp|hash|number-sign">
<common formats="/latex/xelatex/">{\#}</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>
 
<template name="paragraph-sign" match="paragraph-sign|pilcrow|pilcrow-sign">
<common formats="/latex/xelatex/">{\P}</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>
 
<template name="left-curly-bracket" match="left-curly-bracket|left-curly-brace|left-brace">
<common formats="/latex/xelatex/">\ensuremath{\{}</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>
 
<template name="right-curly-bracket" match="right-curly-bracket|right-curly-brace|right-brace">
<common formats="/latex/xelatex/">\ensuremath{\}}</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>
<!-- Greek characters. -->
<include href="modules/greek-characters.xml" />
 
<!-- Miscellaneous symbols. -->
<include href="modules/miscellaneous-symbols.xml" />
 
<!-- Emoticons. -->
<include href="modules/emoticons.xml" />
 
<!-- Mathematical operators and symbols. -->
<include href="modules/mathematical-symbols.xml" />
 
<common formats="/latex/xelatex/">\textbf{<xsl:apply-templates />}</common>
<common formats="/html/xhtml/"><b><xsl:apply-templates /></b></common>
</template>
<!--
Emoticons, specifically :), :| and :(. We may be able to do more
with the HTML version if we switch to Unicode?
The LaTeX version requires the pifont package, which has been added
to the list of standard packages in xml2xslt.xsl. It also requires
Microsoft's Wingdings font (jwi) to be available.
 
@type: the type of emoticon [optional]
'sad'
'neutral' or 'meh' :)
'happy' [default]
-->
<template name="emoticon" match="emoticon|smiley">
<common formats="/latex/xelatex/">
<xsl:choose>
<xsl:when test="@type = 'sad'">
<xsl:text>\Pisymbol{jwi}{"4C}</xsl:text>
</xsl:when>
<xsl:when test="@type = 'neutral' or @type = 'meh'">
<xsl:text>\Pisymbol{jwi}{"4B}</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>\Pisymbol{jwi}{"4A}</xsl:text>
</xsl:otherwise>
</xsl:choose>
</common>
<html>
<xsl:choose>
<xsl:when test="@type = 'sad'">
<xsl:text>:(</xsl:text>
</xsl:when>
<xsl:when test="@type = 'neutral' or @type = 'meh'">
<xsl:text>:|</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>:)</xsl:text>
</xsl:otherwise>
</xsl:choose>
</html>
<xhtml>
<xsl:choose>
<xsl:when test="@type = 'sad'">
<!-- U+2639 WHITE FROWNING FACE -->
<span class="unicode"><xsl:text></xsl:text></span>
</xsl:when>
<!-- There doesn't appear to be a Unicode character for this one. :( -->
<xsl:when test="@type = 'neutral' or @type = 'meh'">
<xsl:text>:|</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- U+263A WHITE SMILING FACE -->
<span class="unicode"><xsl:text></xsl:text></span>
</xsl:otherwise>
</xsl:choose>
</xhtml>
</template>
<template name="emoticon-strip" match="emoticon|smiley" mode="strip">
<common formats="/html/xhtml/">
<xsl:call-template name="emoticon" />
</common>
</template>
 
<!-- Special styles -->
<template name="emph" match="emph|em">
<common formats="/latex/xelatex/">\emph{<xsl:apply-templates />}</common>
<common formats="/html/xhtml/"><em><xsl:apply-templates /></em></common>
View
75
modules/emoticons.xml 0 → 100755
<?xml version="1.0" encoding="utf-8"?>
 
<!--
Emoticons of various sorts.
 
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">
 
<!--
Emoticons, specifically :), :| and :(. We may be able to do more with the HTML version if we switch to Unicode?
The LaTeX version requires the pifont package, which has been added to the list of standard packages in xml2xslt.xsl. It also requires Microsoft's Wingdings font (jwi) to be available.
 
@type: the type of emoticon [optional]
'sad'
'neutral' or 'meh' :)
'happy' [default]
-->
<template name="emoticon" match="emoticon|smiley">
<common formats="/latex/xelatex/">
<xsl:choose>
<xsl:when test="@type = 'sad'">
<xsl:text>\Pisymbol{jwi}{"4C}</xsl:text>
</xsl:when>
<xsl:when test="@type = 'neutral' or @type = 'meh'">
<xsl:text>\Pisymbol{jwi}{"4B}</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>\Pisymbol{jwi}{"4A}</xsl:text>
</xsl:otherwise>
</xsl:choose>
</common>
<html>
<xsl:choose>
<xsl:when test="@type = 'sad'">
<xsl:text>:(</xsl:text>
</xsl:when>
<xsl:when test="@type = 'neutral' or @type = 'meh'">
<xsl:text>:|</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>:)</xsl:text>
</xsl:otherwise>
</xsl:choose>
</html>
<xhtml>
<xsl:choose>
<xsl:when test="@type = 'sad'">
<!-- U+2639 WHITE FROWNING FACE -->
<span class="unicode"><xsl:text></xsl:text></span>
</xsl:when>
<!-- There doesn't appear to be a Unicode character for this one. :( -->
<xsl:when test="@type = 'neutral' or @type = 'meh'">
<xsl:text>:|</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- U+263A WHITE SMILING FACE -->
<span class="unicode"><xsl:text></xsl:text></span>
</xsl:otherwise>
</xsl:choose>
</xhtml>
</template>
<template name="emoticon-strip" match="emoticon|smiley" mode="strip">
<common formats="/html/xhtml/">
<xsl:call-template name="emoticon" />
</common>
</template>
 
</stylesheet>
View
modules/miscellaneous-symbols.xml 0 → 100755