]> granicus.if.org Git - apache/commitdiff
move the <pre> trimming code into its own module and use it both for html and
authorAndré Malo <nd@apache.org>
Wed, 5 Feb 2014 23:19:32 +0000 (23:19 +0000)
committerAndré Malo <nd@apache.org>
Wed, 5 Feb 2014 23:19:32 +0000 (23:19 +0000)
latex output

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

docs/manual/style/latex/html.xsl
docs/manual/style/xsl/common.xsl
docs/manual/style/xsl/util/pretrim.xsl [new file with mode: 0644]

index 943db8b8b2203e1a7a02e8a2841cca9b84dcc723..3436845dc0584442fe3fd865b24cbcc7515a67dc 100644 (file)
@@ -26,7 +26,7 @@
 
 
 <!-- load utility snippets -->
-<xsl:include href="../xsl/util/string-reverse.xsl" />
+<xsl:include href="../xsl/util/pretrim.xsl" />
 
 <!-- ==================================================================== -->
 <!-- Ordinary HTML that must be converted to latex                        -->
@@ -153,15 +153,14 @@ interpreted in pre -->
 <xsl:template match="pre|highlight">
 <xsl:text>\begin{verbatim}</xsl:text>
 
-<!-- string trimming: ltrim is easy, rtrim is not. so, we're sneaky and use
-ltrim only. The output is then: string-reverse(ltrim(string-reverse(ltrim(.)))) -->
-<xsl:variable name="reversed">
-<xsl:call-template name="string-reverse">
-<xsl:with-param name="string" select="substring(., string-length(substring-before(., substring(normalize-space(.), 1, 1))) + 1, string-length(.))"/>
-</xsl:call-template>
-</xsl:variable>
-<xsl:call-template name="string-reverse">
-<xsl:with-param name="string" select="substring($reversed, string-length(substring-before($reversed, substring(normalize-space($reversed), 1, 1))) + 1, string-length($reversed))"/>
+<xsl:call-template name="pre-rtrim">
+  <xsl:with-param name="string">
+    <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:text>\end{verbatim}</xsl:text>&lf;
index dc1193bcbabd7bc83e0be38a1ae648988e4d0ef5..bf66e3f7abf9172154d054dbf2e600f18b46642a 100644 (file)
@@ -67,7 +67,7 @@
 
 <!-- load utility snippets -->
 <xsl:include href="util/modtrans.xsl" />
-<xsl:include href="util/string-reverse.xsl" />
+<xsl:include href="util/pretrim.xsl" />
 
 <!-- make sure, we set relative anchors only, if we're actually -->
 <!-- transforming a modulefile (see <directive> template)       -->
@@ -605,52 +605,6 @@ if (typeof(prettyPrint) !== 'undefined') {
 <!-- /section/section/section/section -->
 
 
-<!-- strip empty lines at the beginning -->
-<xsl:template name="pre-ltrim">
-<xsl:param name="string" />
-
-<xsl:variable name="lspace">
-    <xsl:call-template name="string-reverse">
-        <xsl:with-param name="string" select="substring-before($string, substring(normalize-space($string), 1, 1))" />
-    </xsl:call-template>
-</xsl:variable>
-
-<xsl:choose>
-<xsl:when test="contains($lspace, '&#x0a;')">
-    <xsl:value-of select="substring(
-        $string,
-        1 + string-length($lspace)
-            - string-length(substring-before($lspace, '&#x0a;')),
-        string-length($string)
-    )" />
-</xsl:when>
-<xsl:otherwise>
-    <xsl:value-of select="$string" />
-</xsl:otherwise>
-</xsl:choose>
-</xsl:template>
-
-<!-- strip whitespace at the end -->
-<xsl:template name="pre-rtrim">
-<xsl:param name="string" />
-
-<xsl:variable name="rev">
-    <xsl:call-template name="string-reverse">
-        <xsl:with-param name="string" select="$string" />
-    </xsl:call-template>
-</xsl:variable>
-
-<xsl:call-template name="string-reverse">
-    <xsl:with-param name="string" select="substring(
-        $rev,
-        1 + string-length(substring-before(
-            $rev, substring(normalize-space($rev), 1, 1)
-        )),
-        string-length($rev)
-    )" />
-</xsl:call-template>
-</xsl:template>
-
 
 <!-- ==================================================================== -->
 <!-- Render trimmed pre/highlight-text                                    -->
diff --git a/docs/manual/style/xsl/util/pretrim.xsl b/docs/manual/style/xsl/util/pretrim.xsl
new file mode 100644 (file)
index 0000000..49f292e
--- /dev/null
@@ -0,0 +1,74 @@
+<?xml version="1.0"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<xsl:stylesheet version="1.0"
+              xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<!-- load utility snippets -->
+<xsl:include href="string-reverse.xsl" />
+
+
+<!-- strip empty lines at the beginning -->
+<xsl:template name="pre-ltrim">
+<xsl:param name="string" />
+
+<xsl:variable name="lspace">
+    <xsl:call-template name="string-reverse">
+        <xsl:with-param name="string" select="substring-before($string, substring(normalize-space($string), 1, 1))" />
+    </xsl:call-template>
+</xsl:variable>
+
+<xsl:choose>
+<xsl:when test="contains($lspace, '&#x0a;')">
+    <xsl:value-of select="substring(
+        $string,
+        1 + string-length($lspace)
+            - string-length(substring-before($lspace, '&#x0a;')),
+        string-length($string)
+    )" />
+</xsl:when>
+<xsl:otherwise>
+    <xsl:value-of select="$string" />
+</xsl:otherwise>
+</xsl:choose>
+</xsl:template>
+
+<!-- strip whitespace at the end -->
+<xsl:template name="pre-rtrim">
+<xsl:param name="string" />
+
+<xsl:variable name="rev">
+    <xsl:call-template name="string-reverse">
+        <xsl:with-param name="string" select="$string" />
+    </xsl:call-template>
+</xsl:variable>
+
+<xsl:call-template name="string-reverse">
+    <xsl:with-param name="string" select="substring(
+        $rev,
+        1 + string-length(substring-before(
+            $rev, substring(normalize-space($rev), 1, 1)
+        )),
+        string-length($rev)
+    )" />
+</xsl:call-template>
+</xsl:template>
+
+
+</xsl:stylesheet>