Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Path: xsl / latex.xsl
Views: 361
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="ul">
36
37
\begin{itemize}<xsl:apply-templates select="li"/>
38
\end{itemize}
39
40
</xsl:template>
41
<xsl:template match="ol">
42
43
\begin{enumerate}[(a)]<xsl:apply-templates select="li"/>
44
\end{enumerate}
45
46
</xsl:template>
47
<xsl:template match="li">
48
\item <xsl:apply-templates/>
49
</xsl:template>
50
51
<xsl:template match="c">\verb|<xsl:value-of select="."/>|</xsl:template>
52
<xsl:template match="url">\verb|<xsl:value-of select="@href"/>|</xsl:template>
53
54
</xsl:stylesheet>
55