tags 597665 + patch
kthxbye

I've attached a patch which solves the problem by marking tabs with
spans with class "tab".

This patch is necessary because there are two contexts in which HTML can
be generated: CSS-ignoring and CSS-supporting.  In the former, tabs will
never be displayed properly.  However, the only way to create
appropriate line breaks is via the br tag, because using the white-space
CSS property won't work (since CSS is not supported).

In CSS-supporting contexts, we *can* get sane white space handling,
including for tabs, by using white-space: pre.  Unfortunately, with the
br tags, this causes two line breaks, which makes every line
double-spaced.  Since we need the br tags for the CSS-ignoring case, the
only way to handle tabs correctly involves using a span to allow styling
of the CSS.

We don't need to handle any other characters specially since white-space
handling in CSS is limited to space, tab, carriage return, and linefeed.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
diff -ur docbook-xsl-ns.old/html/html-rtf.xsl docbook-xsl-ns-1.76.0~RC1+dfsg/html/html-rtf.xsl
--- docbook-xsl-ns.old/html/html-rtf.xsl	2010-09-22 19:15:46.000000000 +0000
+++ docbook-xsl-ns-1.76.0~RC1+dfsg/html/html-rtf.xsl	2010-09-22 19:58:39.000000000 +0000
@@ -236,7 +236,7 @@
   <xsl:variable name="text" select="translate(., ' ', '&#160;')"/>
 
   <xsl:choose>
-    <xsl:when test="not(contains($text, '&#xA;'))">
+    <xsl:when test="not(contains($text, '&#xA;') or contains($text, '&#x9;'))">
       <xsl:value-of select="$text"/>
     </xsl:when>
 
@@ -245,7 +245,14 @@
 
       <xsl:choose>
         <xsl:when test="$len = 1">
-          <br/><xsl:text>&#xA;</xsl:text>
+          <xsl:choose>
+            <xsl:when test="contains($text, '&#xA;')">
+              <br/><xsl:text>&#xA;</xsl:text>
+            </xsl:when>
+            <xsl:otherwise>
+              <span class="tab"><xsl:text>&#x9;</xsl:text></span>
+            </xsl:otherwise>
+          </xsl:choose>
         </xsl:when>
 
         <xsl:otherwise>
@@ -267,7 +274,7 @@
   <xsl:param name="text" select="''"/>
 
   <xsl:choose>
-    <xsl:when test="not(contains($text, '&#xA;'))">
+    <xsl:when test="not(contains($text, '&#xA;') or contains($text, '&#x9;'))">
       <xsl:value-of select="$text"/>
     </xsl:when>
 
@@ -275,8 +282,15 @@
       <xsl:variable name="len" select="string-length($text)"/>
 
       <xsl:choose>
-        <xsl:when test="$len = 1">
-          <br/><xsl:text>&#xA;</xsl:text>
+				<xsl:when test="$len = 1">
+          <xsl:choose>
+            <xsl:when test="contains($text, '&#xA;')">
+              <br/><xsl:text>&#xA;</xsl:text>
+            </xsl:when>
+            <xsl:otherwise>
+              <span class="tab"><xsl:text>&#x9;</xsl:text></span>
+            </xsl:otherwise>
+          </xsl:choose>
         </xsl:when>
 
         <xsl:otherwise>
diff -ur docbook-xsl-ns.old/xhtml/html-rtf.xsl docbook-xsl-ns-1.76.0~RC1+dfsg/xhtml/html-rtf.xsl
--- docbook-xsl-ns.old/xhtml/html-rtf.xsl	2010-09-22 19:15:46.000000000 +0000
+++ docbook-xsl-ns-1.76.0~RC1+dfsg/xhtml/html-rtf.xsl	2010-09-22 19:54:47.000000000 +0000
@@ -222,7 +222,7 @@
   <xsl:variable name="text" select="translate(., ' ', '&#160;')"/>
 
   <xsl:choose>
-    <xsl:when test="not(contains($text, '&#10;'))">
+    <xsl:when test="not(contains($text, '&#xA;') or contains($text, '&#x9;'))">
       <xsl:value-of select="$text"/>
     </xsl:when>
 
@@ -231,8 +231,14 @@
 
       <xsl:choose>
         <xsl:when test="$len = 1">
-          <br/><xsl:text>
-</xsl:text>
+          <xsl:choose>
+            <xsl:when test="contains($text, '&#xA;')">
+              <br/><xsl:text>&#xA;</xsl:text>
+            </xsl:when>
+            <xsl:otherwise>
+              <span class="tab"><xsl:text>&#x9;</xsl:text></span>
+            </xsl:otherwise>
+          </xsl:choose>
         </xsl:when>
 
         <xsl:otherwise>
@@ -241,9 +247,10 @@
             <xsl:with-param name="text" select="substring($text, 1, $half)"/>
           </xsl:call-template>
           <xsl:call-template name="make-verbatim-recursive">
-            <xsl:with-param name="text" select="substring($text, ($half + 1), $len)"/>
+            <xsl:with-param name="text"
+                            select="substring($text, ($half + 1), $len)"/>
           </xsl:call-template>
-    	</xsl:otherwise>
+    	  </xsl:otherwise>
       </xsl:choose>
     </xsl:otherwise>
   </xsl:choose>
@@ -253,7 +260,7 @@
   <xsl:param name="text" select="''"/>
 
   <xsl:choose>
-    <xsl:when test="not(contains($text, '&#10;'))">
+    <xsl:when test="not(contains($text, '&#xA;') or contains($text, '&#x9;'))">
       <xsl:value-of select="$text"/>
     </xsl:when>
 
@@ -261,9 +268,15 @@
       <xsl:variable name="len" select="string-length($text)"/>
 
       <xsl:choose>
-        <xsl:when test="$len = 1">
-          <br/><xsl:text>
-</xsl:text>
+				<xsl:when test="$len = 1">
+          <xsl:choose>
+            <xsl:when test="contains($text, '&#xA;')">
+              <br/><xsl:text>&#xA;</xsl:text>
+            </xsl:when>
+            <xsl:otherwise>
+              <span class="tab"><xsl:text>&#x9;</xsl:text></span>
+            </xsl:otherwise>
+          </xsl:choose>
         </xsl:when>
 
         <xsl:otherwise>
@@ -272,7 +285,8 @@
     	    <xsl:with-param name="text" select="substring($text, 1, $half)"/>
     	  </xsl:call-template>
     	  <xsl:call-template name="make-verbatim-recursive">
-    	    <xsl:with-param name="text" select="substring($text, ($half + 1), $len)"/>
+    	    <xsl:with-param name="text"
+    			    select="substring($text, ($half + 1), $len)"/>
     	  </xsl:call-template>
     	</xsl:otherwise>
       </xsl:choose>
diff -ur docbook-xsl-ns.old/xhtml-1_1/html-rtf.xsl docbook-xsl-ns-1.76.0~RC1+dfsg/xhtml-1_1/html-rtf.xsl
--- docbook-xsl-ns.old/xhtml-1_1/html-rtf.xsl	2010-09-22 19:15:46.000000000 +0000
+++ docbook-xsl-ns-1.76.0~RC1+dfsg/xhtml-1_1/html-rtf.xsl	2010-09-22 19:55:34.000000000 +0000
@@ -222,7 +222,7 @@
   <xsl:variable name="text" select="translate(., ' ', '&#160;')"/>
 
   <xsl:choose>
-    <xsl:when test="not(contains($text, '&#10;'))">
+    <xsl:when test="not(contains($text, '&#xA;') or contains($text, '&#x9;'))">
       <xsl:value-of select="$text"/>
     </xsl:when>
 
@@ -231,8 +231,14 @@
 
       <xsl:choose>
         <xsl:when test="$len = 1">
-          <br/><xsl:text>
-</xsl:text>
+          <xsl:choose>
+            <xsl:when test="contains($text, '&#xA;')">
+              <br/><xsl:text>&#xA;</xsl:text>
+            </xsl:when>
+            <xsl:otherwise>
+              <span class="tab"><xsl:text>&#x9;</xsl:text></span>
+            </xsl:otherwise>
+          </xsl:choose>
         </xsl:when>
 
         <xsl:otherwise>
@@ -253,7 +260,7 @@
   <xsl:param name="text" select="''"/>
 
   <xsl:choose>
-    <xsl:when test="not(contains($text, '&#10;'))">
+    <xsl:when test="not(contains($text, '&#xA;') or contains($text, '&#x9;'))">
       <xsl:value-of select="$text"/>
     </xsl:when>
 
@@ -261,9 +268,15 @@
       <xsl:variable name="len" select="string-length($text)"/>
 
       <xsl:choose>
-        <xsl:when test="$len = 1">
-          <br/><xsl:text>
-</xsl:text>
+				<xsl:when test="$len = 1">
+          <xsl:choose>
+            <xsl:when test="contains($text, '&#xA;')">
+              <br/><xsl:text>&#xA;</xsl:text>
+            </xsl:when>
+            <xsl:otherwise>
+              <span class="tab"><xsl:text>&#x9;</xsl:text></span>
+            </xsl:otherwise>
+          </xsl:choose>
         </xsl:when>
 
         <xsl:otherwise>

Attachment: signature.asc
Description: Digital signature

Reply via email to