summaryrefslogtreecommitdiff
path: root/tangle-bootstrap.xsl
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2022-10-06 21:02:35 +0200
committerVivien Kraus <vivien@planete-kraus.eu>2022-10-06 21:15:20 +0200
commit95c3c983e87d5ee1fb02848f1315cb65a7c6fa0c (patch)
tree616e4386e8755f206da7e6c983364e6f73f5f02d /tangle-bootstrap.xsl
parentfe08dcdb9220bf5b8b42ea503637e20ddbb818eb (diff)
Use a formatter instead of trying to strip space.
Diffstat (limited to 'tangle-bootstrap.xsl')
-rw-r--r--tangle-bootstrap.xsl76
1 files changed, 8 insertions, 68 deletions
diff --git a/tangle-bootstrap.xsl b/tangle-bootstrap.xsl
index ffe19f5..baa9669 100644
--- a/tangle-bootstrap.xsl
+++ b/tangle-bootstrap.xsl
@@ -7,7 +7,8 @@
<xsl:value-of select="@mped:tangle-to"/>
<xsl:text>")
</xsl:text>
- <xsl:text>cat &gt;&gt; </xsl:text>
+ <xsl:apply-templates select="." mode="source-code-formatter"/>
+ <xsl:text> &gt; </xsl:text>
<xsl:value-of select="@mped:tangle-to"/>
<xsl:text> &lt;&lt; "_MPED_EOF"
</xsl:text>
@@ -16,75 +17,14 @@
_MPED_EOF
</xsl:text>
</xsl:template>
- <xsl:template name="mped-private-leading-empty-lines">
- <xsl:param name="indentation" select="''"/>
- <xsl:param name="text" select="."/>
- <xsl:choose>
- <xsl:when test="substring($text, 1, 1) = '&#10;'">
- <xsl:call-template name="mped-private-leading-empty-lines">
- <xsl:with-param name="indentation" select="''"/>
- <xsl:with-param name="text" select="substring($text, 2)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="( substring($text, 1, 1) = ' ' or substring($text, 1, 1) = '&#9;' or substring($text, 1, 1) = '&#13;')">
- <xsl:call-template name="mped-private-leading-empty-lines">
- <xsl:with-param name="indentation" select="concat($indentation, substring($text, 1, 1))"/>
- <xsl:with-param name="text" select="substring($text, 2)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$indentation"/>
- <xsl:value-of select="$text"/>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:template match="docbook:programlisting[@language = 'xml']" mode="source-code-formatter">
+ <xsl:text>xmllint --format -</xsl:text>
</xsl:template>
- <xsl:template name="remove-leading-empty-lines">
- <xsl:param name="text" select="."/>
- <xsl:call-template name="mped-private-leading-empty-lines">
- <xsl:with-param name="indentation" select="''"/>
- <xsl:with-param name="text" select="$text"/>
- </xsl:call-template>
+ <xsl:template match="docbook:programlisting" mode="source-code-formatter">
+ <xsl:text>cat</xsl:text>
</xsl:template>
- <xsl:template name="remove-trailing-whitespace">
- <xsl:param name="text" select="."/>
- <xsl:choose>
- <xsl:when test="$text = ''">
- <xsl:value-of select="$text"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="last" select="substring($text, string-length ($text), 1)"/>
- <xsl:variable name="before" select="substring($text, 1, string-length ($text) - 1)"/>
- <xsl:choose>
- <xsl:when test="$last = ' ' or $last = '&#9;' or $last = '&#10;' or $last = '&#13;'">
- <xsl:call-template name="remove-trailing-whitespace">
- <xsl:with-param name="text" select="$before"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$text"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="text()[position() = 1 and position() = last()]" mode="copy-source-code">
- <xsl:call-template name="remove-trailing-whitespace">
- <xsl:with-param name="text">
- <xsl:call-template name="remove-leading-empty-lines">
- <xsl:with-param name="text" select="."/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:template>
- <xsl:template match="text()[position() = 1 and position() != last()]" mode="copy-source-code">
- <xsl:call-template name="remove-leading-empty-lines">
- <xsl:with-param name="text" select="."/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template match="text()[position() &gt; 1 and position() = last()]" mode="copy-source-code">
- <xsl:call-template name="remove-trailing-whitespace">
- <xsl:with-param name="text" select="."/>
- </xsl:call-template>
+ <xsl:template match="text()" mode="copy-source-code">
+ <xsl:value-of select="."/>
</xsl:template>
<xsl:template match="text()"/>
<xsl:template match="mped:copy" mode="copy-source-code">