Blame xsl/scape.xsl

Packit Service 76cb02
Packit Service 76cb02
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
Packit Service 76cb02
Packit Service 76cb02
Packit Service 76cb02
    XSLT Stylesheet DocBook -> LaTeX 
Packit Service 76cb02
    ############################################################################ -->
Packit Service 76cb02
Packit Service 76cb02
<xsl:template match="text()">
Packit Service 76cb02
  <xsl:call-template name="scape">
Packit Service 76cb02
  <xsl:with-param name="string" select="."/>
Packit Service 76cb02
  </xsl:call-template>
Packit Service 76cb02
</xsl:template>
Packit Service 76cb02
Packit Service 76cb02
<xsl:template match="text()" mode="latex.verbatim">
Packit Service 76cb02
  <xsl:value-of select="."/> 
Packit Service 76cb02
</xsl:template>
Packit Service 76cb02
Packit Service 76cb02
<xsl:template name="do.slash.hyphen">
Packit Service 76cb02
  <xsl:param name="str"/>
Packit Service 76cb02
  <xsl:choose>
Packit Service 76cb02
  <xsl:when test="contains($str,'/')">
Packit Service 76cb02
    <xsl:call-template name="scape">
Packit Service 76cb02
      <xsl:with-param name="string" select="substring-before($str,'/')"/>
Packit Service 76cb02
    </xsl:call-template>
Packit Service 76cb02
    <xsl:text>/\-</xsl:text>
Packit Service 76cb02
    <xsl:call-template name="do.slash.hyphen">
Packit Service 76cb02
      <xsl:with-param name="str" select="substring-after($str,'/')"/>
Packit Service 76cb02
    </xsl:call-template>
Packit Service 76cb02
  </xsl:when>
Packit Service 76cb02
  <xsl:otherwise>
Packit Service 76cb02
    <xsl:call-template name="scape">
Packit Service 76cb02
      <xsl:with-param name="string" select="$str"/>
Packit Service 76cb02
    </xsl:call-template>
Packit Service 76cb02
  </xsl:otherwise>
Packit Service 76cb02
  </xsl:choose>
Packit Service 76cb02
</xsl:template>
Packit Service 76cb02
Packit Service 76cb02
<xsl:template match="text()" mode="slash.hyphen">
Packit Service 76cb02
  <xsl:choose>
Packit Service 76cb02
  <xsl:when test="contains(.,'://')">
Packit Service 76cb02
    <xsl:call-template name="scape">
Packit Service 76cb02
      <xsl:with-param name="string">
Packit Service 76cb02
        <xsl:value-of select="substring-before(.,'://')"/>
Packit Service 76cb02
      </xsl:with-param>
Packit Service 76cb02
    </xsl:call-template>
Packit Service 76cb02
    <xsl:value-of select="'://'"/>
Packit Service 76cb02
    <xsl:call-template name="do.slash.hyphen">
Packit Service 76cb02
      <xsl:with-param name="str" select="substring-after(.,'://')"/>
Packit Service 76cb02
    </xsl:call-template>
Packit Service 76cb02
  </xsl:when>
Packit Service 76cb02
  <xsl:otherwise>
Packit Service 76cb02
    <xsl:call-template name="do.slash.hyphen">
Packit Service 76cb02
      <xsl:with-param name="str" select="."/>
Packit Service 76cb02
    </xsl:call-template>
Packit Service 76cb02
  </xsl:otherwise>
Packit Service 76cb02
  </xsl:choose>
Packit Service 76cb02
</xsl:template>
Packit Service 76cb02
Packit Service 76cb02
Packit Service 76cb02
Packit Service 76cb02
<xsl:template name="scape.index">
Packit Service 76cb02
  <xsl:param name="string"/>
Packit Service 76cb02
  <xsl:call-template name="scape-replace">
Packit Service 76cb02
  <xsl:with-param name="from">@</xsl:with-param>
Packit Service 76cb02
  <xsl:with-param name="to">"@</xsl:with-param>
Packit Service 76cb02
  <xsl:with-param name="string">
Packit Service 76cb02
    <xsl:call-template name="scape-replace">
Packit Service 76cb02
    <xsl:with-param name="from">!</xsl:with-param>
Packit Service 76cb02
    <xsl:with-param name="to">"!</xsl:with-param>
Packit Service 76cb02
    <xsl:with-param name="string">
Packit Service 76cb02
      <xsl:call-template name="scape-replace">
Packit Service 76cb02
      <xsl:with-param name="from">|</xsl:with-param>
Packit Service 76cb02
      <xsl:with-param name="to">\ensuremath{"|}</xsl:with-param>
Packit Service 76cb02
      <xsl:with-param name="string">
Packit Service 76cb02
        
Packit Service 76cb02
             index term, latex indexing fails.
Packit Service 76cb02
             so use a macro to avoid this side effect -->
Packit Service 76cb02
        <xsl:call-template name="scape-replace">
Packit Service 76cb02
        <xsl:with-param name="from">\tbleft </xsl:with-param>
Packit Service 76cb02
        <xsl:with-param name="to">\textbraceleft{}</xsl:with-param>
Packit Service 76cb02
        <xsl:with-param name="string">
Packit Service 76cb02
          <xsl:call-template name="scape-replace">
Packit Service 76cb02
          <xsl:with-param name="from">\tbright </xsl:with-param>
Packit Service 76cb02
          <xsl:with-param name="to">\textbraceright{}</xsl:with-param>
Packit Service 76cb02
          <xsl:with-param name="string">
Packit Service 76cb02
            
Packit Service 76cb02
            <xsl:call-template name="scape-replace">
Packit Service 76cb02
            <xsl:with-param name="from">{</xsl:with-param>
Packit Service 76cb02
            <xsl:with-param name="to">\tbleft </xsl:with-param>
Packit Service 76cb02
            <xsl:with-param name="string">
Packit Service 76cb02
              <xsl:call-template name="scape-replace">
Packit Service 76cb02
              <xsl:with-param name="from">}</xsl:with-param>
Packit Service 76cb02
              <xsl:with-param name="to">\tbright </xsl:with-param>
Packit Service 76cb02
              <xsl:with-param name="string">
Packit Service 76cb02
                <xsl:call-template name="scape-replace">
Packit Service 76cb02
                <xsl:with-param name="from">"</xsl:with-param>
Packit Service 76cb02
                <xsl:with-param name="to">""</xsl:with-param>
Packit Service 76cb02
                <xsl:with-param name="string">
Packit Service 76cb02
                   <xsl:call-template name="normalize-scape">
Packit Service 76cb02
                    <xsl:with-param name="string" select="$string"/>
Packit Service 76cb02
                  </xsl:call-template>
Packit Service 76cb02
                </xsl:with-param>
Packit Service 76cb02
                </xsl:call-template></xsl:with-param>
Packit Service 76cb02
              </xsl:call-template></xsl:with-param>
Packit Service 76cb02
            </xsl:call-template></xsl:with-param>
Packit Service 76cb02
          </xsl:call-template></xsl:with-param>
Packit Service 76cb02
        </xsl:call-template></xsl:with-param>
Packit Service 76cb02
      </xsl:call-template></xsl:with-param>
Packit Service 76cb02
    </xsl:call-template></xsl:with-param>
Packit Service 76cb02
  </xsl:call-template>
Packit Service 76cb02
</xsl:template>
Packit Service 76cb02
Packit Service 76cb02
Packit Service 76cb02
Packit Service 76cb02
     See verbatim.xsl for an overview of the verbatim environment design
Packit Service 76cb02
     that explains the need of probing.
Packit Service 76cb02
-->
Packit Service 76cb02
<xsl:template match="text()" mode="latex.programlisting">
Packit Service 76cb02
  <xsl:param name="probe" select="0"/>
Packit Service 76cb02
  <xsl:if test="$probe = 0">
Packit Service 76cb02
    <xsl:value-of select="."/> 
Packit Service 76cb02
  </xsl:if>
Packit Service 76cb02
</xsl:template>
Packit Service 76cb02
Packit Service 76cb02
<xsl:template name="normalize-scape" >
Packit Service 76cb02
  <xsl:param name="string"/>
Packit Service 76cb02
  <xsl:call-template name="scape">
Packit Service 76cb02
    <xsl:with-param name="string" select="normalize-space($string)"/>
Packit Service 76cb02
  </xsl:call-template>
Packit Service 76cb02
</xsl:template>
Packit Service 76cb02
Packit Service 76cb02
Packit Service 76cb02
Packit Service 76cb02
     before and after actual text, but keeping in-between blank lines.
Packit Service 76cb02
-->
Packit Service 76cb02
<xsl:template name="normalize-border" >
Packit Service 76cb02
  <xsl:param name="string"/>
Packit Service 76cb02
  <xsl:param name="step" select="'start'"/>
Packit Service 76cb02
  <xsl:variable name="left" select="substring-before($string,'
')"/>
Packit Service 76cb02
Packit Service 76cb02
  <xsl:choose>
Packit Service 76cb02
  <xsl:when test="not(contains($string,'
'))">
Packit Service 76cb02
    <xsl:value-of select="$string"/>
Packit Service 76cb02
  </xsl:when>
Packit Service 76cb02
  <xsl:when test="$step='start'">
Packit Service 76cb02
    <xsl:choose>
Packit Service 76cb02
    <xsl:when test="string-length(normalize-space($left))=0">
Packit Service 76cb02
      <xsl:call-template name="normalize-border">
Packit Service 76cb02
        <xsl:with-param name="string" select="substring-after($string,'
')"/>
Packit Service 76cb02
        <xsl:with-param name="step" select="$step"/>
Packit Service 76cb02
      </xsl:call-template>
Packit Service 76cb02
    </xsl:when>
Packit Service 76cb02
    <xsl:otherwise>
Packit Service 76cb02
      <xsl:value-of select="$left"/>
Packit Service 76cb02
      <xsl:text>
</xsl:text>
Packit Service 76cb02
      <xsl:call-template name="normalize-border">
Packit Service 76cb02
        <xsl:with-param name="string" select="substring-after($string,'
')"/>
Packit Service 76cb02
        <xsl:with-param name="step" select="'cont'"/>
Packit Service 76cb02
      </xsl:call-template>
Packit Service 76cb02
    </xsl:otherwise>
Packit Service 76cb02
    </xsl:choose>
Packit Service 76cb02
  </xsl:when>
Packit Service 76cb02
  <xsl:otherwise>
Packit Service 76cb02
    <xsl:value-of select="$left"/>
Packit Service 76cb02
    <xsl:text>
</xsl:text>
Packit Service 76cb02
    <xsl:variable name="right" select="substring-after($string,'
')"/>
Packit Service 76cb02
    <xsl:if test="string-length(normalize-space($right))!=0">
Packit Service 76cb02
      <xsl:call-template name="normalize-border">
Packit Service 76cb02
        <xsl:with-param name="string" select="$right"/>
Packit Service 76cb02
        <xsl:with-param name="step" select="'cont'"/>
Packit Service 76cb02
      </xsl:call-template>
Packit Service 76cb02
    </xsl:if>
Packit Service 76cb02
  </xsl:otherwise>
Packit Service 76cb02
  </xsl:choose>
Packit Service 76cb02
</xsl:template>
Packit Service 76cb02
Packit Service 76cb02
Packit Service 76cb02
Packit Service 76cb02
      replace all occurences of the character(s) `from'
Packit Service 76cb02
      by the string `to' in the string `string'.
Packit Service 76cb02
  -->
Packit Service 76cb02
<xsl:template name="string-replace" >
Packit Service 76cb02
  <xsl:param name="string"/>
Packit Service 76cb02
  <xsl:param name="from"/>
Packit Service 76cb02
  <xsl:param name="to"/>
Packit Service 76cb02
  <xsl:choose>
Packit Service 76cb02
    <xsl:when test="contains($string,$from)">
Packit Service 76cb02
      <xsl:value-of select="substring-before($string,$from)"/>
Packit Service 76cb02
      <xsl:value-of select="$to"/>
Packit Service 76cb02
      <xsl:call-template name="string-replace">
Packit Service 76cb02
        <xsl:with-param name="string" select="substring-after($string,$from)"/>
Packit Service 76cb02
        <xsl:with-param name="from" select="$from"/>
Packit Service 76cb02
        <xsl:with-param name="to" select="$to"/>
Packit Service 76cb02
      </xsl:call-template>
Packit Service 76cb02
    </xsl:when>
Packit Service 76cb02
    <xsl:otherwise>
Packit Service 76cb02
      <xsl:value-of select="$string"/>
Packit Service 76cb02
    </xsl:otherwise>
Packit Service 76cb02
  </xsl:choose>
Packit Service 76cb02
</xsl:template>
Packit Service 76cb02
Packit Service 76cb02
</xsl:stylesheet>