Preliminary math and tables support.
[librarian.git] / librarian / res / embeds / mathml / mathml2latex.xslt
diff --git a/librarian/res/embeds/mathml/mathml2latex.xslt b/librarian/res/embeds/mathml/mathml2latex.xslt
new file mode 100644 (file)
index 0000000..76ccf95
--- /dev/null
@@ -0,0 +1,66 @@
+<xsl:stylesheet version = '1.0'
+xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
+xmlns:ldf="http://planet-sl.org/ldf"
+xmlns:mml="http://www.w3.org/1998/Math/MathML">
+
+<xsl:output method="txt" encoding="utf-8" omit-xml-declaration="yes"/> 
+
+<xsl:template match="mml:mtext">
+       <xsl:text>\textrm{</xsl:text>
+       <xsl:apply-templates select="node()"/>
+       <xsl:text>}</xsl:text>
+</xsl:template>
+
+<xsl:template match="mml:mi">
+       <xsl:value-of select="."/>
+</xsl:template>
+
+<xsl:template match="mml:mn">
+       <xsl:value-of select="."/>
+</xsl:template>
+
+<xsl:template match="mml:mo">
+       <xsl:value-of select="."/>
+</xsl:template>
+
+<xsl:template match="mml:msup">
+       <xsl:text>{</xsl:text>
+       <xsl:apply-templates select="*[1]"/>
+       <xsl:text>}^{</xsl:text>
+       <xsl:apply-templates select="*[2]"/>
+       <xsl:text>}</xsl:text>
+</xsl:template>
+
+<xsl:template match="mml:msub">
+       <xsl:text>{</xsl:text>
+       <xsl:apply-templates select="*[1]"/>
+       <xsl:text>}_{</xsl:text>
+       <xsl:apply-templates select="*[2]"/>
+       <xsl:text>}</xsl:text>
+</xsl:template>
+
+<xsl:template match="mml:mrow">
+       <xsl:text>{</xsl:text>
+       <xsl:apply-templates select="node()"/>
+       <xsl:text>}</xsl:text>
+</xsl:template>
+
+<xsl:template match="mml:mfenced">
+       <xsl:text>(</xsl:text>
+       <xsl:apply-templates select="node()"/>
+       <xsl:text>)</xsl:text>
+</xsl:template>
+
+<xsl:template match="mml:mfrac">
+       <xsl:text>\frac{</xsl:text>
+       <xsl:apply-templates select="*[1]"/>
+       <xsl:text>}{</xsl:text>
+       <xsl:apply-templates select="*[2]"/>
+       <xsl:text>}</xsl:text>
+</xsl:template>
+
+<xsl:template match="mml:varepsilon">
+       <xsl:text>\varepsilon </xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>