You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by nd...@apache.org on 2014/02/06 00:51:08 UTC

svn commit: r1565001 - in /httpd/httpd/trunk/docs/manual/style: latex/html.xsl xsl/common.xsl xsl/util/pretrim.xsl

Author: nd
Date: Wed Feb  5 23:51:08 2014
New Revision: 1565001

URL: http://svn.apache.org/r1565001
Log:
left-trim one-liner-<pre>s oder -<highlight>s completely. The indentation is
usually an accident.

Modified:
    httpd/httpd/trunk/docs/manual/style/latex/html.xsl
    httpd/httpd/trunk/docs/manual/style/xsl/common.xsl
    httpd/httpd/trunk/docs/manual/style/xsl/util/pretrim.xsl

Modified: httpd/httpd/trunk/docs/manual/style/latex/html.xsl
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/style/latex/html.xsl?rev=1565001&r1=1565000&r2=1565001&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/style/latex/html.xsl (original)
+++ httpd/httpd/trunk/docs/manual/style/latex/html.xsl Wed Feb  5 23:51:08 2014
@@ -153,11 +153,17 @@ interpreted in pre -->
 <xsl:template match="pre|highlight">
 <xsl:text>\begin{verbatim}</xsl:text>
 
-<xsl:call-template name="pre-rtrim">
+<!-- If it's a one-liner, trim the initial indentation as well -->
+<!-- it's most likely an accident                              -->
+<xsl:call-template name="pre-ltrim-one">
   <xsl:with-param name="string">
-    <xsl:call-template name="pre-ltrim">
+    <xsl:call-template name="pre-rtrim">
       <xsl:with-param name="string">
-        <xsl:value-of select="." />
+        <xsl:call-template name="pre-ltrim">
+          <xsl:with-param name="string">
+            <xsl:value-of select="." />
+          </xsl:with-param>
+        </xsl:call-template>
       </xsl:with-param>
     </xsl:call-template>
   </xsl:with-param>

Modified: httpd/httpd/trunk/docs/manual/style/xsl/common.xsl
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/style/xsl/common.xsl?rev=1565001&r1=1565000&r2=1565001&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/style/xsl/common.xsl (original)
+++ httpd/httpd/trunk/docs/manual/style/xsl/common.xsl Wed Feb  5 23:51:08 2014
@@ -613,11 +613,15 @@ if (typeof(prettyPrint) !== 'undefined')
 <xsl:choose>
 <!-- Simple case: only one text node -->
 <xsl:when test="node()[position() = 1 and self::text()] and count(node()) = 1">
-    <xsl:call-template name="pre-rtrim">
+    <xsl:call-template name="pre-ltrim-one">
         <xsl:with-param name="string">
-            <xsl:call-template name="pre-ltrim">
-                <xsl:with-param name="string"
-                    select="node()[position() = 1 and self::text()]" />
+            <xsl:call-template name="pre-rtrim">
+                <xsl:with-param name="string">
+                    <xsl:call-template name="pre-ltrim">
+                        <xsl:with-param name="string"
+                            select="node()[position() = 1 and self::text()]" />
+                    </xsl:call-template>
+                </xsl:with-param>
             </xsl:call-template>
         </xsl:with-param>
     </xsl:call-template>
@@ -646,11 +650,23 @@ if (typeof(prettyPrint) !== 'undefined')
         </xsl:choose>
     </xsl:variable>
 
+    <xsl:variable name="out">
+        <xsl:apply-templates select="node()[position() &gt;= $from and position() &lt;= $to]" />
+    </xsl:variable>
+
     <xsl:if test="$from = 2">
-        <xsl:call-template name="pre-ltrim">
-            <xsl:with-param name="string"
-                select="node()[position() = 1 and self::text()]" />
-        </xsl:call-template>
+        <xsl:choose>
+        <xsl:when test="contains($out, '&#x0a;')">
+            <xsl:call-template name="pre-ltrim">
+                <xsl:with-param name="string"
+                    select="node()[position() = 1 and self::text()]" />
+            </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:variable name="tmp" select="node()[position() = 1 and self::text()]" />
+            <xsl:value-of select="substring($tmp, string-length(substring-before($tmp, substring(normalize-space($tmp), 1, 1))) + 1, string-length($tmp))" />
+        </xsl:otherwise>
+        </xsl:choose>
     </xsl:if>
 
     <xsl:apply-templates select="node()[position() &gt;= $from and position() &lt;= $to]" />

Modified: httpd/httpd/trunk/docs/manual/style/xsl/util/pretrim.xsl
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/style/xsl/util/pretrim.xsl?rev=1565001&r1=1565000&r2=1565001&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/style/xsl/util/pretrim.xsl (original)
+++ httpd/httpd/trunk/docs/manual/style/xsl/util/pretrim.xsl Wed Feb  5 23:51:08 2014
@@ -24,6 +24,21 @@
 <xsl:include href="string-reverse.xsl" />
 
 
+<!-- strip whitespace at the beginning if one-liner -->
+<xsl:template name="pre-ltrim-one">
+<xsl:param name="string" />
+
+<xsl:choose>
+<xsl:when test="contains($string, '&#x0a;')">
+  <xsl:value-of select="$string" />
+</xsl:when>
+<xsl:otherwise>
+    <xsl:value-of select="substring($string, string-length(substring-before($string, substring(normalize-space($string), 1, 1))) + 1, string-length($string))" />
+</xsl:otherwise>
+</xsl:choose>
+</xsl:template>
+
+
 <!-- strip empty lines at the beginning -->
 <xsl:template name="pre-ltrim">
 <xsl:param name="string" />