VirtualBox

Changeset 98098 in vbox


Ignore:
Timestamp:
Jan 17, 2023 12:53:30 AM (23 months ago)
Author:
vboxsync
Message:

doc/manual/docbook-refentry-to-C-help.xsl: Try improve leading/trailing whitespace normalization.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/docbook-refentry-to-C-help.xsl

    r96407 r98098  
    4848    <xsl:text>-------------------------------------------------------------------------------------------------------------------</xsl:text>
    4949  </xsl:variable>
     50  <xsl:variable name="g_sNewLine"><xsl:value-of select="'&#10;'" /></xsl:variable>
    5051
    5152  <!-- Sub-command style command (true) or single command (false). -->
     
    494495  </xsl:template>
    495496
     497  <!-- Normalizes the current text node taking tailing and leading spaces
     498       into account (unlike normalize-space which strips them mercilessly). -->
     499  <xsl:template name="my-normalize-space-current">
     500    <!-- <xsl:message>dbg0: position=<xsl:value-of select="position()"/> last=<xsl:value-of select="last()"/> .=|<xsl:value-of select="."/>|</xsl:message> -->
     501    <xsl:if test="(starts-with(.,' ') or starts-with(., $g_sNewLine)) and position() != 1">
     502      <xsl:value-of select="' '"/>
     503    </xsl:if>
     504    <xsl:value-of select="normalize-space(.)"/>
     505    <xsl:if test="((substring(.,string-length(.)) = ' ') or (substring(.,string-length(.)) = $g_sNewLine)) and position() != last()">
     506      <xsl:value-of select="' '"/>
     507    </xsl:if>
     508  </xsl:template>
    496509
    497510  <!--
     
    500513  <xsl:template match="text()" name="escape_text">
    501514    <!-- Leading whitespace hack! -->
    502     <xsl:if test="substring(.,1,1) = ' ' and position() != 1">
     515    <xsl:if test="(starts-with(.,' ') or starts-with(.,$g_sNewLine)) and position() != 1">
    503516      <xsl:text> </xsl:text>
    504517      <xsl:if test="boolean($g_fDebugText)">
    505         <xsl:message>text: add space</xsl:message>
     518        <xsl:message>text: add lead space</xsl:message>
    506519      </xsl:if>
    507520    </xsl:if>
     
    529542        <xsl:value-of select="$sTmp2"/>
    530543        <xsl:if test="boolean($g_fDebugText)">
    531           <xsl:message>text: |<xsl:value-of select="$sTmp2"/>|</xsl:message>
     544          <xsl:message>text: |<xsl:value-of select="$sTmp2"/>|(1)</xsl:message>
    532545        </xsl:if>
    533546      </xsl:when>
     
    536549        <xsl:value-of select="normalize-space(.)"/>
    537550        <xsl:if test="boolean($g_fDebugText)">
    538           <xsl:message>text: |<xsl:value-of select="normalize-space(.)"/>|</xsl:message>
     551          <xsl:message>text: |<xsl:value-of select="normalize-space(.)"/>|(2)</xsl:message>
    539552        </xsl:if>
    540553      </xsl:otherwise>
     
    542555
    543556    <!-- Trailing whitespace hack! -->
    544     <xsl:if test="substring(.,string-length(.)) = ' ' and position() != last() and string-length(.) != 1">
     557    <xsl:if test="(substring(.,string-length(.)) = ' ' or substring(.,string-length(.)) = $g_sNewLine) and position() != last() and string-length(.) != 1">
    545558      <xsl:text> </xsl:text>
    546559      <xsl:if test="boolean($g_fDebugText)">
    547         <xsl:message>text: add space</xsl:message>
     560        <xsl:message>text: add tail space</xsl:message>
    548561      </xsl:if>
    549562    </xsl:if>
     
    553566  <!-- Elements producing non-breaking strings (single line). -->
    554567  <xsl:template match="command/text()|option/text()|computeroutput/text()|arg/text()|filename/text()" name="escape_fixed_text">
    555     <xsl:param name="sText" select="normalize-space(.)"/>
     568    <xsl:param name="sText"><xsl:call-template name="my-normalize-space-current"/></xsl:param>
    556569    <xsl:choose>
    557570
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette