Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
20865 views
1
<?xml version="1.0"?>
2
<xsl:stylesheet version="1.0"
3
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4
<xsl:output method="text"/>
5
6
<!-- Normalize whitespace but don't completely trim beginning or end: https://stackoverflow.com/a/5044657/1607849 -->
7
<xsl:template match="text()"><xsl:value-of select="translate(normalize-space(concat('&#x7F;',.,'&#x7F;')),'&#x7F;','')"/></xsl:template>
8
9
<xsl:template match="statement">
10
\begin{exerciseStatement}
11
<xsl:apply-templates/>
12
\end{exerciseStatement}
13
</xsl:template>
14
15
<xsl:template match="answer">
16
\begin{exerciseAnswer}
17
<xsl:apply-templates/>
18
\end{exerciseAnswer}
19
</xsl:template>
20
21
<xsl:template match="p">
22
<xsl:text>
23
24
</xsl:text><xsl:apply-templates/><xsl:text>
25
26
</xsl:text>
27
</xsl:template>
28
29
<xsl:template match="claim">
30
\begin{center}\begin{minipage}{0.8\textwidth}
31
<xsl:apply-templates/>
32
\end{minipage}\end{center}
33
</xsl:template>
34
35
<xsl:template match="me">\[<xsl:value-of select="."/>\]</xsl:template>
36
37
<xsl:template match="md">
38
<xsl:choose>
39
<xsl:when test="@alignment='alignat'">
40
\begin{alignat*}{<xsl:value-of select="normalize-space(@alignat-columns)"/>} <xsl:apply-templates select="mrow"/> \end{alignat*}
41
</xsl:when>
42
<xsl:otherwise>
43
\begin{align*} <xsl:apply-templates select="mrow"/> \end{align*}
44
</xsl:otherwise>
45
</xsl:choose>
46
</xsl:template>
47
48
49
<xsl:template match="mrow"><xsl:value-of select="."/> \\</xsl:template>
50
51
<xsl:template match="m">\(<xsl:value-of select="."/>\)</xsl:template>
52
53
<xsl:template match="ul">
54
\begin{itemize}<xsl:apply-templates select="li"/>
55
\end{itemize}
56
</xsl:template>
57
<xsl:template match="ol">
58
\begin{enumerate}[(a)]<xsl:apply-templates select="li"/>
59
\end{enumerate}
60
</xsl:template>
61
<xsl:template match="li">
62
\item <xsl:apply-templates/>
63
</xsl:template>
64
65
<xsl:template match="c">\verb|<xsl:value-of select="."/>|</xsl:template>
66
<xsl:template match="url">\verb|<xsl:value-of select="@href"/>|</xsl:template>
67
68
</xsl:stylesheet>
69