-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.xsl
More file actions
42 lines (35 loc) · 1.17 KB
/
math.xsl
File metadata and controls
42 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lxir="http://www.latex-lxir.org"
xmlns:mathml="http://www.w3.org/1998/Math/MathML"
exclude-result-prefixes="lxir mathml">
<xsl:template match="mathml:math">
<xsl:copy>
<xsl:apply-templates mode="math" select="@* | * | text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="mathml:math/@type" mode="math">
<xsl:attribute name="display"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>
<!--
The LaTeX sources contain code like
text$_1$
i.e. a inline math "block" without base for the subscript.
This cannot be expressed directly in MathML, since MathML's
<msub> requires a base.
Therefore, LXir translates it to <sub><math>...</math></sub>
-->
<xsl:template match=" sub[count(*) = 1 and ./mathml:math]
| sup[count(*) = 1 and ./mathml:math]">
<xsl:copy>
<xsl:apply-templates mode="math" select="@* | * | text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | * | text()" mode="math">
<xsl:copy>
<xsl:apply-templates mode="math" select="@* | * | text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>