[gnome-doc-utils/mallard: 59/87] Fixing newline stripping
- From: Shaun McCance <shaunm src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-doc-utils/mallard: 59/87] Fixing newline stripping
- Date: Sun, 19 Apr 2009 12:19:18 -0400 (EDT)
commit c32da3bed14f8fe6c9dfc3131e8b53990c17d17e
Author: Shaun McCance <shaunm gnome org>
Date: Tue Dec 2 09:16:39 2008 -0600
Fixing newline stripping
---
xslt/mallard/html/mal2html-block.xsl | 6 ++--
xslt/mallard/html/util.xsl | 38 ++++-----------------------------
2 files changed, 8 insertions(+), 36 deletions(-)
diff --git a/xslt/mallard/html/mal2html-block.xsl b/xslt/mallard/html/mal2html-block.xsl
index d79c74d..34166ec 100644
--- a/xslt/mallard/html/mal2html-block.xsl
+++ b/xslt/mallard/html/mal2html-block.xsl
@@ -166,12 +166,12 @@ div.title {
<xsl:call-template name="util.strip_newlines">
<xsl:with-param name="string" select="$first"/>
<xsl:with-param name="leading" select="true()"/>
- <xsl:with-param name="trailing" select="$first = $last"/>
+ <xsl:with-param name="trailing" select="count(node()) = 1"/>
</xsl:call-template>
</xsl:if>
<xsl:apply-templates mode="mal2html.inline.mode"
- select="node()[not(. = $first or . = $last)]"/>
- <xsl:if test="$last and ($first != $last)">
+ select="node()[not(self::text() and (position() = 1 or position() = last()))]"/>
+ <xsl:if test="$last and (count(node()) != 1)">
<xsl:call-template name="util.strip_newlines">
<xsl:with-param name="string" select="$last"/>
<xsl:with-param name="leading" select="false()"/>
diff --git a/xslt/mallard/html/util.xsl b/xslt/mallard/html/util.xsl
index c71b5b7..2816d06 100644
--- a/xslt/mallard/html/util.xsl
+++ b/xslt/mallard/html/util.xsl
@@ -33,11 +33,9 @@ $string: The string to strip newlines from
$leading: Whether to strip leading newlines
$trailing: Whether to strip trailing newlines
-This template strips at most one leading and one trailing newline from ${string}.
-The newline may come in four different forms: U+000D U+000A (CR LF), U+000D (CR),
-U+000A (LF), and U+0085 (NEL). This is useful for preformatted block elements
-where leading and trailing newlines are ignored to make source formatting easier
-for authors.
+This template strips at most one leading and one trailing newline from
+${string}. This is useful for preformatted block elements where leading and
+trailing newlines are ignored to make source formatting easier for authors.
-->
<xsl:template name="util.strip_newlines">
<xsl:param name="string"/>
@@ -47,21 +45,8 @@ for authors.
<xsl:when test="$leading">
<xsl:variable name="new">
<xsl:choose>
- <!-- CR LF -->
- <xsl:when test="starts-with($string, '
')">
- <xsl:value-of select="substring-after($string, '
')"/>
- </xsl:when>
- <!-- CR -->
- <xsl:when test="starts-with($string, '
')">
- <xsl:value-of select="substring-after($string, '
')"/>
- </xsl:when>
- <!-- LF -->
<xsl:when test="starts-with($string, '
')">
- <xsl:value-of select="substring-after($string, '
')"/>
- </xsl:when>
- <!-- NEL -->
- <xsl:when test="starts-with($string, '…')">
- <xsl:value-of select="substring-after($string, '…')"/>
+ <xsl:value-of select="substring($string, 2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
@@ -83,20 +68,7 @@ for authors.
</xsl:when>
<xsl:when test="$trailing">
<xsl:choose>
- <!-- CR LF -->
- <xsl:when test="substring($string, -2) = '
'">
- <xsl:value-of select="substring($string, 1, string-length($string) - 2 )"/>
- </xsl:when>
- <!-- CR -->
- <xsl:when test="substring($string, -1) = '
'">
- <xsl:value-of select="substring($string, 1, string-length($string) - 1 )"/>
- </xsl:when>
- <!-- LF -->
- <xsl:when test="substring($string, -1) = '
'">
- <xsl:value-of select="substring($string, 1, string-length($string) - 1 )"/>
- </xsl:when>
- <!-- NEL -->
- <xsl:when test="substring($string, -1) = '…'">
+ <xsl:when test="substring($string, string-length($string)) = '
'">
<xsl:value-of select="substring($string, 1, string-length($string) - 1 )"/>
</xsl:when>
<xsl:otherwise>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]