httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject svn commit: r1565174 - in /httpd/httpd/branches/2.4.x/docs/manual/style: common.dtd latex/html.xsl xsl/common.xsl xsl/util/pretrim.xsl xsl/util/string-reverse.xsl
Date Thu, 06 Feb 2014 11:28:55 GMT
Author: nd
Date: Thu Feb  6 11:28:55 2014
New Revision: 1565174

URL: http://svn.apache.org/r1565174
Log:
port style and dtd changes from trunk

Added:
    httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/pretrim.xsl   (with props)
    httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/string-reverse.xsl   (with props)
Modified:
    httpd/httpd/branches/2.4.x/docs/manual/style/common.dtd
    httpd/httpd/branches/2.4.x/docs/manual/style/latex/html.xsl
    httpd/httpd/branches/2.4.x/docs/manual/style/xsl/common.xsl

Modified: httpd/httpd/branches/2.4.x/docs/manual/style/common.dtd
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/style/common.dtd?rev=1565174&r1=1565173&r2=1565174&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/docs/manual/style/common.dtd (original)
+++ httpd/httpd/branches/2.4.x/docs/manual/style/common.dtd Thu Feb  6 11:28:55 2014
@@ -167,7 +167,6 @@ highlight | blockquote">
 <!ELEMENT dd %BlockOrInline;>
 
 <!ELEMENT pre %Inline;>
-<!ATTLIST pre class CDATA #IMPLIED>
 
 <!ELEMENT highlight %Inline;>
 <!ATTLIST highlight language CDATA #IMPLIED>

Modified: httpd/httpd/branches/2.4.x/docs/manual/style/latex/html.xsl
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/style/latex/html.xsl?rev=1565174&r1=1565173&r2=1565174&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/docs/manual/style/latex/html.xsl (original)
+++ httpd/httpd/branches/2.4.x/docs/manual/style/latex/html.xsl Thu Feb  6 11:28:55 2014
@@ -25,6 +25,9 @@
                   xmlns="http://www.w3.org/1999/xhtml">
 
 
+<!-- load utility snippets -->
+<xsl:include href="../xsl/util/pretrim.xsl" />
+
 <!-- ==================================================================== -->
 <!-- Ordinary HTML that must be converted to latex                        -->
 <!-- ==================================================================== -->
@@ -143,30 +146,6 @@
 <xsl:text>}</xsl:text>
 </xsl:template>
 
-<!-- O(log(n)) (stack usage!) string reverter -->
-<xsl:template name="string-reverse">
-<xsl:param name="string"/>
-<xsl:variable name="length" select="string-length($string)"/>
-
-<xsl:choose>
-<xsl:when test="$length &lt; 2">
-  <xsl:value-of select="$string"/>
-</xsl:when>
-<xsl:when test="$length = 2">
-  <xsl:value-of select="concat(substring($string, 2, 1), substring($string, 1, 1))"/>
-</xsl:when>
-<xsl:otherwise>
-  <xsl:variable name="middle" select="floor($length div 2)"/>
-
-  <xsl:call-template name="string-reverse">
-    <xsl:with-param name="string" select="substring($string, $middle + 1, $middle + 1)"/>
-  </xsl:call-template>
-  <xsl:call-template name="string-reverse">
-    <xsl:with-param name="string" select="substring($string, 1, $middle)"/>
-  </xsl:call-template>
-</xsl:otherwise>
-</xsl:choose>
-</xsl:template>
 
 <!-- Value-of used here explicitly because we don't wan't latex-escaping
 performed.  Of course, this will conflict with html where some tags are
@@ -174,15 +153,20 @@ 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))"/>
+<!-- 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-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:with-param>
 </xsl:call-template>
 
 <xsl:text>\end{verbatim}</xsl:text>&lf;

Modified: httpd/httpd/branches/2.4.x/docs/manual/style/xsl/common.xsl
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/style/xsl/common.xsl?rev=1565174&r1=1565173&r2=1565174&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/docs/manual/style/xsl/common.xsl (original)
+++ httpd/httpd/branches/2.4.x/docs/manual/style/xsl/common.xsl Thu Feb  6 11:28:55 2014
@@ -67,6 +67,7 @@
 
 <!-- load utility snippets -->
 <xsl:include href="util/modtrans.xsl" />
+<xsl:include href="util/pretrim.xsl" />
 
 <!-- make sure, we set relative anchors only, if we're actually -->
 <!-- transforming a modulefile (see <directive> template)       -->
@@ -604,13 +605,85 @@ if (typeof(prettyPrint) !== 'undefined')
 <!-- /section/section/section/section -->
 
 
+
+<!-- ==================================================================== -->
+<!-- Render trimmed pre/highlight-text                                    -->
+<!-- ==================================================================== -->
+<xsl:template name="pre">
+<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-ltrim-one">
+        <xsl:with-param name="string">
+            <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>
+</xsl:when>
+
+<!-- multiple nodes -->
+<xsl:otherwise>
+    <xsl:variable name="from">
+        <xsl:choose>
+        <xsl:when test="node()[position() = 1 and self::text()]">
+            <xsl:value-of select="2" />
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select="1" />
+        </xsl:otherwise>
+        </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="to">
+        <xsl:choose>
+        <xsl:when test="node()[position() = last() and self::text()]">
+            <xsl:value-of select="count(node()) - 1" />
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select="count(node())" />
+        </xsl:otherwise>
+        </xsl:choose>
+    </xsl:variable>
+
+    <xsl:if test="$from = 2">
+        <xsl:choose>
+        <xsl:when test="text()[contains(., '&#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]" />
+
+    <xsl:if test="$to &lt; count(node())">
+        <xsl:call-template name="pre-rtrim">
+            <xsl:with-param name="string"
+                select="node()[position() = last() and self::text()]" />
+        </xsl:call-template>
+    </xsl:if>
+</xsl:otherwise>
+</xsl:choose>
+</xsl:template>
+
+
 <!-- ==================================================================== -->
 <!-- Process source code highlighting                                     -->
 <!-- ==================================================================== -->
 <xsl:template match="highlight">
 <pre class="prettyprint lang-{@language}">
-    <!-- highlight body -->
-    <xsl:apply-templates />
+    <xsl:call-template name="pre" />
 </pre>&lf; <!-- /.highlight -->
 </xsl:template>
 <!-- /higlight -->
@@ -1203,7 +1276,7 @@ if (typeof(prettyPrint) !== 'undefined')
 <xsl:template match="dd"><dd><xsl:apply-templates select="*|@*|text()" /></dd></xsl:template>
 <xsl:template match="em"><em><xsl:apply-templates select="*|@*|text()" /></em></xsl:template>
 <xsl:template match="strong"><strong><xsl:apply-templates select="*|@*|text()"
/></strong></xsl:template>
-<xsl:template match="pre"><pre><xsl:apply-templates select="*|@*|text()" /></pre></xsl:template>
+<xsl:template match="pre"><pre><xsl:call-template name="pre" /></pre></xsl:template>
 <xsl:template match="code"><code><xsl:apply-templates select="*|@*|text()"
/></code></xsl:template>
 <xsl:template match="var"><var><xsl:apply-templates select="*|@*|text()" /></var></xsl:template>
 <xsl:template match="dfn"><dfn><xsl:apply-templates select="*|@*|text()" /></dfn></xsl:template>

Added: httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/pretrim.xsl
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/pretrim.xsl?rev=1565174&view=auto
==============================================================================
--- httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/pretrim.xsl (added)
+++ httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/pretrim.xsl Thu Feb  6 11:28:55
2014
@@ -0,0 +1,89 @@
+<?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 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" />
+
+<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>

Propchange: httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/pretrim.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/string-reverse.xsl
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/string-reverse.xsl?rev=1565174&view=auto
==============================================================================
--- httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/string-reverse.xsl (added)
+++ httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/string-reverse.xsl Thu Feb  6 11:28:55
2014
@@ -0,0 +1,49 @@
+<?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">
+
+<!-- O(log(n)) (stack usage!) string reverter -->
+<xsl:template name="string-reverse">
+<xsl:param name="string"/>
+<xsl:variable name="length" select="string-length($string)"/>
+
+<xsl:choose>
+<xsl:when test="$length &lt; 2">
+  <xsl:value-of select="$string"/>
+</xsl:when>
+<xsl:when test="$length = 2">
+  <xsl:value-of select="concat(substring($string, 2, 1), substring($string, 1, 1))"/>
+</xsl:when>
+<xsl:otherwise>
+  <xsl:variable name="middle" select="floor($length div 2)"/>
+
+  <xsl:call-template name="string-reverse">
+    <xsl:with-param name="string" select="substring($string, $middle + 1, $middle + 1)"/>
+  </xsl:call-template>
+  <xsl:call-template name="string-reverse">
+    <xsl:with-param name="string" select="substring($string, 1, $middle)"/>
+  </xsl:call-template>
+</xsl:otherwise>
+</xsl:choose>
+</xsl:template>
+<!-- /string-reverse -->
+
+</xsl:stylesheet>

Propchange: httpd/httpd/branches/2.4.x/docs/manual/style/xsl/util/string-reverse.xsl
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message