pmml2svg-workinprogress.txt

来自「convert MATHML to SVG」· 文本 代码 · 共 466 行 · 第 1/2 页

TXT
466
字号
  <!-- ###########################################################################  munder (formatting)  ################################################################################ --><!--  <xsl:template match="math:munder" mode="formatting">    <xsl:param name="size"/>    <xsl:param name="x"/>        <xsl:param name="y"/>        <xsl:param name="baseline" select="0"/>    <xsl:variable name="child1">      <xsl:apply-templates select="math:*[1]" mode="formatting">        <xsl:with-param name="size" select="$size * $sizeMult"/>        <xsl:with-param name="x" select="$x"/>        <xsl:with-param name="y" select="$y"/>      </xsl:apply-templates>    </xsl:variable>    <xsl:variable name="child2">      <xsl:apply-templates select="math:*[2]" mode="formatting">        <xsl:with-param name="size" select="$size * $sizeMult"/>        <xsl:with-param name="x" select="$x"/>        <xsl:with-param name="y" select="$y"/>      </xsl:apply-templates>    </xsl:variable>    <xsl:variable name="numWidth">      <xsl:value-of select="$child1/*/@t:WIDTH"/>    </xsl:variable>    <xsl:variable name="denWidth">      <xsl:value-of select="$child2/*/@t:WIDTH"/>    </xsl:variable>    <xsl:variable name="numHeight">      <xsl:value-of select="$child1/*/@t:HEIGHT"/>    </xsl:variable>    <xsl:variable name="denHeight">      <xsl:value-of select="$child2/*/@t:HEIGHT"/>    </xsl:variable>    <xsl:message>numerator width / height : <xsl:value-of select="$child1/*/@t:WIDTH"/> -        <xsl:value-of select="$child1/*/@t:HEIGHT"/>    </xsl:message>    <xsl:message>denominator width / height : <xsl:value-of select="$child2/*/@t:WIDTH"/> -        <xsl:value-of select="$child2/*/@t:HEIGHT"/>    </xsl:message>    <xsl:variable name="maxWidth">      <xsl:choose>        <xsl:when test="number($numWidth) &lt; number($denWidth)">          <xsl:value-of select="$denWidth * 1.3"/>        </xsl:when>        <xsl:otherwise>          <xsl:value-of select="$numWidth * 1.3"/>        </xsl:otherwise>      </xsl:choose>    </xsl:variable>    <xsl:variable name="centering" select="($maxWidth - ($maxWidth * (10 div 13))) div 2"/>    <xsl:variable name="denX">      <xsl:choose>        <xsl:when test="number($numWidth) &gt; number($denWidth)">          <xsl:value-of select="$centering + ((number($numWidth) - number($denWidth)) div 2)"/>        </xsl:when>        <xsl:otherwise>          <xsl:value-of select="$centering"/>        </xsl:otherwise>      </xsl:choose>    </xsl:variable>    <xsl:variable name="numX">      <xsl:choose>        <xsl:when test="number($numWidth) &lt; number($denWidth)">          <xsl:value-of select="$centering + ((number($denWidth) - number($numWidth)) div 2)"/>        </xsl:when>        <xsl:otherwise>          <xsl:value-of select="$centering"/>        </xsl:otherwise>      </xsl:choose>    </xsl:variable>    <xsl:message>      <xsl:value-of select="$numWidth"/> &lt; <xsl:value-of select="$denWidth"/>    </xsl:message>    <xsl:message>maxWidth: <xsl:value-of select="$maxWidth"/>    </xsl:message>    <xsl:variable name="denY" select="$numHeight + $numHeightDen"/>    <xsl:copy>      <xsl:copy-of select="@*"/>      <xsl:attribute name="t:X">        <xsl:value-of select="$x"/>      </xsl:attribute>      <xsl:attribute name="t:Y">        <xsl:value-of select="$y"/>      </xsl:attribute>      <xsl:attribute name="t:numX">        <xsl:value-of select="$numX"/>      </xsl:attribute>      <xsl:attribute name="t:numHeight">        <xsl:value-of select="$numHeight"/>      </xsl:attribute>      <xsl:message>numHeight : <xsl:value-of select="$numHeight"/>      </xsl:message>      <xsl:attribute name="t:denX">        <xsl:value-of select="$denX"/>      </xsl:attribute>      <xsl:attribute name="t:denY">        <xsl:value-of select="$denY"/>      </xsl:attribute>      <xsl:attribute name="t:FONTSIZE">        <xsl:value-of select="$size"/>      </xsl:attribute>      <xsl:attribute name="t:WIDTH">        <xsl:value-of select="$maxWidth"/>      </xsl:attribute>      <xsl:attribute name="t:HEIGHT">        <xsl:value-of select="$numHeight + $denHeight + $numHeightDen"/>      </xsl:attribute>      <xsl:attribute name="t:BASELINE">        <xsl:value-of select="$y + $numHeight + $denHeight + $numHeightDen"/>      </xsl:attribute>      <xsl:message>        <xsl:value-of select="$numHeight + $denHeight + $numHeightDen"/>      </xsl:message>      <xsl:attribute name="t:TEXT">        <xsl:copy-of select="text()"/>      </xsl:attribute>      <xsl:copy-of select="$child1"/>      <xsl:copy-of select="$child2"/>    </xsl:copy>  </xsl:template>-->  <!-- ###########################################################################  mover(formatting)  ################################################################################ --> <!-- <xsl:template match="math:mover" mode="formatting">    <xsl:param name="size"/>    <xsl:param name="x"/>        <xsl:param name="y"/>        <xsl:param name="baseline" select="0"/>    <xsl:variable name="child1">      <xsl:apply-templates select="math:*[2]" mode="formatting">        <xsl:with-param name="size" select="$size * $sizeMult"/>        <xsl:with-param name="x" select="$x"/>        <xsl:with-param name="y" select="$y"/>      </xsl:apply-templates>    </xsl:variable>    <xsl:variable name="child2">      <xsl:apply-templates select="math:*[1]" mode="formatting">        <xsl:with-param name="size" select="$size * $sizeMult"/>        <xsl:with-param name="x" select="$x"/>        <xsl:with-param name="y" select="$y"/>      </xsl:apply-templates>    </xsl:variable>    <xsl:variable name="numWidth">      <xsl:value-of select="$child1/*/@t:WIDTH"/>    </xsl:variable>    <xsl:variable name="denWidth">      <xsl:value-of select="$child2/*/@t:WIDTH"/>    </xsl:variable>    <xsl:variable name="numHeight">      <xsl:value-of select="$child1/*/@t:HEIGHT"/>    </xsl:variable>    <xsl:variable name="denHeight">      <xsl:value-of select="$child2/*/@t:HEIGHT"/>    </xsl:variable>    <xsl:message>numerator width / height : <xsl:value-of select="$child1/*/@t:WIDTH"/> -        <xsl:value-of select="$child1/*/@t:HEIGHT"/>    </xsl:message>    <xsl:message>denominator width / height : <xsl:value-of select="$child2/*/@t:WIDTH"/> -        <xsl:value-of select="$child2/*/@t:HEIGHT"/>    </xsl:message>    <xsl:variable name="maxWidth">      <xsl:choose>        <xsl:when test="number($numWidth) &lt; number($denWidth)">          <xsl:value-of select="$denWidth * 1.3"/>        </xsl:when>        <xsl:otherwise>          <xsl:value-of select="$numWidth * 1.3"/>        </xsl:otherwise>      </xsl:choose>    </xsl:variable>    <xsl:variable name="centering" select="($maxWidth - ($maxWidth * (10 div 13))) div 2"/>    <xsl:variable name="denX">      <xsl:choose>        <xsl:when test="number($numWidth) &gt; number($denWidth)">          <xsl:value-of select="$centering + ((number($numWidth) - number($denWidth)) div 2)"/>        </xsl:when>        <xsl:otherwise>          <xsl:value-of select="$centering"/>        </xsl:otherwise>      </xsl:choose>    </xsl:variable>    <xsl:variable name="numX">      <xsl:choose>        <xsl:when test="number($numWidth) &lt; number($denWidth)">          <xsl:value-of select="$centering + ((number($denWidth) - number($numWidth)) div 2)"/>        </xsl:when>        <xsl:otherwise>          <xsl:value-of select="$centering"/>        </xsl:otherwise>      </xsl:choose>    </xsl:variable>    <xsl:message>      <xsl:value-of select="$numWidth"/> &lt; <xsl:value-of select="$denWidth"/>    </xsl:message>    <xsl:message>maxWidth: <xsl:value-of select="$maxWidth"/>    </xsl:message>    <xsl:variable name="denY" select="$numHeight + $numHeightDen"/>    <xsl:copy>      <xsl:copy-of select="@*"/>      <xsl:attribute name="t:X">        <xsl:value-of select="$x"/>      </xsl:attribute>      <xsl:attribute name="t:Y">        <xsl:value-of select="$y"/>      </xsl:attribute>      <xsl:attribute name="t:numX">        <xsl:value-of select="$numX"/>      </xsl:attribute>      <xsl:attribute name="t:numHeight">        <xsl:value-of select="$numHeight"/>      </xsl:attribute>      <xsl:message>numHeight : <xsl:value-of select="$numHeight"/>      </xsl:message>      <xsl:attribute name="t:denX">        <xsl:value-of select="$denX"/>      </xsl:attribute>      <xsl:attribute name="t:denY">        <xsl:value-of select="$denY"/>      </xsl:attribute>      <xsl:attribute name="t:FONTSIZE">        <xsl:value-of select="$size"/>      </xsl:attribute>      <xsl:attribute name="t:WIDTH">        <xsl:value-of select="$maxWidth"/>      </xsl:attribute>      <xsl:attribute name="t:HEIGHT">        <xsl:value-of select="$numHeight + $denHeight + $numHeightDen"/>      </xsl:attribute>      <xsl:message>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?