diff options
Diffstat (limited to 'tangle-bootstrap.xsl')
-rw-r--r-- | tangle-bootstrap.xsl | 76 |
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 >> </xsl:text> + <xsl:apply-templates select="." mode="source-code-formatter"/> + <xsl:text> > </xsl:text> <xsl:value-of select="@mped:tangle-to"/> <xsl:text> << "_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) = ' '"> - <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) = '	' or substring($text, 1, 1) = ' ')"> - <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 = '	' or $last = ' ' or $last = ' '"> - <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() > 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"> |