left-trim one-liner-<pre>s or -<highlight>s completely. The indentation is
authorAndré Malo <nd@apache.org>
Wed, 5 Feb 2014 23:51:08 +0000 (23:51 +0000)
committerAndré Malo <nd@apache.org>
Wed, 5 Feb 2014 23:51:08 +0000 (23:51 +0000)
usually an accident.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1565001 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/style/latex/html.xsl
docs/manual/style/xsl/common.xsl
docs/manual/style/xsl/util/pretrim.xsl

index 3436845dc0584442fe3fd865b24cbcc7515a67dc..e610fad6db1e625017448aeaa8dc60ff031d535d 100644 (file)
@@ -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>
index bf66e3f7abf9172154d054dbf2e600f18b46642a..d31a16c1fa0cf2a481eff376799296c15dc59a07 100644 (file)
@@ -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]" />
index 49f292efffdab8b01c8714d0d90a9d7aa5a709d3..4c8f3337339134851006b4b8d96c65320caa2f58 100644 (file)
 <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" />