]> Lady’s Gitweb - LesML/blobdiff - parser.xslt
Don’t use literal result elements
[LesML] / parser.xslt
index 86c28ea1a31bade3aeefb20e4cd3c9779c3e1dba..bd510b08e59f37079807f62ea265b64150a2e487 100644 (file)
@@ -12,7 +12,9 @@ This Source Code Form is subject to the terms of the Mozilla Public License, v 2
 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 -->
 <!DOCTYPE transform [
 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 -->
 <!DOCTYPE transform [
-       <!ENTITY section-break '#*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~'>
+       <!ENTITY section-break "*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~">
+       <!ENTITY sigiled-text "(string-length($text)=1 or substring($text, 2, 1)=' ')">
+       <!ENTITY unsigiled-text "substring($text, 3, string-length($text)-2)">
 ]>
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
 ]>
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
@@ -46,6 +48,24 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        </otherwise>
                </choose>
        </template>
                        </otherwise>
                </choose>
        </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">
+                       <call-template name="LesML:unescape">
+                               <with-param name="source" select="string()"/>
+                       </call-template>
+                       <if test="position()!=count($broken)">
+                               <element name="html:br"/>
+                       </if>
+               </for-each>
+       </template>
        <template name="LesML:unescape">
                <param name="source"/>
                <choose>
        <template name="LesML:unescape">
                <param name="source"/>
                <choose>
@@ -103,9 +123,12 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        <when test="starts-with($source, '¶')">
                                <choose>
                                        <when test="contains($source, ' ')">
                        <when test="starts-with($source, '¶')">
                                <choose>
                                        <when test="contains($source, ' ')">
-                                               <attribute name="id">
-                                                       <value-of select="substring-before(substring-after($source, '¶'), ' ')"/>
-                                               </attribute>
+                                               <variable name="id" select="substring-before(substring-after($source, '¶'), ' ')"/>
+                                               <if test="$id!=''">
+                                                       <attribute name="id">
+                                                               <value-of select="$id"/>
+                                                       </attribute>
+                                               </if>
                                                <value-of select="substring-after($source, ' ')"/>
                                        </when>
                                        <otherwise>
                                                <value-of select="substring-after($source, ' ')"/>
                                        </when>
                                        <otherwise>
@@ -121,24 +144,14 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                </choose>
        </template>
        <template name="LesML:parse">
                </choose>
        </template>
        <template name="LesML:parse">
-               <param name="source"/>
+               <param name="lines" select="/.."/>
                <param name="parent-params" select="/.."/>
                <param name="parent-params" select="/.."/>
+               <variable name="first-line" select="$lines[1]"/>
                <variable name="shebang">
                <variable name="shebang">
-                       <if test="starts-with($source, '#!lesml')">
-                               <value-of select="substring-before($source, '&#xA;')"/>
+                       <if test="starts-with($first-line, '#!lesml')">
+                               <value-of select="$first-line"/>
                        </if>
                </variable>
                        </if>
                </variable>
-               <variable name="noshebang">
-                       <text>&#xA;</text>
-                       <choose>
-                               <when test="starts-with($source, '#!')">
-                                       <value-of select="substring-after($source, '&#xA;')"/>
-                               </when>
-                               <otherwise>
-                                       <value-of select="$source"/>
-                               </otherwise>
-                       </choose>
-               </variable>
                <variable name="params-string">
                        <choose>
                                <when test="starts-with($shebang, '#!lesml@')">
                <variable name="params-string">
                        <choose>
                                <when test="starts-with($shebang, '#!lesml@')">
@@ -150,324 +163,457 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        </choose>
                </variable>
                <variable name="params-fragment">
                        </choose>
                </variable>
                <variable name="params-fragment">
-                       <html:dl>
-                               <if test="starts-with($shebang, '#!lesml@') and contains($shebang, '$')">
-                                       <html:div>
-                                               <html:dt>
-                                                       <text> LANG </text>
-                                               </html:dt>
-                                               <html:dd>
-                                                       <value-of select="substring-before(substring-after($shebang, '#!lesml@'), '$')"/>
-                                               </html:dd>
-                                       </html:div>
-                               </if>
-                               <for-each select="exslstr:tokenize($params-string)">
-                                       <choose>
-                                               <when test="contains(., '=')">
+                       <choose>
+                               <when test="$shebang!=''">
+                                       <html:dl>
+                                               <if test="starts-with($shebang, '#!lesml@') and contains($shebang, '$')">
                                                        <html:div>
                                                                <html:dt>
                                                        <html:div>
                                                                <html:dt>
-                                                                       <value-of select="substring-before(., '=')"/>
+                                                                       <text> LANG </text>
                                                                </html:dt>
                                                                <html:dd>
                                                                </html:dt>
                                                                <html:dd>
-                                                                       <value-of select="substring-after(., '=')"/>
+                                                                       <value-of select="substring-before(substring-after($shebang, '#!lesml@'), '$')"/>
                                                                </html:dd>
                                                        </html:div>
                                                                </html:dd>
                                                        </html:div>
-                                               </when>
-                                               <otherwise>
-                                                       <html:div>
-                                                               <html:dt>
-                                                                       <value-of select="."/>
-                                                               </html:dt>
-                                                               <html:dd/>
-                                                       </html:div>
-                                               </otherwise>
-                                       </choose>
-                               </for-each>
-                       </html:dl>
+                                               </if>
+                                               <for-each select="exslstr:tokenize($params-string)">
+                                                       <choose>
+                                                               <when test="contains(., '=')">
+                                                                       <html:div>
+                                                                               <html:dt>
+                                                                                       <value-of select="substring-before(., '=')"/>
+                                                                               </html:dt>
+                                                                               <html:dd>
+                                                                                       <value-of select="substring-after(., '=')"/>
+                                                                               </html:dd>
+                                                                       </html:div>
+                                                               </when>
+                                                               <otherwise>
+                                                                       <html:div>
+                                                                               <html:dt>
+                                                                                       <value-of select="."/>
+                                                                               </html:dt>
+                                                                               <html:dd/>
+                                                                       </html:div>
+                                                               </otherwise>
+                                                       </choose>
+                                               </for-each>
+                                       </html:dl>
+                               </when>
+                               <when test="$parent-params">
+                                       <copy-of select="$parent-params"/>
+                               </when>
+                               <otherwise>
+                                       <html:dl/>
+                               </otherwise>
+                       </choose>
                </variable>
                <variable name="params" select="exsl:node-set($params-fragment)/*"/>
                </variable>
                <variable name="params" select="exsl:node-set($params-fragment)/*"/>
-               <variable name="records">
-                       <call-template name="LesML:split">
-                               <with-param name="source" select="$noshebang"/>
-                               <with-param name="separator" select="'&#xA;%%'"/>
+               <variable name="noshebang" select="$lines[position()>1 or not(starts-with(., '#!lesml') or starts-with(., '##'))]"/>
+               <variable name="docsep" select="$noshebang[starts-with(., '#!lesml') or starts-with(., '##')][1]"/>
+               <variable name="doclines" select="$noshebang[not($docsep) or following-sibling::*[generate-id()=generate-id($docsep)]]"/>
+               <if test="starts-with($first-line, '##') and $first-line!='##'">
+                       <comment>
+                               <value-of select="substring-after($first-line, '##')"/>
+                       </comment>
+               </if>
+               <if test="$shebang!='' or $doclines[normalize-space()!='']">
+                       <variable name="record-separators" select="$doclines[starts-with(., '%%')]"/>
+                       <element name="html:article">
+                               <for-each select="$params/html:div/html:dt[string()=' LANG ']">
+                                       <attribute name="lang">
+                                               <value-of select="following-sibling::html:dd"/>
+                                       </attribute>
+                                       <attribute name="xml:lang">
+                                               <value-of select="following-sibling::html:dd"/>
+                                       </attribute>
+                               </for-each>
+                               <for-each select="$params/html:div/html:dt[string()='profile']">
+                                       <attribute name="data-lesml-profile">
+                                               <value-of select="following-sibling::html:dd"/>
+                                       </attribute>
+                               </for-each>
+                               <if test="$record-separators[preceding-sibling::*[normalize-space()!='']]">
+                                       <element name="html:footer">
+                                               <attribute name="class">
+                                                       <text>head</text>
+                                               </attribute>
+                                               <for-each select="$record-separators">
+                                                       <variable name="position" select="position()"/>
+                                                       <variable name="prev-separator" select="$record-separators[($position)-1]"/>
+                                                       <variable name="fields" select="$noshebang[following-sibling::*[generate-id()=generate-id(current())] and (not($prev-separator) or preceding-sibling::*[generate-id()=generate-id($prev-separator)])]"/>
+                                                       <if test="$fields">
+                                                               <element name="html:dl">
+                                                                       <for-each select="$fields">
+                                                                               <choose>
+                                                                                       <when test="starts-with(., ' ') and $fields[generate-id()=generate-id(current()/preceding-sibling::*[1])]"/>
+                                                                                       <otherwise>
+                                                                                               <variable name="next" select="following-sibling::*[not(starts-with(., ' '))]"/>
+                                                                                               <element name="html:div">
+                                                                                                       <element name="html:dt">
+                                                                                                               <value-of select="normalize-space(substring-before(., ':'))"/>
+                                                                                                       </element>
+                                                                                                       <element name="html:dd">
+                                                                                                               <variable name="firstline">
+                                                                                                                       <choose>
+                                                                                                                               <when test="contains(., ':')">
+                                                                                                                                       <value-of select="normalize-space(substring-after(., ':'))"/>
+                                                                                                                               </when>
+                                                                                                                               <otherwise>
+                                                                                                                                       <value-of select="normalize-space(.)"/>
+                                                                                                                               </otherwise>
+                                                                                                                       </choose>
+                                                                                                               </variable>
+                                                                                                               <choose>
+                                                                                                                       <when test="substring($firstline, string-length($firstline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
+                                                                                                                               <value-of select="substring($firstline, 1, string-length($firstline)-1)"/>
+                                                                                                                       </when>
+                                                                                                                       <otherwise>
+                                                                                                                               <value-of select="$firstline"/>
+                                                                                                                       </otherwise>
+                                                                                                               </choose>
+                                                                                                               <for-each select="following-sibling::*[starts-with(., ' ') and not(preceding-sibling::*[generate-id()=generate-id($next)])]">
+                                                                                                                       <variable name="nextline" select="normalize-space(.)"/>
+                                                                                                                       <choose>
+                                                                                                                               <when test="substring($nextline, string-length($nextline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
+                                                                                                                                       <value-of select="substring($nextline, 1, string-length($nextline)-1)"/>
+                                                                                                                               </when>
+                                                                                                                               <otherwise>
+                                                                                                                                       <value-of select="$nextline"/>
+                                                                                                                               </otherwise>
+                                                                                                                       </choose>
+                                                                                                               </for-each>
+                                                                                                       </element>
+                                                                                               </element>
+                                                                                       </otherwise>
+                                                                               </choose>
+                                                                       </for-each>
+                                                               </element>
+                                                       </if>
+                                                       <if test=".!='%%'">
+                                                               <comment>
+                                                                       <value-of select="substring-after(., '%%')"/>
+                                                               </comment>
+                                                       </if>
+                                               </for-each>
+                                       </element>
+                               </if>
+                               <element name="html:div">
+                                       <attribute name="class">
+                                               <text>body</text>
+                                       </attribute>
+                                       <call-template name="LesML:paragraphize">
+                                               <with-param name="lines" select="$doclines[not($record-separators) or preceding-sibling::*[generate-id()=generate-id($record-separators[last()])]]"/>
+                                       </call-template>
+                               </element>
+                       </element>
+               </if>
+               <if test="$docsep">
+                       <call-template name="LesML:parse">
+                               <with-param name="lines" select="$docsep|$lines[preceding-sibling::*[generate-id()=generate-id($docsep)]]"/>
+                               <with-param name="parent-params" select="$params"/>
                        </call-template>
                        </call-template>
-               </variable>
-               <variable name="record-nodes" select="exsl:node-set($records)/*"/>
-               <html:article>
-                       <for-each select="$params/html:div/html:dt[string()=' LANG ']">
-                               <attribute name="lang">
-                                       <value-of select="following-sibling::html:dd"/>
-                               </attribute>
-                               <attribute name="xml:lang">
-                                       <value-of select="following-sibling::html:dd"/>
-                               </attribute>
-                       </for-each>
-                       <for-each select="$params/html:div/html:dt[string()='profile']">
-                               <attribute name="data-lesml-profile">
-                                       <value-of select="following-sibling::html:dd"/>
-                               </attribute>
-                       </for-each>
-                       <if test="count($record-nodes)>1">
-                               <html:footer class="head">
-                                       <for-each select="$record-nodes[not(position()=last() or normalize-space(.)='')]">
-                                               <variable name="fields" select="exslstr:tokenize(., '&#xA;')"/>
-                                               <html:dl>
-                                                       <for-each select="$fields">
-                                                               <choose>
-                                                                       <when test="starts-with(., ' ') and $fields[generate-id()=generate-id(current()/preceding-sibling::*[1])]"/>
-                                                                       <otherwise>
-                                                                               <variable name="next" select="following-sibling::*[not(starts-with(., ' '))]"/>
-                                                                               <html:div>
-                                                                                       <html:dt>
-                                                                                               <value-of select="normalize-space(substring-before(., ':'))"/>
-                                                                                       </html:dt>
-                                                                                       <html:dd>
-                                                                                               <variable name="firstline">
-                                                                                                       <choose>
-                                                                                                               <when test="contains(., ':')">
-                                                                                                                       <value-of select="normalize-space(substring-after(., ':'))"/>
-                                                                                                               </when>
-                                                                                                               <otherwise>
-                                                                                                                       <value-of select="normalize-space(.)"/>
-                                                                                                               </otherwise>
-                                                                                                       </choose>
-                                                                                               </variable>
-                                                                                               <choose>
-                                                                                                       <when test="substring($firstline, string-length($firstline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
-                                                                                                               <value-of select="substring($firstline, 1, string-length($firstline)-1)"/>
-                                                                                                       </when>
-                                                                                                       <otherwise>
-                                                                                                               <value-of select="$firstline"/>
-                                                                                                       </otherwise>
-                                                                                               </choose>
-                                                                                               <for-each select="following-sibling::*[starts-with(., ' ') and not(preceding-sibling::*[generate-id()=generate-id($next)])]">
-                                                                                                       <variable name="nextline" select="normalize-space(.)"/>
-                                                                                                       <choose>
-                                                                                                               <when test="substring($nextline, string-length($nextline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
-                                                                                                                       <value-of select="substring($nextline, 1, string-length($nextline)-1)"/>
-                                                                                                               </when>
-                                                                                                               <otherwise>
-                                                                                                                       <value-of select="$nextline"/>
-                                                                                                               </otherwise>
-                                                                                                       </choose>
-                                                                                               </for-each>
-                                                                                       </html:dd>
-                                                                               </html:div>
-                                                                       </otherwise>
-                                                               </choose>
-                                                       </for-each>
-                                               </html:dl>
-                                       </for-each>
-                               </html:footer>
-                       </if>
-                       <html:div class="body">
-                               <call-template name="LesML:paragraphize">
-                                       <with-param name="source" select="string($record-nodes[last()])"/>
-                               </call-template>
-                       </html:div>
-               </html:article>
+               </if>
        </template>
        <template name="LesML:paragraphize">
        </template>
        <template name="LesML:paragraphize">
-               <param name="source"/>
-               <variable name="paragraphs">
-                       <call-template name="LesML:split">
-                               <with-param name="source" select="$source"/>
-                               <with-param name="separator" select="'&#xA;&#xA;'"/>
-                       </call-template>
-               </variable>
+               <param name="lines" select="/.."/>
+               <variable name="last-lines" select="$lines[normalize-space()!='' and normalize-space(following-sibling::*[1])='']|$lines[last()]"/>
                <variable name="blocked">
                <variable name="blocked">
-                       <for-each select="exsl:node-set($paragraphs)/*">
-                               <variable name="lines">
-                                       <call-template name="LesML:split">
-                                               <with-param name="source" select="string()"/>
-                                       </call-template>
-                               </variable>
-                               <variable name="linespans" select="exsl:node-set($lines)/*"/>
+                       <for-each select="$last-lines">
+                               <variable name="position" select="position()"/>
+                               <variable name="prev-last" select="$last-lines[($position)-1]"/>
+                               <variable name="linespans" select="$lines[following-sibling::*[generate-id()=generate-id(current())] and (not($prev-last) or preceding-sibling::*[generate-id()=generate-id($prev-last)]) and normalize-space()!='']|."/>
                                <variable name="quoted" select="not($linespans[not(starts-with(., ' ') or starts-with(., '&#x9;'))])"/>
                                <variable name="quoted" select="not($linespans[not(starts-with(., ' ') or starts-with(., '&#x9;'))])"/>
+                               <variable name="preformatted" select="not($linespans[not(starts-with(normalize-space(), '|'))])"/>
                                <variable name="text">
                                        <for-each select="$linespans">
                                <variable name="text">
                                        <for-each select="$linespans">
-                                               <if test="normalize-space()!=''">
-                                                       <value-of select="normalize-space()"/>
-                                                       <if test="following-sibling::*[normalize-space()!='']">
-                                                               <text> </text>
-                                                       </if>
+                                               <choose>
+                                                       <when test="$preformatted">
+                                                               <value-of select="substring-after(., '|')"/>
+                                                       </when>
+                                                       <otherwise>
+                                                               <value-of select="normalize-space()"/>
+                                                       </otherwise>
+                                               </choose>
+                                               <if test="position()!=count($linespans)">
+                                                       <choose>
+                                                               <when test="$preformatted">
+                                                                       <text>&#xA;</text>
+                                                               </when>
+                                                               <otherwise>
+                                                                       <text> </text>
+                                                               </otherwise>
+                                                       </choose>
                                                </if>
                                        </for-each>
                                </variable>
                                <if test="string($text)!=''">
                                        <variable name="par">
                                                <choose>
                                                </if>
                                        </for-each>
                                </variable>
                                <if test="string($text)!=''">
                                        <variable name="par">
                                                <choose>
-                                                       <when test="starts-with($text, '⁌ ')">
-                                                               <html:h1>
+                                                       <when test="$preformatted">
+                                                               <element name="html:pre">
+                                                                       <call-template name="LesML:id-and-contents">
+                                                                               <with-param name="source" select="$text"/>
+                                                                       </call-template>
+                                                               </element>
+                                                       </when>
+                                                       <when test="starts-with($text, '⁌') and &sigiled-text;">
+                                                               <element name="html:h1">
                                                                        <call-template name="LesML:id-and-contents">
                                                                        <call-template name="LesML:id-and-contents">
-                                                                               <with-param name="source" select="substring-after($text, '⁌ ')"/>
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                        </call-template>
-                                                               </html:h1>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '§ ')">
-                                                               <html:h2>
+                                                       <when test="starts-with($text, '§') and &sigiled-text;">
+                                                               <element name="html:h2">
                                                                        <call-template name="LesML:id-and-contents">
                                                                        <call-template name="LesML:id-and-contents">
-                                                                               <with-param name="source" select="substring-after($text, '§ ')"/>
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                        </call-template>
-                                                               </html:h2>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '❦ ')">
-                                                               <html:h3>
+                                                       <when test="starts-with($text, '❦') and &sigiled-text;">
+                                                               <element name="html:h3">
                                                                        <call-template name="LesML:id-and-contents">
                                                                        <call-template name="LesML:id-and-contents">
-                                                                               <with-param name="source" select="substring-after($text, '❦ ')"/>
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                        </call-template>
-                                                               </html:h3>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '✠ ')">
-                                                               <html:h4>
+                                                       <when test="starts-with($text, '✠') and &sigiled-text;">
+                                                               <element name="html:h4">
                                                                        <call-template name="LesML:id-and-contents">
                                                                        <call-template name="LesML:id-and-contents">
-                                                                               <with-param name="source" select="substring-after($text, '✠ ')"/>
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                        </call-template>
-                                                               </html:h4>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '• ')">
-                                                               <html:li class="unordered" data-level="1">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '•') and &sigiled-text;">
+                                                               <element name="html:li">
+                                                                       <attribute name="class">
+                                                                               <text>unordered</text>
+                                                                       </attribute>
+                                                                       <attribute name="data-level">
+                                                                               <text>1</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '• ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:li>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '🔢 ')">
-                                                               <html:li class="ordered" data-level="1">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '🔢') and &sigiled-text;">
+                                                               <element name="html:li">
+                                                                       <attribute name="class">
+                                                                               <text>ordered</text>
+                                                                       </attribute>
+                                                                       <attribute name="data-level">
+                                                                               <text>1</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '🔢 ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:li>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '◦ ')">
-                                                               <html:li class="unordered" data-level="2">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '◦') and &sigiled-text;">
+                                                               <element name="html:li">
+                                                                       <attribute name="class">
+                                                                               <text>unordered</text>
+                                                                       </attribute>
+                                                                       <attribute name="data-level">
+                                                                               <text>2</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '◦ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:li>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '🔠 ')">
-                                                               <html:li class="ordered" data-level="2">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '🔠') and &sigiled-text;">
+                                                               <element name="html:li">
+                                                                       <attribute name="class">
+                                                                               <text>ordered</text>
+                                                                       </attribute>
+                                                                       <attribute name="data-level">
+                                                                               <text>2</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '🔠 ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:li>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '▪ ')">
-                                                               <html:li class="unordered" data-level="3">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '▪') and &sigiled-text;">
+                                                               <element name="html:li">
+                                                                       <attribute name="class">
+                                                                               <text>unordered</text>
+                                                                       </attribute>
+                                                                       <attribute name="data-level">
+                                                                               <text>3</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '▪ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:li>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '🔡 ')">
-                                                               <html:li class="ordered" data-level="3">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '🔡') and &sigiled-text;">
+                                                               <element name="html:li">
+                                                                       <attribute name="class">
+                                                                               <text>ordered</text>
+                                                                       </attribute>
+                                                                       <attribute name="data-level">
+                                                                               <text>3</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '🔡 ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:li>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '⁃ ')">
-                                                               <html:li class="unordered" data-level="4">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '⁃') and &sigiled-text;">
+                                                               <element name="html:li">
+                                                                       <attribute name="class">
+                                                                               <text>unordered</text>
+                                                                       </attribute>
+                                                                       <attribute name="data-level">
+                                                                               <text>4</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '⁃ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:li>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '🔣 ')">
-                                                               <html:li class="ordered" data-level="4">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '🔣') and &sigiled-text;">
+                                                               <element name="html:li">
+                                                                       <attribute name="class">
+                                                                               <text>ordered</text>
+                                                                       </attribute>
+                                                                       <attribute name="data-level">
+                                                                               <text>4</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '🔣 ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:li>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '🛈 ')">
-                                                               <html:div role="note" class="info">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '🛈') and &sigiled-text;">
+                                                               <element name="html:div">
+                                                                       <attribute name="role">
+                                                                               <text>note</text>
+                                                                       </attribute>
+                                                                       <attribute name="class">
+                                                                               <text>info</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '🛈 ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:div>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '⯑ ')">
-                                                               <html:div role="note" class="query">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '⯑') and &sigiled-text;">
+                                                               <element name="html:div">
+                                                                       <attribute name="role">
+                                                                               <text>note</text>
+                                                                       </attribute>
+                                                                       <attribute name="class">
+                                                                               <text>query</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '⯑ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:div>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '⚠︎ ')">
-                                                               <html:div role="note" class="warn">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '⚠︎') and &sigiled-text;">
+                                                               <element name="html:div">
+                                                                       <attribute name="role">
+                                                                               <text>note</text>
+                                                                       </attribute>
+                                                                       <attribute name="class">
+                                                                               <text>warn</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '⚠︎ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:div>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '※ ')">
-                                                               <html:div role="note" class="note">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '※') and &sigiled-text;">
+                                                               <element name="html:div">
+                                                                       <attribute name="role">
+                                                                               <text>note</text>
+                                                                       </attribute>
+                                                                       <attribute name="class">
+                                                                               <text>note</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '※ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:div>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '☡ ')">
-                                                               <html:div role="note" class="caution">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '☡') and &sigiled-text;">
+                                                               <element name="html:div">
+                                                                       <attribute name="role">
+                                                                               <text>note</text>
+                                                                       </attribute>
+                                                                       <attribute name="class">
+                                                                               <text>caution</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '☡ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:div>
+                                                                       </element>
+                                                               </element>
                                                        </when>
                                                        </when>
-                                                       <when test="starts-with($text, '⋯ ')">
-                                                               <html:div class="continuation">
-                                                                       <html:p>
+                                                       <when test="starts-with($text, '⋯') and &sigiled-text;">
+                                                               <element name="html:div">
+                                                                       <attribute name="class">
+                                                                               <text>continuation</text>
+                                                                       </attribute>
+                                                                       <element name="html:p">
                                                                                <call-template name="LesML:id-and-contents">
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '⋯ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                                </call-template>
-                                                                       </html:p>
-                                                               </html:div>
+                                                                       </element>
+                                                               </element>
+                                                       </when>
+                                                       <when test="starts-with($text, '#') and &sigiled-text;">
+                                                               <comment>
+                                                                       <value-of select="&unsigiled-text;"/>
+                                                               </comment>
                                                        </when>
                                                        <otherwise>
                                                        </when>
                                                        <otherwise>
-                                                               <html:p>
+                                                               <element name="html:p">
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="$text"/>
                                                                        </call-template>
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="$text"/>
                                                                        </call-template>
-                                                               </html:p>
+                                                               </element>
                                                        </otherwise>
                                                </choose>
                                        </variable>
                                        <choose>
                                                <when test="translate(string($text), '&section-break; ', '')=''">
                                                        </otherwise>
                                                </choose>
                                        </variable>
                                        <choose>
                                                <when test="translate(string($text), '&section-break; ', '')=''">
-                                                       <html:hr/>
+                                                       <element name="html:hr"/>
                                                </when>
                                                <when test="$quoted">
                                                </when>
                                                <when test="$quoted">
-                                                       <html:blockquote>
+                                                       <element name="html:blockquote">
                                                                <copy-of select="$par"/>
                                                                <copy-of select="$par"/>
-                                                       </html:blockquote>
+                                                       </element>
                                                </when>
                                                <otherwise>
                                                        <copy-of select="$par"/>
                                                </when>
                                                <otherwise>
                                                        <copy-of select="$par"/>
@@ -482,13 +628,17 @@ 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)/node()" mode="LesML:finalize-tree"/>
        </template>
        <template match="html:script[@type='text/lesml']">
                <apply-templates select="exsl:node-set($inlined)/node()" mode="LesML:finalize-tree"/>
        </template>
        <template match="html:script[@type='text/lesml']">
-               <variable name="source">
-                       <for-each select=".//text()">
-                               <value-of select="."/>
-                       </for-each>
+               <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>
                <call-template name="LesML:parse">
                </variable>
                <call-template name="LesML:parse">
-                       <with-param name="source" select="string($source)"/>
+                       <with-param name="lines" select="exsl:node-set($lines-fragment)/*"/>
                </call-template>
        </template>
        <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
                </call-template>
        </template>
        <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
@@ -497,7 +647,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                </copy>
        </template>
        <template match="text()" mode="LesML:finalize-tree">
                </copy>
        </template>
        <template match="text()" mode="LesML:finalize-tree">
-               <call-template name="LesML:unescape">
+               <call-template name="LesML:break-and-unescape">
                        <with-param name="source" select="string(.)"/>
                </call-template>
        </template>
                        <with-param name="source" select="string(.)"/>
                </call-template>
        </template>
@@ -519,18 +669,18 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                <value-of select="substring-after($laststarttext, '— ')"/>
                                                <copy-of select="$laststarttext/following-sibling::node()"/>
                                        </variable>
                                                <value-of select="substring-after($laststarttext, '— ')"/>
                                                <copy-of select="$laststarttext/following-sibling::node()"/>
                                        </variable>
-                                       <html:figure>
+                                       <element name="html:figure">
                                                <copy>
                                                        <apply-templates select="@*|$content-nodes[position()!=last()]" mode="LesML:finalize-tree"/>
                                                </copy>
                                                <copy>
                                                        <apply-templates select="@*|$content-nodes[position()!=last()]" mode="LesML:finalize-tree"/>
                                                </copy>
-                                               <html:figcaption>
+                                               <element name="html:figcaption">
                                                        <for-each select="$content-nodes[last()]">
                                                                <copy>
                                                                        <apply-templates select="@*|exsl:node-set($caption)/node()" mode="LesML:finalize-tree"/>
                                                                </copy>
                                                        </for-each>
                                                        <for-each select="$content-nodes[last()]">
                                                                <copy>
                                                                        <apply-templates select="@*|exsl:node-set($caption)/node()" mode="LesML:finalize-tree"/>
                                                                </copy>
                                                        </for-each>
-                                               </html:figcaption>
-                                       </html:figure>
+                                               </element>
+                                       </element>
                                </when>
                                <otherwise>
                                        <copy>
                                </when>
                                <otherwise>
                                        <copy>
@@ -741,7 +891,10 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                                </variable>
                                                                                <copy-of select="$start-node/preceding-sibling::node()"/>
                                                                                <value-of select="substring-before($start-node, '{🔗')"/>
                                                                                </variable>
                                                                                <copy-of select="$start-node/preceding-sibling::node()"/>
                                                                                <value-of select="substring-before($start-node, '{🔗')"/>
-                                                                               <html:a href="{$ltcomponent-nodes[last()]}">
+                                                                               <element name="html:a">
+                                                                                       <attribute name="href">
+                                                                                               <value-of select="$ltcomponent-nodes[last()]"/>
+                                                                                       </attribute>
                                                                                        <choose>
                                                                                                <when test="count($ltcomponent-nodes)>2 or normalize-space($ltcomponent-nodes[1])!=''">
                                                                                                        <value-of select="$ltcomponent-nodes[1]"/>
                                                                                        <choose>
                                                                                                <when test="count($ltcomponent-nodes)>2 or normalize-space($ltcomponent-nodes[1])!=''">
                                                                                                        <value-of select="$ltcomponent-nodes[1]"/>
@@ -754,7 +907,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                                                        <value-of select="$ltcomponent-nodes[last()]"/>
                                                                                                </otherwise>
                                                                                        </choose>
                                                                                                        <value-of select="$ltcomponent-nodes[last()]"/>
                                                                                                </otherwise>
                                                                                        </choose>
-                                                                               </html:a>
+                                                                               </element>
                                                                                <copy-of select="exsl:node-set($processed-rest)/*/node()"/>
                                                                        </when>
                                                                        <otherwise>
                                                                                <copy-of select="exsl:node-set($processed-rest)/*/node()"/>
                                                                        </when>
                                                                        <otherwise>
This page took 0.278222 seconds and 4 git commands to generate.