]> Lady’s Gitweb - LesML/blobdiff - parser.xslt
Make LesML:split a function
[LesML] / parser.xslt
index 5164ea125b2bf4502cf582ce70970d30c4b05b3c..cf1de9841afef8acf2e844431fbf002f9a647de7 100644 (file)
@@ -13,7 +13,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
 -->
 <!DOCTYPE transform [
        <!ENTITY LesML "urn:fdc:ladys.computer:20240512:LesML">
 -->
 <!DOCTYPE transform [
        <!ENTITY LesML "urn:fdc:ladys.computer:20240512:LesML">
-       <!ENTITY section-break "">
+       <!ENTITY pilcrow-atts "(local-name()='id' or local-name()='lang') and namespace-uri()='' or local-name()='lang' and namespace-uri()='http://www.w3.org/XML/1998/namespace'">
        <!ENTITY sigiled-text "(string-length($text)=1 or substring($text, 2, 1)=' ' or substring($text, 2, 1)='¶')">
        <!ENTITY unsigiled-text "concat(translate(substring($text, 2, 1), ' ', ''), substring($text, 3, string-length($text)-2))">
        <!ENTITY xhtml "http://www.w3.org/1999/xhtml">
        <!ENTITY sigiled-text "(string-length($text)=1 or substring($text, 2, 1)=' ' or substring($text, 2, 1)='¶')">
        <!ENTITY unsigiled-text "concat(translate(substring($text, 2, 1), ' ', ''), substring($text, 3, string-length($text)-2))">
        <!ENTITY xhtml "http://www.w3.org/1999/xhtml">
@@ -23,17 +23,29 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        xmlns:LesML="urn:fdc:ladys.computer:20240512:LesML"
        xmlns:exsl="http://exslt.org/common"
        xmlns:exsldyn="http://exslt.org/dynamic"
        xmlns:LesML="urn:fdc:ladys.computer:20240512:LesML"
        xmlns:exsl="http://exslt.org/common"
        xmlns:exsldyn="http://exslt.org/dynamic"
+       xmlns:exslfunc="http://exslt.org/functions"
        xmlns:exslset="http://exslt.org/sets"
        xmlns:exslstr="http://exslt.org/strings"
        xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
        exclude-result-prefixes="LesML"
        xmlns:exslset="http://exslt.org/sets"
        xmlns:exslstr="http://exslt.org/strings"
        xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
        exclude-result-prefixes="LesML"
-       extension-element-prefixes="exsl exsldyn exslset exslstr"
+       extension-element-prefixes="exsl exsldyn exslfunc exslset exslstr"
        version="1.0"
 >
        <书社:id>urn:fdc:ladys.computer:20240512:LesML:parser.xslt</书社:id>
        <param name="LESML_SECTION_BREAK_CHARS" select="'*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~'"/>
        version="1.0"
 >
        <书社:id>urn:fdc:ladys.computer:20240512:LesML:parser.xslt</书社:id>
        <param name="LESML_SECTION_BREAK_CHARS" select="'*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~'"/>
-       <template name="LesML:split">
+       <exslfunc:function name="LesML:split">
+               <param name="source" select="string()"/>
+               <param name="separator" select="'&#xA;'"/>
+               <variable name="result-fragment">
+                       <call-template name="LesML:do-split">
+                               <with-param name="source" select="$source"/>
+                               <with-param name="separator" select="$separator"/>
+                       </call-template>
+               </variable>
+               <exslfunc:result select="exsl:node-set($result-fragment)/node()"/>
+       </exslfunc:function>
+       <template name="LesML:do-split">
                <param name="source"/>
                <param name="separator" select="'&#xA;'"/>
                <choose>
                <param name="source"/>
                <param name="separator" select="'&#xA;'"/>
                <choose>
@@ -41,7 +53,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                <html:span>
                                        <value-of select="substring-before($source, $separator)"/>
                                </html:span>
                                <html:span>
                                        <value-of select="substring-before($source, $separator)"/>
                                </html:span>
-                               <call-template name="LesML:split">
+                               <call-template name="LesML:do-split">
                                        <with-param name="source" select="substring-after($source, $separator)"/>
                                        <with-param name="separator" select="$separator"/>
                                </call-template>
                                        <with-param name="source" select="substring-after($source, $separator)"/>
                                        <with-param name="separator" select="$separator"/>
                                </call-template>
@@ -55,18 +67,11 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        </template>
        <template name="LesML:break-and-unescape">
                <param name="source"/>
        </template>
        <template name="LesML:break-and-unescape">
                <param name="source"/>
-               <variable name="broken-fragment">
-                       <call-template name="LesML:split">
-                               <with-param name="source" select="$source"/>
-                               <with-param name="separator" select="'&#xA;'"/>
-                       </call-template>
-               </variable>
-               <variable name="broken" select="exsl:node-set($broken-fragment)/node()"/>
-               <for-each select="$broken">
+               <for-each select="LesML:split($source)">
                        <call-template name="LesML:unescape">
                                <with-param name="source" select="string()"/>
                        </call-template>
                        <call-template name="LesML:unescape">
                                <with-param name="source" select="string()"/>
                        </call-template>
-                       <if test="position()!=count($broken)">
+                       <if test="position()!=last()">
                                <element name="br" namespace="&xhtml;"/>
                        </if>
                </for-each>
                                <element name="br" namespace="&xhtml;"/>
                        </if>
                </for-each>
@@ -79,16 +84,10 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                <choose>
                                        <when test="contains($after, '}')">
                                                <variable name="inner" select="substring-before($after, '}')"/>
                                <choose>
                                        <when test="contains($after, '}')">
                                                <variable name="inner" select="substring-before($after, '}')"/>
-                                               <variable name="components">
-                                                       <call-template name="LesML:split">
-                                                               <with-param name="source" select="$inner"/>
-                                                               <with-param name="separator" select="'.'"/>
-                                                       </call-template>
-                                               </variable>
-                                               <variable name="component-nodes" select="exsl:node-set($components)/node()"/>
+                                               <variable name="components" select="LesML:split($inner, '.')"/>
                                                <value-of select="substring-before($source, '{U+')"/>
                                                <choose>
                                                <value-of select="substring-before($source, '{U+')"/>
                                                <choose>
-                                                       <when test="$component-nodes[string(.)='' or translate(., '0123456789ABCDEF', '')!='']">
+                                                       <when test="$components[string(.)='' or translate(., '0123456789ABCDEF', '')!='']">
                                                                <text>{U+</text>
                                                                <value-of select="$inner"/>
                                                                <text>}</text>
                                                                <text>{U+</text>
                                                                <value-of select="$inner"/>
                                                                <text>}</text>
@@ -97,7 +96,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </call-template>
                                                        </when>
                                                        <otherwise>
                                                                </call-template>
                                                        </when>
                                                        <otherwise>
-                                                               <for-each select="$component-nodes">
+                                                               <for-each select="$components">
                                                                        <text disable-output-escaping="yes">&amp;#x</text>
                                                                        <value-of select="."/>
                                                                        <text>;</text>
                                                                        <text disable-output-escaping="yes">&amp;#x</text>
                                                                        <value-of select="."/>
                                                                        <text>;</text>
@@ -124,14 +123,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        </template>
        <template name="LesML:comment-out">
                <param name="source"/>
        </template>
        <template name="LesML:comment-out">
                <param name="source"/>
-               <variable name="comment-split-fragment">
-                       <call-template name="LesML:split">
-                               <with-param name="source" select="$source"/>
-                               <with-param name="separator" select="'--'"/>
-                       </call-template>
-               </variable>
                <comment>
                <comment>
-                       <for-each select="exsl:node-set($comment-split-fragment)/*">
+                       <for-each select="LesML:split($source, '--')">
                                <if test="string()='' or starts-with(., '‐')">
                                        <text>&#x034F;</text>
                                </if>
                                <if test="string()='' or starts-with(., '‐')">
                                        <text>&#x034F;</text>
                                </if>
@@ -174,13 +167,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                </variable>
                <variable name="maybe-langtag">
                        <if test="substring($id-and-lang, string-length($id-and-lang), 1)='$' and contains($id-and-lang, '@')">
                </variable>
                <variable name="maybe-langtag">
                        <if test="substring($id-and-lang, string-length($id-and-lang), 1)='$' and contains($id-and-lang, '@')">
-                               <variable name="split-tag-fragment">
-                                       <call-template name="LesML:split">
-                                               <with-param name="source" select="substring($id-and-lang, 2, string-length($id-and-lang)-2)"/>
-                                               <with-param name="separator" select="'@'"/>
-                                       </call-template>
-                               </variable>
-                               <value-of select="exsl:node-set($split-tag-fragment)/*[last()]"/>
+                               <value-of select="LesML:split(substring($id-and-lang, 2, string-length($id-and-lang)-2), '@')[last()]"/>
                        </if>
                </variable>
                <variable name="langtag">
                        </if>
                </variable>
                <variable name="langtag">
@@ -422,7 +409,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                        <attribute name="class">
                                                <text>body</text>
                                        </attribute>
                                        <attribute name="class">
                                                <text>body</text>
                                        </attribute>
-                                       <apply-templates select="$paragraphized/node()" mode="LesML:finalize-footnotes">
+                                       <apply-templates select="$paragraphized/node()" mode="LesML:finalize">
                                                <with-param name="used-footnotes" select="$used-footnote-nodes"/>
                                        </apply-templates>
                                </element>
                                                <with-param name="used-footnotes" select="$used-footnote-nodes"/>
                                        </apply-templates>
                                </element>
@@ -432,7 +419,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                        <text>doc-endnotes</text>
                                                </attribute>
                                                <element name="ol" namespace="&xhtml;">
                                                        <text>doc-endnotes</text>
                                                </attribute>
                                                <element name="ol" namespace="&xhtml;">
-                                                       <apply-templates select="$used-footnote-nodes" mode="LesML:finalize-footnotes">
+                                                       <apply-templates select="$used-footnote-nodes" mode="LesML:finalize">
                                                                <with-param name="used-footnotes" select="$used-footnote-nodes"/>
                                                        </apply-templates>
                                                </element>
                                                                <with-param name="used-footnotes" select="$used-footnote-nodes"/>
                                                        </apply-templates>
                                                </element>
@@ -690,13 +677,13 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </element>
                                                        </element>
                                                </when>
                                                                </element>
                                                        </element>
                                                </when>
-                                               <when test="starts-with($text, '🛈') and &sigiled-text;">
-                                                       <element name="div" namespace="&xhtml;">
+                                               <when test="starts-with($text, '') and &sigiled-text;">
+                                                       <element name="section" namespace="&xhtml;">
                                                                <attribute name="role">
                                                                        <text>note</text>
                                                                </attribute>
                                                                <attribute name="class">
                                                                <attribute name="role">
                                                                        <text>note</text>
                                                                </attribute>
                                                                <attribute name="class">
-                                                                       <text>info</text>
+                                                                       <text>note</text>
                                                                </attribute>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                </attribute>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
@@ -705,13 +692,13 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </element>
                                                        </element>
                                                </when>
                                                                </element>
                                                        </element>
                                                </when>
-                                               <when test="starts-with($text, '') and &sigiled-text;">
-                                                       <element name="div" namespace="&xhtml;">
+                                               <when test="starts-with($text, '') and &sigiled-text;">
+                                                       <element name="section" namespace="&xhtml;">
                                                                <attribute name="role">
                                                                        <text>note</text>
                                                                </attribute>
                                                                <attribute name="class">
                                                                <attribute name="role">
                                                                        <text>note</text>
                                                                </attribute>
                                                                <attribute name="class">
-                                                                       <text>query</text>
+                                                                       <text>caution</text>
                                                                </attribute>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                </attribute>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
@@ -720,13 +707,13 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </element>
                                                        </element>
                                                </when>
                                                                </element>
                                                        </element>
                                                </when>
-                                               <when test="starts-with($text, '') and &sigiled-text;">
-                                                       <element name="div" namespace="&xhtml;">
+                                               <when test="starts-with($text, '') and &sigiled-text;">
+                                                       <element name="section" namespace="&xhtml;">
                                                                <attribute name="role">
                                                                        <text>note</text>
                                                                </attribute>
                                                                <attribute name="class">
                                                                <attribute name="role">
                                                                        <text>note</text>
                                                                </attribute>
                                                                <attribute name="class">
-                                                                       <text>warn</text>
+                                                                       <text>query</text>
                                                                </attribute>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                </attribute>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
@@ -735,13 +722,10 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </element>
                                                        </element>
                                                </when>
                                                                </element>
                                                        </element>
                                                </when>
-                                               <when test="starts-with($text, '') and &sigiled-text;">
-                                                       <element name="div" namespace="&xhtml;">
+                                               <when test="starts-with($text, '@') and &sigiled-text;">
+                                                       <element name="section" namespace="&xhtml;">
                                                                <attribute name="role">
                                                                <attribute name="role">
-                                                                       <text>note</text>
-                                                               </attribute>
-                                                               <attribute name="class">
-                                                                       <text>note</text>
+                                                                       <text>doc-abstract</text>
                                                                </attribute>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                </attribute>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
@@ -750,13 +734,22 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </element>
                                                        </element>
                                                </when>
                                                                </element>
                                                        </element>
                                                </when>
-                                               <when test="starts-with($text, '') and &sigiled-text;">
-                                                       <element name="div" namespace="&xhtml;">
+                                               <when test="starts-with($text, '🛈') and &sigiled-text;">
+                                                       <element name="section" namespace="&xhtml;">
                                                                <attribute name="role">
                                                                <attribute name="role">
-                                                                       <text>note</text>
+                                                                       <text>doc-tip</text>
                                                                </attribute>
                                                                </attribute>
-                                                               <attribute name="class">
-                                                                       <text>caution</text>
+                                                               <element name="p" namespace="&xhtml;">
+                                                                       <call-template name="LesML:id-and-contents">
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
+                                                                       </call-template>
+                                                               </element>
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '⚠') and &sigiled-text;">
+                                                       <element name="section" namespace="&xhtml;">
+                                                               <attribute name="role">
+                                                                       <text>doc-notice</text>
                                                                </attribute>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                </attribute>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
@@ -825,37 +818,23 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                <apply-templates select="exsl:node-set($inlined-fragment)/node()" mode="LesML:finalize-tree"/>
        </template>
        <template match="html:script[@type='text/lesml']">
                <apply-templates select="exsl:node-set($inlined-fragment)/node()" mode="LesML:finalize-tree"/>
        </template>
        <template match="html:script[@type='text/lesml']">
-               <variable name="lines-fragment">
-                       <call-template name="LesML:split">
-                               <with-param name="source">
-                                       <for-each select=".//text()">
-                                               <value-of select="."/>
-                                       </for-each>
-                               </with-param>
-                       </call-template>
+               <variable name="source">
+                       <for-each select=".//text()">
+                               <value-of select="."/>
+                       </for-each>
                </variable>
                <element name="div" namespace="&xhtml;">
                        <call-template name="LesML:parse">
                </variable>
                <element name="div" namespace="&xhtml;">
                        <call-template name="LesML:parse">
-                               <with-param name="lines" select="exsl:node-set($lines-fragment)/*"/>
+                               <with-param name="lines" select="LesML:split($source)"/>
                        </call-template>
                </element>
        </template>
                        </call-template>
                </element>
        </template>
-       <template match="node()" mode="LesML:finalize-attributes">
-               <variable name="notattr" select="following-sibling::node()[not(self::text() and translate(., ' &#x9;', '')='' or self::LesML:attribute)]"/>
-               <for-each select="(.|exslset:leading(following-sibling::node(), $notattr)[self::LesML:attribute])/@*">
-                       <copy-of select="."/>
-                       <if test="local-name()='lang' and namespace-uri()=''">
-                               <attribute name="xml:lang">
-                                       <value-of select="."/>
-                               </attribute>
-                       </if>
-               </for-each>
-       </template>
-       <template match="html:a[@role='doc-noteref']" mode="LesML:finalize-footnotes">
+       <template match="html:ol[processing-instruction()[local-name()='LesML-Footnote']]|processing-instruction()[local-name()='LesML-Footnote']" mode="LesML:finalize" priority="1"/>
+       <template match="html:a[@role='doc-noteref']" mode="LesML:finalize">
                <param name="used-footnotes" select="/.."/>
                <variable name="matching-note" select="$used-footnotes[concat('#', @id)=current()/@href]"/>
                <copy>
                <param name="used-footnotes" select="/.."/>
                <variable name="matching-note" select="$used-footnotes[concat('#', @id)=current()/@href]"/>
                <copy>
-                       <apply-templates select="@*" mode="LesML:finalize-footnotes">
+                       <apply-templates select="@*" mode="LesML:finalize">
                                <with-param name="used-footnotes" select="$used-footnotes"/>
                        </apply-templates>
                        <choose>
                                <with-param name="used-footnotes" select="$used-footnotes"/>
                        </apply-templates>
                        <choose>
@@ -863,30 +842,74 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                        <value-of select="$matching-note/@value"/>
                                </when>
                                <otherwise>
                                        <value-of select="$matching-note/@value"/>
                                </when>
                                <otherwise>
-                                       <apply-templates select="node()" mode="LesML:finalize-footnotes">
+                                       <apply-templates select="node()" mode="LesML:finalize">
                                                <with-param name="used-footnotes" select="$used-footnotes"/>
                                        </apply-templates>
                                </otherwise>
                        </choose>
                </copy>
        </template>
                                                <with-param name="used-footnotes" select="$used-footnotes"/>
                                        </apply-templates>
                                </otherwise>
                        </choose>
                </copy>
        </template>
-       <template match="html:p[preceding-sibling::*[1]=processing-instruction()[local-name()='LesML-Footnote']]" mode="LesML:finalize-footnotes">
-               <variable name="content" select="@*[not(local-name()='@id' and namespace-uri()='')]|node()"/>
+       <template match="html:p[position()=1 and ancestor::*]" mode="LesML:finalize">
+               <param name="used-footnotes" select="/.."/>
+               <variable name="content" select="@*[not(&pilcrow-atts;)]|node()"/>
                <if test="$content">
                        <copy>
                <if test="$content">
                        <copy>
-                               <apply-templates select="$content" mode="LesML:finalize-footnotes"/>
+                               <apply-templates select="$content" mode="LesML:finalize">
+                                       <with-param name="used-footnotes" select="$used-footnotes"/>
+                               </apply-templates>
+                       </copy>
+               </if>
+       </template>
+       <template match="html:section" mode="LesML:finalize">
+               <param name="used-footnotes" select="/.."/>
+               <variable name="notinsection" select="following-sibling::node()[not(html:li/@aria-level>1)][1]"/>
+               <copy>
+                       <apply-templates select="@*|html:p[1]/@*[&pilcrow-atts;]" mode="LesML:finalize"/>
+                       <apply-templates select="node()" mode="LesML:finalize"/>
+                       <for-each select="exslset:leading(following-sibling::node(), $notinsection)">
+                               <copy>
+                                       <apply-templates select="@*|node()" mode="LesML:finalize">
+                                               <with-param name="used-footnotes" select="$used-footnotes"/>
+                                       </apply-templates>
+                               </copy>
+                       </for-each>
+               </copy>
+       </template>
+       <template match="html:*[html:li/@aria-level>1]" mode="LesML:finalize">
+               <param name="used-footnotes" select="/.."/>
+               <if test="not(preceding-sibling::node()[not(html:li/@aria-level>1)][1]/self::html:section)">
+                       <copy>
+                               <apply-templates select="@*|node()" mode="LesML:finalize">
+                                       <with-param name="used-footnotes" select="$used-footnotes"/>
+                               </apply-templates>
                        </copy>
                </if>
        </template>
                        </copy>
                </if>
        </template>
-       <template match="html:ol[processing-instruction()[local-name()='LesML-Footnote']]|processing-instruction()[local-name()='LesML-Footnote']" mode="LesML:finalize-footnotes"/>
-       <template match="@*|node()" mode="LesML:finalize-footnotes" priority="-1">
+       <template match="text()" mode="LesML:finalize">
+               <call-template name="LesML:break-and-unescape">
+                       <with-param name="source" select="string()"/>
+               </call-template>
+       </template>
+       <template match="@*|node()" mode="LesML:finalize" priority="-1">
                <param name="used-footnotes" select="/.."/>
                <copy>
                <param name="used-footnotes" select="/.."/>
                <copy>
-                       <apply-templates select="@*|node()" mode="LesML:finalize-footnotes">
+                       <apply-templates select="@*|html:p[1]/@*[&pilcrow-atts;]" mode="LesML:finalize"/>
+                       <apply-templates select="node()" mode="LesML:finalize">
                                <with-param name="used-footnotes" select="$used-footnotes"/>
                        </apply-templates>
                </copy>
        </template>
                                <with-param name="used-footnotes" select="$used-footnotes"/>
                        </apply-templates>
                </copy>
        </template>
+       <template match="node()" mode="LesML:finalize-attributes">
+               <variable name="notattr" select="following-sibling::node()[not(self::text() and translate(., ' &#x9;', '')='' or self::LesML:attribute)]"/>
+               <for-each select="(.|exslset:leading(following-sibling::node(), $notattr)[self::LesML:attribute])/@*">
+                       <copy-of select="."/>
+                       <if test="local-name()='lang' and namespace-uri()=''">
+                               <attribute name="xml:lang">
+                                       <value-of select="."/>
+                               </attribute>
+                       </if>
+               </for-each>
+       </template>
        <template match="html:li" mode="LesML:finalize-list">
                <param name="parent-level" select="0"/>
                <variable name="current-class" select="string(@class)"/>
        <template match="html:li" mode="LesML:finalize-list">
                <param name="parent-level" select="0"/>
                <variable name="current-class" select="string(@class)"/>
@@ -932,14 +955,12 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                <element name="span" namespace="&xhtml;">
                        <apply-templates select="." mode="LesML:finalize-attributes"/>
                        <if test="self::text()">
                <element name="span" namespace="&xhtml;">
                        <apply-templates select="." mode="LesML:finalize-attributes"/>
                        <if test="self::text()">
-                               <call-template name="LesML:break-and-unescape">
-                                       <with-param name="source" select="string(.)"/>
-                               </call-template>
+                               <copy/>
                        </if>
                </element>
        </template>
        <template match="html:div" mode="LesML:finalize-tree">
                        </if>
                </element>
        </template>
        <template match="html:div" mode="LesML:finalize-tree">
-               <if test="not(processing-instruction()[local-name()='LesML-Continuation']) or not(preceding-sibling::node()[position()=1 and self::html:* and contains(' div li h1 h2 h3 h4 h5 h6 ', local-name())])">
+               <if test="not(processing-instruction()[local-name()='LesML-Continuation']) or not(preceding-sibling::node()[position()=1 and self::html:* and contains(' div h1 h2 h3 h4 h5 h6 li section ', local-name())])">
                        <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
                        <choose>
                                <when test="processing-instruction()[local-name()='LesML-Continuation'] and $notcontinuation[self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
                        <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
                        <choose>
                                <when test="processing-instruction()[local-name()='LesML-Continuation'] and $notcontinuation[self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
@@ -1004,15 +1025,19 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        <apply-templates select="." mode="LesML:finalize-list"/>
                </if>
        </template>
                        <apply-templates select="." mode="LesML:finalize-list"/>
                </if>
        </template>
+       <template match="html:section" mode="LesML:finalize-tree">
+               <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
+               <copy>
+                       <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+                       <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
+                               <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                       </for-each>
+               </copy>
+       </template>
        <template match="processing-instruction()[local-name()='LesML-Continuation']" mode="LesML:finalize-tree"/>
        <template match="processing-instruction()[local-name()='LesML-Token-Escape']" mode="LesML:finalize-tree">
                <value-of select="."/>
        </template>
        <template match="processing-instruction()[local-name()='LesML-Continuation']" mode="LesML:finalize-tree"/>
        <template match="processing-instruction()[local-name()='LesML-Token-Escape']" mode="LesML:finalize-tree">
                <value-of select="."/>
        </template>
-       <template match="text()" mode="LesML:finalize-tree">
-               <call-template name="LesML:break-and-unescape">
-                       <with-param name="source" select="string(.)"/>
-               </call-template>
-       </template>
        <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
                <copy>
                        <apply-templates select="." mode="LesML:finalize-attributes"/>
        <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
                <copy>
                        <apply-templates select="." mode="LesML:finalize-attributes"/>
@@ -1037,13 +1062,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                        <value-of select="substring-before($end-node, $end-sigil)"/>
                                                </variable>
                                                <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., $start-sigil)][last()]"/>
                                                        <value-of select="substring-before($end-node, $end-sigil)"/>
                                                </variable>
                                                <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., $start-sigil)][last()]"/>
-                                               <variable name="start-tokens-fragment">
-                                                       <call-template name="LesML:split">
-                                                               <with-param name="source" select="string($start-node)"/>
-                                                               <with-param name="separator" select="$start-sigil"/>
-                                                       </call-template>
-                                               </variable>
-                                               <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
+                                               <variable name="start-tokens" select="LesML:split($start-node, $start-sigil)"/>
                                                <variable name="wrapped">
                                                        <copy>
                                                                <copy-of select="@*"/>
                                                <variable name="wrapped">
                                                        <copy>
                                                                <copy-of select="@*"/>
@@ -1114,15 +1133,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                </variable>
                                <variable name="preceding" select="exsl:node-set($preceding-fragment)/node()"/>
                                <variable name="start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()][not($ncname-keys) or not(following-sibling::* or following-sibling::comment())]"/>
                                </variable>
                                <variable name="preceding" select="exsl:node-set($preceding-fragment)/node()"/>
                                <variable name="start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()][not($ncname-keys) or not(following-sibling::* or following-sibling::comment())]"/>
-                               <variable name="start-tokens-fragment">
-                                       <if test="$start-node">
-                                               <call-template name="LesML:split">
-                                                       <with-param name="source" select="string($start-node)"/>
-                                                       <with-param name="separator" select="$start-sigil"/>
-                                               </call-template>
-                                       </if>
-                               </variable>
-                               <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
+                               <variable name="start-tokens" select="LesML:split($start-node, $start-sigil)"/>
                                <variable name="innards-fragment">
                                        <value-of select="$start-tokens[last()]"/>
                                        <copy-of select="$start-node/following-sibling::node()"/>
                                <variable name="innards-fragment">
                                        <value-of select="$start-tokens[last()]"/>
                                        <copy-of select="$start-node/following-sibling::node()"/>
@@ -1132,15 +1143,9 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                <choose>
                                        <when test="not($start-node) or $separator-node[following-sibling::* or following-sibling::comment()]">
                                                <variable name="bad-start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()]"/>
                                <choose>
                                        <when test="not($start-node) or $separator-node[following-sibling::* or following-sibling::comment()]">
                                                <variable name="bad-start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()]"/>
-                                               <variable name="bad-start-tokens-fragment">
-                                                       <call-template name="LesML:split">
-                                                               <with-param name="source" select="string($bad-start-node)"/>
-                                                               <with-param name="separator" select="$start-sigil"/>
-                                                       </call-template>
-                                               </variable>
                                                <element name="span" namespace="&xhtml;">
                                                        <copy-of select="$bad-start-node/preceding-sibling::node()"/>
                                                <element name="span" namespace="&xhtml;">
                                                        <copy-of select="$bad-start-node/preceding-sibling::node()"/>
-                                                       <for-each select="exsl:node-set($bad-start-tokens-fragment)/*">
+                                                       <for-each select="LesML:split($bad-start-node, $start-sigil)">
                                                                <value-of select="."/>
                                                                <if test="position()!=last()">
                                                                        <processing-instruction name="LesML-Token-Escape">
                                                                <value-of select="."/>
                                                                <if test="position()!=last()">
                                                                        <processing-instruction name="LesML-Token-Escape">
@@ -1155,13 +1160,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                </element>
                                        </when>
                                        <when test="$separator-node">
                                                </element>
                                        </when>
                                        <when test="$separator-node">
-                                               <variable name="keyval-fragment">
-                                                       <call-template name="LesML:split">
-                                                               <with-param name="source" select="$separator-node"/>
-                                                               <with-param name="separator" select="$separator"/>
-                                                       </call-template>
-                                               </variable>
-                                               <variable name="keyval" select="exsl:node-set($keyval-fragment)/*"/>
+                                               <variable name="keyval" select="LesML:split($separator-node, $separator)"/>
                                                <variable name="key-fragment">
                                                        <choose>
                                                                <when test="$ncname-keys">
                                                <variable name="key-fragment">
                                                        <choose>
                                                                <when test="$ncname-keys">
@@ -1356,13 +1355,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                        </choose>
                                </when>
                                <when test="self::text()[contains(., '⌧')]">
                                        </choose>
                                </when>
                                <when test="self::text()[contains(., '⌧')]">
-                                       <variable name="split-fragment">
-                                               <call-template name="LesML:split">
-                                                       <with-param name="source" select="string()"/>
-                                                       <with-param name="separator" select="'⌧'"/>
-                                               </call-template>
-                                       </variable>
-                                       <for-each select="exsl:node-set($split-fragment)/node()">
+                                       <for-each select="LesML:split(., '⌧')">
                                                <value-of select="."/>
                                                <if test="position()!=last()">
                                                        <call-template name="LesML:comment-out"/>
                                                <value-of select="."/>
                                                <if test="position()!=last()">
                                                        <call-template name="LesML:comment-out"/>
This page took 0.429391 seconds and 4 git commands to generate.