]> granicus.if.org Git - docbook-dsssl/commitdiff
fix issue #43 Spurious escapes caused by manpage title truncation snapshot/2018-09-28-175
authorbobstayton <bobs@sagehill.net>
Sat, 21 Jul 2018 15:52:04 +0000 (08:52 -0700)
committerbobstayton <bobs@sagehill.net>
Fri, 28 Sep 2018 21:31:53 +0000 (14:31 -0700)
xsl/manpages/other.xsl

index c87b08c1751aecae3ca8243cd87aec8dc1422235..850fa08f00a9d43a7d92e196e1160d62fc89c222 100644 (file)
     <!-- * validation does not provide a way to constrain them to be -->
     <!-- * "space free" -->
     <xsl:text>.TH "</xsl:text>
+    <xsl:variable name="title.n" select="normalize-space($title)"/>
     <xsl:call-template name="string.upper">
       <xsl:with-param name="string">
         <xsl:choose>
           <xsl:when test="$man.th.title.max.length != ''">
-            <xsl:value-of
-                select="normalize-space(substring($title, 1, $man.th.title.max.length))"/>
+            <xsl:choose>
+              <!-- if last two are double backslash, then two less -->
+              <xsl:when test="substring($title.n,$man.th.title.max.length - 1, 2) = '\\'">
+                <xsl:value-of select="substring($title.n, 1, $man.th.title.max.length - 2)"/>
+              </xsl:when>
+              <xsl:when test="substring($title.n,$man.th.title.max.length - 1, 2) = '\E'">
+                <xsl:value-of select="substring($title.n, 1, $man.th.title.max.length - 2)"/>
+              </xsl:when>
+              <xsl:when test="substring($title.n,$man.th.title.max.length - 1, 2) = '\e'">
+                <xsl:value-of select="substring($title.n, 1, $man.th.title.max.length - 2)"/>
+              </xsl:when>
+              <!-- if last character is backslash, then one less -->
+              <xsl:when test="substring($title.n,$man.th.title.max.length,1) = '\'">
+                <xsl:value-of select="substring($title.n, 1, $man.th.title.max.length - 1)"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="substring($title.n, 1, $man.th.title.max.length)"/>
+              </xsl:otherwise>
+            </xsl:choose>
           </xsl:when>
           <xsl:otherwise>
-            <xsl:value-of select="normalize-space($title)"/>
+            <xsl:value-of select="$title.n"/>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:with-param>