mirror of
https://github.com/brl/mutter.git
synced 2024-12-29 06:12:14 +00:00
cookbook: Strip leading and trailing space inside programlisting
It's a XSL FAQ to be able to chomp text nodes and we just have to copy and paste a XSLT 1.0 solution from: http://dpawson.co.uk/xsl/sect2/N8321.html#d11325e833 Let's then empower our cookbook customization layer to chomp text nodes, children of programlisting.
This commit is contained in:
parent
c0c9ddab65
commit
ad1f1cb741
@ -2,6 +2,85 @@
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
<xsl:include href="ref-html-style.xsl"/>
|
||||
|
||||
<!-- Strip leading and trailing space from text children of programlisting -->
|
||||
|
||||
<xsl:template match="programlisting/text()">
|
||||
<xsl:variable name="before" select="preceding-sibling::node()"/>
|
||||
<xsl:variable name="after" select="following-sibling::node()"/>
|
||||
|
||||
<xsl:variable name="conts" select="."/>
|
||||
|
||||
<xsl:variable name="contsl">
|
||||
<xsl:choose>
|
||||
<xsl:when test="count($before) = 0">
|
||||
<xsl:call-template name="remove-lf-left">
|
||||
<xsl:with-param name="astr" select="$conts"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$conts"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="contslr">
|
||||
<xsl:choose>
|
||||
<xsl:when test="count($after) = 0">
|
||||
<xsl:call-template name="remove-ws-right">
|
||||
<xsl:with-param name="astr" select="$contsl"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$contsl"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:value-of select="$contslr"/>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<!-- eats linefeeds from the left -->
|
||||
<xsl:template name="remove-lf-left">
|
||||
<xsl:param name="astr"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="starts-with($astr,'
') or
|
||||
starts-with($astr,'
')">
|
||||
<xsl:call-template name="remove-lf-left">
|
||||
<xsl:with-param name="astr" select="substring($astr, 2)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$astr"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- eats whitespace from the right -->
|
||||
<xsl:template name="remove-ws-right">
|
||||
<xsl:param name="astr"/>
|
||||
|
||||
<xsl:variable name="last-char">
|
||||
<xsl:value-of select="substring($astr, string-length($astr), 1)"/>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="($last-char = '
') or
|
||||
($last-char = '
') or
|
||||
($last-char = ' ') or
|
||||
($last-char = '	')">
|
||||
<xsl:call-template name="remove-ws-right">
|
||||
<xsl:with-param name="astr"
|
||||
select="substring($astr, 1, string-length($astr) - 1)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$astr"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="inlinemediaobject" priority="100">
|
||||
<p>
|
||||
<video controls="controls">
|
||||
|
Loading…
Reference in New Issue
Block a user