forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r106928 - /forrest/trunk/plugins/text-output/resources/stylesheets/txt/document2txt.xsl
Date Mon, 29 Nov 2004 16:44:54 GMT
Author: rick
Date: Mon Nov 29 08:44:53 2004
New Revision: 106928

URL: http://svn.apache.org/viewcvs?view=rev&rev=106928
Log:
Better handling of text wrapping in lists when the list item has only
text nodes and in-line markup without being wrapped by structural markup
such as <p>, <ol>, <ul>, <dl>.

Modified:
   forrest/trunk/plugins/text-output/resources/stylesheets/txt/document2txt.xsl

Modified: forrest/trunk/plugins/text-output/resources/stylesheets/txt/document2txt.xsl
Url: http://svn.apache.org/viewcvs/forrest/trunk/plugins/text-output/resources/stylesheets/txt/document2txt.xsl?view=diff&rev=106928&p1=forrest/trunk/plugins/text-output/resources/stylesheets/txt/document2txt.xsl&r1=106927&p2=forrest/trunk/plugins/text-output/resources/stylesheets/txt/document2txt.xsl&r2=106928
==============================================================================
--- forrest/trunk/plugins/text-output/resources/stylesheets/txt/document2txt.xsl	(original)
+++ forrest/trunk/plugins/text-output/resources/stylesheets/txt/document2txt.xsl	Mon Nov 29
08:44:53 2004
@@ -424,10 +424,33 @@
     </xsl:variable>
 
     <xsl:variable name="item">
-      <xsl:apply-templates mode="in-list">
-        <xsl:with-param name="level" select="'0'"/>
-        <xsl:with-param name="width" select="$width - string-length($marker)"/>
-      </xsl:apply-templates>
+      <!-- If we have no surrounding "p" elements in which word wrapping
+      can take place, we need to see if we can word-wrap everything
+      we have.  We can do this if we have no "p" elements and no
+      nested lists or tables. -->
+      <xsl:choose>
+        <xsl:when test="p|ol|ul|dl">
+          <xsl:apply-templates mode="in-list">
+            <xsl:with-param name="level" select="'0'"/>
+            <xsl:with-param name="width"
+                select="$width - string-length($marker)"/>
+          </xsl:apply-templates>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:variable name="tmp">
+            <xsl:apply-templates mode="in-list">
+              <xsl:with-param name="level" select="'0'"/>
+              <xsl:with-param name="width"
+                  select="$width - string-length($marker)"/>
+            </xsl:apply-templates>
+          </xsl:variable>
+          <xsl:call-template name="wrap-text">
+            <xsl:with-param name="text" select="$tmp"/>
+            <xsl:with-param name="indent" select="'0'"/>
+            <xsl:with-param name="width" select="$width"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:variable>
 
     <xsl:call-template name="emit-with-indent">
@@ -448,10 +471,33 @@
     </xsl:variable>
 
     <xsl:variable name="item">
-      <xsl:apply-templates mode="in-list">
-        <xsl:with-param name="level" select="'0'"/>
-        <xsl:with-param name="width" select="$width - string-length($marker)"/>
-      </xsl:apply-templates>
+      <!-- If we have no surrounding "p" elements in which word wrapping
+      can take place, we need to see if we can word-wrap everything
+      we have.  We can do this if we have no "p" elements and no
+      nested lists or tables. -->
+      <xsl:choose>
+        <xsl:when test="p|ol|ul|dl">
+          <xsl:apply-templates mode="in-list">
+            <xsl:with-param name="level" select="'0'"/>
+            <xsl:with-param name="width"
+                select="$width - string-length($marker)"/>
+          </xsl:apply-templates>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:variable name="tmp">
+            <xsl:apply-templates mode="in-list">
+              <xsl:with-param name="level" select="'0'"/>
+              <xsl:with-param name="width"
+                  select="$width - string-length($marker)"/>
+            </xsl:apply-templates>
+          </xsl:variable>
+          <xsl:call-template name="wrap-text">
+            <xsl:with-param name="text" select="$tmp"/>
+            <xsl:with-param name="indent" select="'0'"/>
+            <xsl:with-param name="width" select="$width"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:variable>
 
     <xsl:call-template name="emit-with-indent">
@@ -467,10 +513,31 @@
             select="$document-width - ($level * $indent-per-level)"/>
 
     <xsl:variable name="item">
-      <xsl:apply-templates mode="in-list">
-        <xsl:with-param name="level" select="'0'"/>
-        <xsl:with-param name="width" select="$width - 2"/>
-      </xsl:apply-templates>
+      <!-- If we have no surrounding "p" elements in which word wrapping
+      can take place, we need to see if we can word-wrap everything
+      we have.  We can do this if we have no "p" elements and no
+      nested lists or tables. -->
+      <xsl:choose>
+        <xsl:when test="p|ol|ul|dl">
+          <xsl:apply-templates mode="in-list">
+            <xsl:with-param name="level" select="'0'"/>
+            <xsl:with-param name="width" select="$width - 2"/>
+          </xsl:apply-templates>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:variable name="tmp">
+            <xsl:apply-templates mode="in-list">
+              <xsl:with-param name="level" select="'0'"/>
+              <xsl:with-param name="width" select="$width - 2"/>
+            </xsl:apply-templates>
+          </xsl:variable>
+          <xsl:call-template name="wrap-text">
+            <xsl:with-param name="text" select="$tmp"/>
+            <xsl:with-param name="indent" select="'0'"/>
+            <xsl:with-param name="width" select="$width"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:variable>
 
     <xsl:call-template name="emit-with-indent">
@@ -487,10 +554,31 @@
             select="$document-width - ($level * $indent-per-level)"/>
 
     <xsl:variable name="item">
-      <xsl:apply-templates mode="in-list">
-        <xsl:with-param name="level" select="'0'"/>
-        <xsl:with-param name="width" select="$width - 2"/>
-      </xsl:apply-templates>
+      <!-- If we have no surrounding "p" elements in which word wrapping
+      can take place, we need to see if we can word-wrap everything
+      we have.  We can do this if we have no "p" elements and no
+      nested lists or tables. -->
+      <xsl:choose>
+        <xsl:when test="p|ol|ul|dl">
+          <xsl:apply-templates mode="in-list">
+            <xsl:with-param name="level" select="'0'"/>
+            <xsl:with-param name="width" select="$width - 2"/>
+          </xsl:apply-templates>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:variable name="tmp">
+            <xsl:apply-templates mode="in-list">
+              <xsl:with-param name="level" select="'0'"/>
+              <xsl:with-param name="width" select="$width - 2"/>
+            </xsl:apply-templates>
+          </xsl:variable>
+          <xsl:call-template name="wrap-text">
+            <xsl:with-param name="text" select="$tmp"/>
+            <xsl:with-param name="indent" select="'0'"/>
+            <xsl:with-param name="width" select="$width"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:variable>
 
     <xsl:call-template name="emit-with-indent">
@@ -507,11 +595,33 @@
             select="$document-width - ($level * $indent-per-level)"/>
 
     <xsl:variable name="item">
-      <xsl:apply-templates mode="in-list">
-        <xsl:with-param name="level" select="'0'"/>
-        <xsl:with-param name="width" select="$width"/>
-      </xsl:apply-templates>
+      <!-- If we have no surrounding "p" elements in which word wrapping
+      can take place, we need to see if we can word-wrap everything
+      we have.  We can do this if we have no "p" elements and no
+      nested lists or tables. -->
+      <xsl:choose>
+        <xsl:when test="p|ol|ul|dl">
+          <xsl:apply-templates mode="in-list">
+            <xsl:with-param name="level" select="'0'"/>
+            <xsl:with-param name="width" select="$width - 3"/>
+          </xsl:apply-templates>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:variable name="tmp">
+            <xsl:apply-templates mode="in-list">
+              <xsl:with-param name="level" select="'0'"/>
+              <xsl:with-param name="width" select="$width - 3"/>
+            </xsl:apply-templates>
+          </xsl:variable>
+          <xsl:call-template name="wrap-text">
+            <xsl:with-param name="text" select="$tmp"/>
+            <xsl:with-param name="indent" select="'0'"/>
+            <xsl:with-param name="width" select="$width"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:variable>
+
     <xsl:call-template name="emit-with-indent">
       <xsl:with-param name="text" select="$item"/>
       <xsl:with-param name="indent" select="$level * $indent-per-level"/>
@@ -525,11 +635,33 @@
             select="$document-width - ($level * $indent-per-level)"/>
 
     <xsl:variable name="item">
-      <xsl:apply-templates mode="in-list">
-        <xsl:with-param name="level" select="'0'"/>
-        <xsl:with-param name="width" select="$width"/>
-      </xsl:apply-templates>
+      <!-- If we have no surrounding "p" elements in which word wrapping
+      can take place, we need to see if we can word-wrap everything
+      we have.  We can do this if we have no "p" elements and no
+      nested lists or tables. -->
+      <xsl:choose>
+        <xsl:when test="p|ol|ul|dl">
+          <xsl:apply-templates mode="in-list">
+            <xsl:with-param name="level" select="'0'"/>
+            <xsl:with-param name="width" select="$width - 3"/>
+          </xsl:apply-templates>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:variable name="tmp">
+            <xsl:apply-templates mode="in-list">
+              <xsl:with-param name="level" select="'0'"/>
+              <xsl:with-param name="width" select="$width - 3"/>
+            </xsl:apply-templates>
+          </xsl:variable>
+          <xsl:call-template name="wrap-text">
+            <xsl:with-param name="text" select="$tmp"/>
+            <xsl:with-param name="indent" select="'0'"/>
+            <xsl:with-param name="width" select="$width"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:variable>
+
     <xsl:call-template name="emit-with-indent">
       <xsl:with-param name="text" select="$item"/>
       <xsl:with-param name="indent" select="$level * $indent-per-level"/>

Mime
View raw message