<?xml version="1.0" encoding="utf-8"?>
<!--
Basic text formatting, like emphasis, bold, etc.
-->
<stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- "Logical" styles. -->
<!-- Emphasis (normally italic). -->
<template name="emph" match="emph|em">
<common formats="/latex/xelatex/">
<xsl:text>\emph{</xsl:text>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<em><xsl:apply-templates /></em>
</common>
</template>
<!--
Emphasis inside answers needs to be handled specially in HTML, as it doesn't just flip-flop automatically like it does in LaTeX.
-->
<template name="emph-in-answer" match="answer//emph|answer//em">
<common formats="/latex/xelatex/">
<xsl:text>\emph{</xsl:text>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<strong><xsl:apply-templates /></strong>
</common>
</template>
<!-- Strong emphasis (normally bold). -->
<template name="strong" match="strong">
<common formats="/latex/xelatex/">
<xsl:text>\textbf{</xsl:text>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<strong><xsl:apply-templates /></strong>
</common>
</template>
<!-- A defined term. -->
<template name="term" match="term">
<common formats="/latex/xelatex/">
<xsl:text>\term{</xsl:text>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<i class="term"><xsl:apply-templates /></i>
</common>
</template>
<!-- A foreign word or phrase. -->
<template name="foreign" match="foreign">
<common formats="/latex/xelatex/">
<xsl:text>\foreign{</xsl:text>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<i class="foreign"><xsl:apply-templates /></i>
</common>
</template>
<!-- "Physical" styles. -->
<!-- Italics. -->
<template name="italic" match="italic">
<common formats="/latex/xelatex/">
<xsl:text>\textit{</xsl:text>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<i><xsl:apply-templates /></i>
</common>
</template>
<!-- Bold face. -->
<template name="bold" match="bold">
<common formats="/latex/xelatex/">
<xsl:text>\textbf{</xsl:text>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<b><xsl:apply-templates /></b>
</common>
</template>
<!-- Underlining. -->
<template name="underline" match="underline|u">
<common formats="/latex/xelatex/">
<xsl:text>\uline{</xsl:text>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<span style="text-decoration: underline;"><xsl:apply-templates /></span>
</common>
</template>
<!-- Strike-through. -->
<template name="strike-through" match="strike-through|line-through|strikethrough|linethrough">
<common formats="/latex/xelatex/">
<xsl:text>\sout{</xsl:text>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<span style="text-decoration: line-through;"><xsl:apply-templates /></span>
</common>
</template>
<!-- Center stuff on the page. -->
<template name="center" match="center|centering|centre|centring">
<common formats="/latex/xelatex/">
<xsl:text>\begin{center}</xsl:text>
<xsl:call-template name="newline-internal" />
<xsl:apply-templates />
<xsl:text>\end{center}</xsl:text>
<xsl:call-template name="newline-internal" />
</common>
<common formats="/html/xhtml/">
<div style="text-align: center;">
<xsl:apply-templates />
</div>
</common>
</template>
<!--
Simple inline text colors using CSS colour names. (This requires the css-colors package in LaTeX.)
TODO: RGB colours?
@name: The CSS name of the colour. [REQUIRED]
-->
<template name="colour" match="color|colour">
<common formats="/latex/xelatex/">
<xsl:text>\textcolor{</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>}{</xsl:text>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<div style="color: {@name};">
<xsl:apply-templates />
</div>
</common>
</template>
<!--
Convert the input string into Title Case.
$input-string: The string to be converted.
Returns: The converted string.
-->
<function name="infosci:title-case" as="xs:string">
<common>
<xsl:param name="input-string" />
<xsl:variable name="output-string">
<xsl:choose>
<xsl:when test="contains($input-string, ' ')">
<xsl:value-of select="infosci:title-case(substring-before($input-string, ' '))" />
<xsl:text> </xsl:text>
<xsl:value-of select="infosci:title-case(substring-after($input-string, ' '))" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(upper-case(substring($input-string, 1, 1)), substring($input-string, 2))" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:sequence select="$output-string" />
</common>
</function>
</stylesheet>