Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 1794
Image: ubuntu2004
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="exercise">
10
\begin{exercise}{<xsl:value-of select="@checkit-slug"/>}{<xsl:value-of select="@checkit-title"/>}{<xsl:value-of select="@checkit-seed"/>}<xsl:apply-templates/>\end{exercise}
11
</xsl:template>
12
13
<xsl:template match="statement">
14
\begin{exerciseStatement}<xsl:apply-templates/>\end{exerciseStatement}
15
</xsl:template>
16
17
<xsl:template match="answer">\begin{exerciseAnswer}<xsl:apply-templates/>\end{exerciseAnswer}
18
</xsl:template>
19
20
<xsl:template match="p">
21
<xsl:text>
22
23
</xsl:text><xsl:apply-templates/><xsl:text>
24
25
</xsl:text>
26
</xsl:template>
27
28
<xsl:template match="claim">
29
\begin{center}\begin{minipage}{0.8\textwidth}
30
<xsl:apply-templates/>
31
\end{minipage}\end{center}
32
</xsl:template>
33
34
<xsl:template match="me">\[<xsl:value-of select="."/>\]</xsl:template>
35
36
<xsl:template match="md">
37
<xsl:choose>
38
<xsl:when test="@alignment='alignat'">
39
\begin{alignat*}{<xsl:value-of select="normalize-space(@alignat-columns)"/>} <xsl:apply-templates select="mrow"/> \end{alignat*}
40
</xsl:when>
41
<xsl:otherwise>
42
\begin{align*} <xsl:apply-templates select="mrow"/> \end{align*}
43
</xsl:otherwise>
44
</xsl:choose>
45
</xsl:template>
46
47
48
<xsl:template match="mrow"><xsl:value-of select="."/> \\</xsl:template>
49
50
<xsl:template match="m">\(<xsl:value-of select="."/>\)</xsl:template>
51
52
<xsl:template match="ul">
53
54
\begin{itemize}<xsl:apply-templates select="li"/>
55
\end{itemize}
56
57
</xsl:template>
58
<xsl:template match="ol">
59
60
\begin{enumerate}[(a)]<xsl:apply-templates select="li"/>
61
\end{enumerate}
62
63
</xsl:template>
64
<xsl:template match="li">
65
\item <xsl:apply-templates/>
66
</xsl:template>
67
68
<xsl:template match="c">\verb|<xsl:value-of select="."/>|</xsl:template>
69
<xsl:template match="url">\verb|<xsl:value-of select="@href"/>|</xsl:template>
70
71
</xsl:stylesheet>
72