1 <?xml version="1.0" encoding="utf-8"?>
3 <!-- XHTML2LaTeX replace-substring utility file by Fletcher Penney
4 specifically designed for use with MultiMarkdown created XHTML
6 Extracted this routine so that it can be changed more easily by users.
8 This file is responsible for cleaning up special characters into
9 a LaTeX-friendly format.
11 Modified to support features needed for poetry.
13 MultiMarkdown Version 2.0.b5
15 $Id: clean-text-poetry.xslt 488 2008-01-14 00:46:15Z fletcher $
19 # Copyright (C) 2005-2008 Fletcher T. Penney <fletcher@fletcherpenney.net>
21 # This program is free software; you can redistribute it and/or modify
22 # it under the terms of the GNU General Public License as published by
23 # the Free Software Foundation; either version 2 of the License, or
24 # (at your option) any later version.
26 # This program is distributed in the hope that it will be useful,
27 # but WITHOUT ANY WARRANTY; without even the implied warranty of
28 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 # GNU General Public License for more details.
31 # You should have received a copy of the GNU General Public License
32 # along with this program; if not, write to the
33 # Free Software Foundation, Inc.
34 # 59 Temple Place, Suite 330
35 # Boston, MA 02111-1307 USA
40 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
41 xmlns:html="http://www.w3.org/1999/xhtml"
44 <!-- It's still built on the original -->
45 <xsl:import href="clean-text.xslt"/>
48 <!-- Find the longest line of a poem -->
49 <xsl:template name="longest-line">
50 <xsl:param name="source"/>
51 <xsl:variable name="first">
52 <xsl:value-of select="substring-before($source, $newline)"/>
54 <xsl:variable name="rest">
55 <xsl:value-of select="substring-after($source, $newline)"/>
58 <xsl:when test="contains($rest, $newline)">
59 <xsl:variable name="second">
60 <xsl:call-template name="longest-line">
61 <xsl:with-param name="source">
62 <xsl:value-of select="$rest"/>
67 <xsl:when test="string-length($first) > string-length($second)">
68 <xsl:value-of select="$first"/>
71 <xsl:value-of select="$second"/>
76 <xsl:value-of select="$rest"/>
82 <!-- This version is for blocks of poetry. In additional to the usual
83 cleanup, it changes the newlines for poetry typesetting, and replaces
84 leading spaces or tabs with \vin -->
85 <xsl:template name="poetry-text">
86 <xsl:param name="source"/>
87 <xsl:call-template name="replace-substring">
88 <xsl:with-param name="original">
89 <xsl:call-template name="replace-substring">
90 <xsl:with-param name="original">
91 <xsl:call-template name="replace-substring">
92 <xsl:with-param name="original">
93 <xsl:call-template name="clean-text-utility">
94 <xsl:with-param name="source">
95 <xsl:value-of select="$source"/>
99 <xsl:with-param name="substring">
100 <xsl:value-of select="$newline"/>
102 <xsl:with-param name="replacement">
103 <xsl:text> \\</xsl:text>
104 <xsl:value-of select="$newline"/>
108 <xsl:with-param name="substring">
109 <xsl:value-of select="$newline"/>
110 <xsl:text> \\</xsl:text>
111 <xsl:value-of select="$newline"/>
113 <xsl:with-param name="replacement">
114 <xsl:text>!</xsl:text>
115 <xsl:value-of select="$newline"/>
116 <xsl:value-of select="$newline"/>
120 <xsl:with-param name="substring">
121 <xsl:text> </xsl:text>
123 <xsl:with-param name="replacement">
124 <xsl:text>\vin </xsl:text>