Commit 5e2cdb29 authored by Eva Huet's avatar Eva Huet
Browse files

PKP-TEI : fix latex

parent e099624e
Loading
Loading
Loading
Loading
+34 −15
Original line number Diff line number Diff line
@@ -1812,17 +1812,36 @@
    <!-- maths (mathml traité dans la partie figures) -->

    <xsl:template match="tei:formula[@notation='latex']">
<xsl:variable name="clean" select="replace(., '^\$|(\$)$', '')"/>
        <xsl:choose>
            <xsl:when test="parent::tei:figure[@rend='inline']">
            <xsl:text>\(</xsl:text>
            <xsl:value-of select="$clean"/>
            <xsl:text>\)</xsl:text>
                <span class="{@notation}">
                    <xsl:choose>
                        <xsl:when test="starts-with(node(), '$') and substring(node(), string-length(node()), 1) = '$'">
                            <xsl:copy-of select="concat('\(', substring(node(), 2, string-length(node()) - 2), '\)')"/>
                        </xsl:when>
                        <xsl:when test="starts-with(node(), '\(') and substring(node(), string-length(node()) - 1, 2) = '\)'">
                            <xsl:copy-of select="."/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:copy-of select="concat('\(',node(),'\)')"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </span>
            </xsl:when> 
            <xsl:otherwise>
            <xsl:text>$$</xsl:text>
            <xsl:value-of select="$clean"/>
            <xsl:text>$$</xsl:text>
                <div class="formula-tex">
                    <xsl:choose>
                        <xsl:when test="starts-with(node(), '$$') and substring(node(), string-length(node()) - 1, 2) = '$$'">
                            <xsl:copy-of select="concat('\[', substring(node(), 3, string-length(node()) - 4), '\]')"/>
                        </xsl:when>
                        <xsl:when test="starts-with(node(), '\[') and substring(node(), string-length(node()) - 1, 2) = '\]'">
                            <xsl:copy-of select="."/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:copy-of select="concat('\[',node(),'\]')"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </div>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>