Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 1833
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="me">\[<xsl:value-of select="."/>\]</xsl:template>
29
<xsl:template match="md">
30
\begin{align*} <xsl:apply-templates select="mrow"/> \end{align*}
31
</xsl:template>
32
<xsl:template match="mrow"><xsl:value-of select="."/> \\</xsl:template>
33
<xsl:template match="m">\(<xsl:value-of select="."/>\)</xsl:template>
34
35
<xsl:template match="em">\textbf{<xsl:value-of select="."/>}</xsl:template>
36
37
<xsl:template match="ul">
38
39
\begin{itemize}<xsl:apply-templates select="li"/>
40
\end{itemize}
41
42
</xsl:template>
43
<xsl:template match="ol">
44
45
\begin{enumerate}[(a)]<xsl:apply-templates select="li"/>
46
\end{enumerate}
47
48
</xsl:template>
49
<xsl:template match="li">
50
\item <xsl:apply-templates/>
51
</xsl:template>
52
53
<xsl:template match="c">\verb|<xsl:value-of select="."/>|</xsl:template>
54
<xsl:template match="url">\verb|<xsl:value-of select="@href"/>|</xsl:template>
55
56
<xsl:template match="figure">
57
58
\begin{figure*}[h]\centering
59
\includegraphics[height=2in]{assets/<xsl:value-of select="image/@TEMP-assets-file"/>}
60
\caption*{<xsl:value-of select="caption"/>}
61
\end{figure*}
62
63
</xsl:template>
64
<xsl:template match="image"/><!-- currently kill images outside figures -->
65
66
</xsl:stylesheet>
67