VirtualBox

Changeset 76235 in vbox


Ignore:
Timestamp:
Dec 14, 2018 3:57:25 PM (6 years ago)
Author:
vboxsync
Message:

docbook2latex.xsl: cure the string replacement quirk which is caused by the replacement of \ containing {}

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/docbook2latex.xsl

    r76088 r76235  
    911911  <xsl:template match="//text()">
    912912
     913    <!-- Do the translation of \ into \textbackslash{} in two steps, to avoid
     914         running into replacing {} as well which would be very wrong. -->
    913915    <xsl:variable name="subst1">
    914916      <xsl:call-template name="str:subst">
    915917        <xsl:with-param name="text" select="." />
    916918        <xsl:with-param name="replace" select="'\'" />
     919        <xsl:with-param name="with" select="'\textbackslash'" />
     920        <xsl:with-param name="disable-output-escaping" select="no" />
     921      </xsl:call-template>
     922    </xsl:variable>
     923    <xsl:variable name="subst2">
     924      <xsl:call-template name="str:subst">
     925        <xsl:with-param name="text" select="$subst1" />
     926        <xsl:with-param name="replace" select="'{'" />
     927        <xsl:with-param name="with" select="'\{'" />
     928        <xsl:with-param name="disable-output-escaping" select="no" />
     929      </xsl:call-template>
     930    </xsl:variable>
     931    <xsl:variable name="subst3">
     932      <xsl:call-template name="str:subst">
     933        <xsl:with-param name="text" select="$subst2" />
     934        <xsl:with-param name="replace" select="'}'" />
     935        <xsl:with-param name="with" select="'\}'" />
     936        <xsl:with-param name="disable-output-escaping" select="no" />
     937      </xsl:call-template>
     938    </xsl:variable>
     939    <xsl:variable name="subst4">
     940      <xsl:call-template name="str:subst">
     941        <xsl:with-param name="text" select="$subst3" />
     942        <xsl:with-param name="replace" select="'\textbackslash'" />
    917943        <xsl:with-param name="with" select="'\textbackslash{}'" />
    918944        <xsl:with-param name="disable-output-escaping" select="no" />
     
    929955                   or (name(..) = 'replaceable')    or (name(../..) = 'replaceable')
    930956                     ">
    931         <xsl:variable name="subst2">
    932           <xsl:call-template name="str:subst">
    933             <xsl:with-param name="text" select="translate(normalize-space(concat('&#x7F;',$subst1,'&#x7F;')),'&#x7F;','')" />
     957        <xsl:variable name="subst5">
     958          <xsl:call-template name="str:subst">
     959            <xsl:with-param name="text" select="translate(normalize-space(concat('&#x7f;',$subst4,'&#x7f;')),'&#x7f;','')" />
    934960            <xsl:with-param name="replace" select="'--'" />
    935961            <xsl:with-param name="with" select="'-{}-'" />
     
    937963          </xsl:call-template>
    938964        </xsl:variable>
    939         <xsl:variable name="subst3">
    940           <xsl:call-template name="str:subst">
    941             <xsl:with-param name="text" select="$subst2" />
     965        <xsl:variable name="subst6">
     966          <xsl:call-template name="str:subst">
     967            <xsl:with-param name="text" select="$subst5" />
    942968            <xsl:with-param name="replace" select="'_'" />
    943969            <xsl:with-param name="with" select="'\_'" />
     
    945971          </xsl:call-template>
    946972        </xsl:variable>
    947         <xsl:variable name="subst4">
    948           <xsl:call-template name="str:subst">
    949             <xsl:with-param name="text" select="$subst3" />
     973        <xsl:variable name="subst7">
     974          <xsl:call-template name="str:subst">
     975            <xsl:with-param name="text" select="$subst6" />
    950976            <xsl:with-param name="replace" select="'$'" />
    951977            <xsl:with-param name="with" select="'\$'" />
     
    953979          </xsl:call-template>
    954980        </xsl:variable>
    955         <xsl:variable name="subst5">
    956           <xsl:call-template name="str:subst">
    957             <xsl:with-param name="text" select="$subst4" />
     981        <xsl:variable name="subst8">
     982          <xsl:call-template name="str:subst">
     983            <xsl:with-param name="text" select="$subst7" />
    958984            <xsl:with-param name="replace" select="'%'" />
    959985            <xsl:with-param name="with" select="'\%'" />
     
    961987          </xsl:call-template>
    962988        </xsl:variable>
    963         <xsl:variable name="subst6">
    964           <xsl:call-template name="str:subst">
    965             <xsl:with-param name="text" select="$subst5" />
     989        <xsl:variable name="subst9">
     990          <xsl:call-template name="str:subst">
     991            <xsl:with-param name="text" select="$subst8" />
    966992            <xsl:with-param name="replace" select="'#'" />
    967993            <xsl:with-param name="with" select="'\#'" />
     
    969995          </xsl:call-template>
    970996        </xsl:variable>
    971         <xsl:variable name="subst7">
    972           <xsl:call-template name="str:subst">
    973             <xsl:with-param name="text" select="$subst6" />
     997        <xsl:variable name="subst10">
     998          <xsl:call-template name="str:subst">
     999            <xsl:with-param name="text" select="$subst9" />
    9741000            <xsl:with-param name="replace" select="'~'" />
    975             <xsl:with-param name="with" select="'\textasciitilde '" />
    976             <xsl:with-param name="disable-output-escaping" select="no" />
    977           </xsl:call-template>
    978         </xsl:variable>
    979         <xsl:variable name="subst8">
    980           <xsl:call-template name="str:subst">
    981             <xsl:with-param name="text" select="$subst7" />
     1001            <xsl:with-param name="with" select="'\textasciitilde{}'" />
     1002            <xsl:with-param name="disable-output-escaping" select="no" />
     1003          </xsl:call-template>
     1004        </xsl:variable>
     1005        <xsl:variable name="subst11">
     1006          <xsl:call-template name="str:subst">
     1007            <xsl:with-param name="text" select="$subst10" />
    9821008            <xsl:with-param name="replace" select="'&amp;'" />
    9831009            <xsl:with-param name="with" select="'\&amp;'" />
     
    9871013        <xsl:choose>
    9881014          <xsl:when test="parent::arg or parent::command">
    989             <xsl:variable name="subst9">
     1015            <xsl:variable name="subst12">
    9901016              <xsl:call-template name="str:subst">
    991                 <xsl:with-param name="text" select="$subst8" />
     1017                <xsl:with-param name="text" select="$subst10" />
    9921018                <xsl:with-param name="replace" select="' '" />
    9931019                <xsl:with-param name="with" select="'~'" />
     
    9951021              </xsl:call-template>
    9961022            </xsl:variable>
    997             <xsl:value-of select="$subst9" />
     1023            <xsl:value-of select="$subst12" />
    9981024          </xsl:when>
    9991025          <xsl:otherwise>
    1000             <xsl:value-of select="$subst8" />
     1026            <xsl:value-of select="$subst11" />
    10011027          </xsl:otherwise>
    10021028        </xsl:choose>
     
    10041030
    10051031      <xsl:when test="(name(..)='address') or (name(../..)='address')">
    1006         <xsl:variable name="subst2">
    1007           <xsl:call-template name="str:subst">
    1008             <xsl:with-param name="text" select="$subst1" />
     1032        <xsl:variable name="subst5">
     1033          <xsl:call-template name="str:subst">
     1034            <xsl:with-param name="text" select="$subst4" />
    10091035            <xsl:with-param name="replace" select="'&#x0a;'" />
    10101036            <xsl:with-param name="with" select="' \\'" />
     
    10121038          </xsl:call-template>
    10131039        </xsl:variable>
    1014         <xsl:value-of select="$subst2" />
     1040        <xsl:value-of select="$subst5" />
    10151041      </xsl:when>
    10161042
    10171043      <!-- <screen> and <programlisting>, which work with alltt environment. -->
    10181044      <xsl:otherwise>
    1019         <xsl:variable name="subst2">
    1020           <xsl:call-template name="str:subst">
    1021             <xsl:with-param name="text" select="$subst1" />
    1022             <xsl:with-param name="replace" select="'{'" />
    1023             <xsl:with-param name="with" select="'\{'" />
    1024             <xsl:with-param name="disable-output-escaping" select="no" />
    1025           </xsl:call-template>
    1026         </xsl:variable>
    1027         <xsl:variable name="subst3">
    1028           <xsl:call-template name="str:subst">
    1029             <xsl:with-param name="text" select="$subst2" />
    1030             <xsl:with-param name="replace" select="'}'" />
    1031             <xsl:with-param name="with" select="'\}'" />
    1032             <xsl:with-param name="disable-output-escaping" select="no" />
    1033           </xsl:call-template>
    1034         </xsl:variable>
    1035         <xsl:variable name="subst4">
    1036           <xsl:call-template name="str:subst">
    1037             <xsl:with-param name="text" select="$subst3" />
     1045        <xsl:variable name="subst5">
     1046          <xsl:call-template name="str:subst">
     1047            <xsl:with-param name="text" select="$subst4" />
    10381048            <xsl:with-param name="replace" select="'_'" />
    10391049            <xsl:with-param name="with" select="'\_'" />
     
    10411051          </xsl:call-template>
    10421052        </xsl:variable>
    1043         <xsl:variable name="subst5">
    1044           <xsl:call-template name="str:subst">
    1045             <xsl:with-param name="text" select="$subst4" />
     1053        <xsl:variable name="subst6">
     1054          <xsl:call-template name="str:subst">
     1055            <xsl:with-param name="text" select="$subst5" />
    10461056            <xsl:with-param name="replace" select="'$'" />
    10471057            <xsl:with-param name="with" select="'\$'" />
     
    10491059          </xsl:call-template>
    10501060        </xsl:variable>
    1051         <xsl:variable name="subst6">
    1052           <xsl:call-template name="str:subst">
    1053             <xsl:with-param name="text" select="$subst5" />
     1061        <xsl:variable name="subst7">
     1062          <xsl:call-template name="str:subst">
     1063            <xsl:with-param name="text" select="$subst6" />
    10541064            <xsl:with-param name="replace" select="'%'" />
    10551065            <xsl:with-param name="with" select="'\%'" />
     
    10571067          </xsl:call-template>
    10581068        </xsl:variable>
    1059         <xsl:variable name="subst7">
    1060           <xsl:call-template name="str:subst">
    1061             <xsl:with-param name="text" select="$subst6" />
     1069        <xsl:variable name="subst8">
     1070          <xsl:call-template name="str:subst">
     1071            <xsl:with-param name="text" select="$subst7" />
    10621072            <xsl:with-param name="replace" select="'#'" />
    10631073            <xsl:with-param name="with" select="'\#'" />
     
    10651075          </xsl:call-template>
    10661076        </xsl:variable>
    1067         <xsl:variable name="subst8">
    1068           <xsl:call-template name="str:subst">
    1069             <xsl:with-param name="text" select="$subst7" />
     1077        <xsl:variable name="subst9">
     1078          <xsl:call-template name="str:subst">
     1079            <xsl:with-param name="text" select="$subst8" />
    10701080            <xsl:with-param name="replace" select="'µ'" />
    10711081            <xsl:with-param name="with" select="'$\mu$'" />
     
    10731083          </xsl:call-template>
    10741084        </xsl:variable>
    1075         <xsl:variable name="subst9">
    1076           <xsl:call-template name="str:subst">
    1077             <xsl:with-param name="text" select="$subst8" />
     1085        <xsl:variable name="subst10">
     1086          <xsl:call-template name="str:subst">
     1087            <xsl:with-param name="text" select="$subst9" />
    10781088            <xsl:with-param name="replace" select="'®'" />
    10791089            <xsl:with-param name="with" select="'\texorpdfstring{\textregistered}{}'" />
     
    10861096             with pretty quotes by invoking sed a few times. Unfortunately there are
    10871097             no regular expressions in XSLT so there's no other way. -->
    1088         <xsl:variable name="subst10">
     1098        <xsl:variable name="subst11">
    10891099          <xsl:choose>
    10901100            <xsl:when test="(name(..)='screen') or (name(../..)='screen')
    10911101                         or (name(..)='programlisting') or (name(../..)='programlisting')
    10921102                           ">
    1093               <xsl:value-of select="$subst9" />
     1103              <xsl:value-of select="$subst10" />
    10941104            </xsl:when>
    10951105            <xsl:otherwise>
    10961106              <xsl:call-template name="str:subst">
    1097                 <xsl:with-param name="text" select="$subst9" />
     1107                <xsl:with-param name="text" select="$subst10" />
    10981108                <xsl:with-param name="replace" select="$quote" />
    10991109                <xsl:with-param name="with" select="'\QUOTE{}'" />
     
    11031113          </xsl:choose>
    11041114        </xsl:variable>
    1105         <xsl:variable name="subst11">
    1106           <xsl:call-template name="str:subst">
    1107             <xsl:with-param name="text" select="$subst10" />
     1115        <xsl:variable name="subst12">
     1116          <xsl:call-template name="str:subst">
     1117            <xsl:with-param name="text" select="$subst11" />
    11081118            <xsl:with-param name="replace" select="'~'" />
    1109             <xsl:with-param name="with" select="'\textasciitilde '" />
    1110             <xsl:with-param name="disable-output-escaping" select="no" />
    1111           </xsl:call-template>
    1112         </xsl:variable>
    1113         <xsl:variable name="subst12">
    1114           <xsl:call-template name="str:subst">
    1115             <xsl:with-param name="text" select="$subst11" />
     1119            <xsl:with-param name="with" select="'\textasciitilde{}'" />
     1120            <xsl:with-param name="disable-output-escaping" select="no" />
     1121          </xsl:call-template>
     1122        </xsl:variable>
     1123        <xsl:variable name="subst13">
     1124          <xsl:call-template name="str:subst">
     1125            <xsl:with-param name="text" select="$subst12" />
    11161126            <xsl:with-param name="replace" select="'&amp;'" />
    11171127            <xsl:with-param name="with" select="'\&amp;'" />
     
    11191129          </xsl:call-template>
    11201130        </xsl:variable>
    1121         <xsl:value-of select="$subst12" />
     1131        <xsl:value-of select="$subst13" />
    11221132      </xsl:otherwise>
    11231133    </xsl:choose>
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