]> Lady’s Gitweb - LesML/commitdiff
Support hgroups with heading continuations current 0.5.0
authorLady <redacted>
Mon, 28 Apr 2025 01:55:06 +0000 (21:55 -0400)
committerLady <redacted>
Mon, 28 Apr 2025 01:55:06 +0000 (21:55 -0400)
These are a bit interesting because continuation paragraphs can be
placed _before_ the heading they “continue” (not just after). A block
comment can be used to separate them from a preceding list or similar.

README.markdown
parser.xslt

index 29815e549d3a86cd67fb8a6fe953ac902cd726e7..ac2d0dc5b89facc1fbea5275baed244f33140145 100644 (file)
@@ -52,6 +52,14 @@ Documents in the later case inherit the latest preceding `#!lesml`
 
 Documents are broken into paragraphs by blank lines.
 Empty paragraphs are ignored.
 
 Documents are broken into paragraphs by blank lines.
 Empty paragraphs are ignored.
+
+If every line in the paragraph begins with (optional white·space
+  followed by) `»` it is quoted (`<html:blockquote>`); if every line
+  begins with `]` it is bracketed.
+The lines, minus this leading, are then re‐analysed.
+Bracketed paragraphs which end quotes are treated as captions
+  (`<html:figcaption>`); otherwise, they are footers (`<html:footer>`).
+
 Non·empty paragraphs are classified as follows :⁠—
 
 - If the paragraph consists of only the following section‐break
 Non·empty paragraphs are classified as follows :⁠—
 
 - If the paragraph consists of only the following section‐break
@@ -98,21 +106,16 @@ Non·empty paragraphs are classified as follows :⁠—
   | `_` | `U+FF3F` | `FULLWIDTH LOW LINE` |
   | `~` | `U+FF5E` | `FULLWIDTH TILDE` |
 
   | `_` | `U+FF3F` | `FULLWIDTH LOW LINE` |
   | `~` | `U+FF5E` | `FULLWIDTH TILDE` |
 
-- If every line in the paragraph begins with at least one space, then
-    it is considered to be a quoted paragraph (`<html:blockquote>`).
-  There is only one level of paragraph quoting; quoted paragraphs may
-    not be quoted again.
-
 - If every line in the paragraph begins with zero or more white·space
     characters followed by `|`, it is a “preformatted” paragraph and
     white·space is not collapsed (`<html:pre>`).
 - If every line in the paragraph begins with zero or more white·space
     characters followed by `|`, it is a “preformatted” paragraph and
     white·space is not collapsed (`<html:pre>`).
-  A paragraph may be both quoted and preformatted.
 
 
-- Otherwise, the paragraph is unquoted.
+- Otherwise, the paragraph is ordinary.
 
 
-After this classification, each quoted or unquoted paragraph is further
+After this classification, each ordinary paragraph is further
   classified by type based on its first character (which is must be
   classified by type based on its first character (which is must be
-   followed by white·space, or else the only thing on the line) :⁠—
+  followed by white·space, a pilcrow, or else the only thing on the
+  line) :⁠—
 
 - If the paragraph is preformatted, it is an ordinary paragraph.
 
 
 - If the paragraph is preformatted, it is an ordinary paragraph.
 
@@ -170,24 +173,42 @@ After this classification, each quoted or unquoted paragraph is further
   Comments produce X·M·L comment nodes and can be used to break up list
     items into separate lists.
 
   Comments produce X·M·L comment nodes and can be used to break up list
     items into separate lists.
 
-- If the paragraph begins with `⋯`, it is a continuation paragraph
-    (`<html:div class="continuation">`).
-  Continuation paragraphs may be used to continue a preceding list item
-    or quote.
-  Note, however, that an unquoted paragraph cannot continue a quoted
-    one, or vice·versa.
+- If the paragraph begins with `⋯`, it is a continuation paragraph.
+  Continuation paragraphs may be used to continue a preceding div or
+    list item.
+  If there is no such preceding div or list item, they will attach to
+    adjacent heading elements to form heading groups (`<html:hgroup>`).
+  Otherwise, they will be treated as ordinary paragraphs.
 
 - Otherwise, it is an ordinary paragraph.
 
 
 - Otherwise, it is an ordinary paragraph.
 
-Following this sigil (if any, including trailing white·space) there may
-  be a `¶` followed by zero or more non·white·space characters.
+Following this sigil (if any) there may be a `¶` followed by zero or
+  more non·white·space characters.
 The characters following the `¶` give the identifier for the paragraph,
   which is expected to be unique within a document.
 The characters following the `¶` give the identifier for the paragraph,
   which is expected to be unique within a document.
+This may be suffixed with a language tag beginning with `@` and
+  terminated with `$`.
 
 The remaining characters in a paragraph form its contents.
 Markup within paragraphs is delimited with·out exception by pairs of
   characters, with the following precedence :⁠—
 
 
 The remaining characters in a paragraph form its contents.
 Markup within paragraphs is delimited with·out exception by pairs of
   characters, with the following precedence :⁠—
 
+- The characters `⌦` and `⌫` indicate inline comments.
+  A single character `⌧` may be used to indicate an “empty” comment
+    (consisting of `U+034F COMBINING GRAPHEME JOINER` for X·M·L
+    compatibility).
+
+- The characters `{@` and `"}` indicate attribute specifications.
+  The attribute specification must contain at least one `="` which
+    separates the key of the attribute from the value.
+  Attributes attach to the previous element or text node, with
+    white·space‐only text nodes after elements ignored; if there is no
+    such previous element or text node, an empty text node is used
+    instead.
+  Multiple attributes can be given in sequence using multiple
+    specifications.
+  Text nodes with attributes are wrapped in `<html:span>`.
+
 - The characters `{🔗` and `>}` indicate a hyperlink to a U·R·L
     (`<html:a>`).
   The hyperlink must contain at least one `<`; the content before the
 - The characters `{🔗` and `>}` indicate a hyperlink to a U·R·L
     (`<html:a>`).
   The hyperlink must contain at least one `<`; the content before the
@@ -209,9 +230,9 @@ Markup within paragraphs is delimited with·out exception by pairs of
 
 - The characters `⟪` and `⟫` indicate titles (`<html:cite>`).
 
 
 - The characters `⟪` and `⟫` indicate titles (`<html:cite>`).
 
+- The characters `⸶` and `⸷` indicate names (`<html:u class="name">`).
+
 - The characters `⟨` and `⟩` indicate offset text (`<html:i>`).
 - The characters `⟨` and `⟩` indicate offset text (`<html:i>`).
-  This may be followed by a `@`, a language tag, and a `$` to provide
-    the language of the text.
 
 - The characters `⦃` and `⦄` indicate keyword highlighting
     (`<html:b>`).
 
 - The characters `⦃` and `⦄` indicate keyword highlighting
     (`<html:b>`).
@@ -224,13 +245,8 @@ Markup within paragraphs is delimited with·out exception by pairs of
 Once the tree is built as above, it is remediated into its final form
   by the following steps :⁠—
 
 Once the tree is built as above, it is remediated into its final form
   by the following steps :⁠—
 
-- Successive quoted paragraphs are joined into one quote.
-  If the final quoted paragraph is an ordinary paragraph which begins
-    with `—` and a space, the quote is wrapped in a `<html:figure>`
-    and the final paragraph becomes its `<html:figcaption>`.
-
 - Continuation paragraphs are joined with the preceding list items or
 - Continuation paragraphs are joined with the preceding list items or
-    quotes.
+    divs.
 
 - List items of a higher level are nested in preceding list items, when
     present.
 
 - List items of a higher level are nested in preceding list items, when
     present.
@@ -244,7 +260,9 @@ Finally, any character can be escaped by instead providing its Unicode
   codepoint in the form `{U+NNNN}`, where `NNNN` is one or more
   hexadecimal digits.
 Multiple codepoints may be provided separated by periods, as in
   codepoint in the form `{U+NNNN}`, where `NNNN` is one or more
   hexadecimal digits.
 Multiple codepoints may be provided separated by periods, as in
-  `{U+WWWW.ZZZZ}`
+  `{U+WWWW.ZZZZ}`.
+Due to limitations in X·S·L·T, characters cannot be escaped in
+  attributes (including link targets).
 
 ## Usage
 
 
 ## Usage
 
index 6e0d82a842f43854ec589bc8413ee2cf12ce3c63..5ba22481500091cd93f14a5879c8bac631869336 100644 (file)
@@ -12,22 +12,27 @@ 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 sigiled-text "(string-length($text)=1 or substring($text, 2, 1)=' ')">
-       <!ENTITY unsigiled-text "substring($text, 3, string-length($text)-2)">
+       <!ENTITY LesML "urn:fdc:ladys.computer:20240512:LesML">
+       <!ENTITY section-break "">
+       <!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">
 ]>
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
        xmlns:LesML="urn:fdc:ladys.computer:20240512:LesML"
        xmlns:exsl="http://exslt.org/common"
 ]>
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
        xmlns:LesML="urn:fdc:ladys.computer:20240512:LesML"
        xmlns:exsl="http://exslt.org/common"
+       xmlns:exsldyn="http://exslt.org/dynamic"
+       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: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 exslstr"
+       extension-element-prefixes="exsl exsldyn exslset exslstr"
        version="1.0"
 >
        <书社:id>urn:fdc:ladys.computer:20240512:LesML:parser.xslt</书社:id>
        version="1.0"
 >
        <书社:id>urn:fdc:ladys.computer:20240512:LesML:parser.xslt</书社:id>
+       <param name="LESML_SECTION_BREAK_CHARS" select="'*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~'"/>
        <template name="LesML:split">
                <param name="source"/>
                <param name="separator" select="'&#xA;'"/>
        <template name="LesML:split">
                <param name="source"/>
                <param name="separator" select="'&#xA;'"/>
@@ -62,7 +67,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                <with-param name="source" select="string()"/>
                        </call-template>
                        <if test="position()!=count($broken)">
                                <with-param name="source" select="string()"/>
                        </call-template>
                        <if test="position()!=count($broken)">
-                               <element name="html:br"/>
+                               <element name="br" namespace="&xhtml;"/>
                        </if>
                </for-each>
        </template>
                        </if>
                </for-each>
        </template>
@@ -117,31 +122,96 @@ 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: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>
+                       <for-each select="exsl:node-set($comment-split-fragment)/*">
+                               <if test="string()='' or starts-with(., '‐')">
+                                       <text>&#x034F;</text>
+                               </if>
+                               <value-of select="."/>
+                               <if test="substring(., string-length(.), 1)='‐'">
+                                       <text>&#x034F;</text>
+                               </if>
+                               <choose>
+                                       <when test="position()!=last()">
+                                               <text>-&#x034F;-</text>
+                                       </when>
+                               </choose>
+                       </for-each>
+               </comment>
+       </template>
        <template name="LesML:id-and-contents">
                <param name="source"/>
        <template name="LesML:id-and-contents">
                <param name="source"/>
-               <choose>
-                       <when test="starts-with($source, '¶')">
+               <variable name="id-and-lang">
+                       <if test="starts-with($source, '¶')">
                                <choose>
                                        <when test="contains($source, ' ')">
                                <choose>
                                        <when test="contains($source, ' ')">
-                                               <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, ' ')"/>
+                                               <value-of select="substring-before(substring-after($source, '¶'), ' ')"/>
                                        </when>
                                        <otherwise>
                                        </when>
                                        <otherwise>
-                                               <attribute name="id">
-                                                       <value-of select="substring-after($source, '¶')"/>
-                                               </attribute>
+                                               <value-of select="substring-after($source, '¶')"/>
                                        </otherwise>
                                </choose>
                                        </otherwise>
                                </choose>
-                       </when>
-                       <otherwise>
-                               <value-of select="$source"/>
-                       </otherwise>
-               </choose>
+                       </if>
+               </variable>
+               <variable name="restoftext">
+                       <choose>
+                               <when test="starts-with($source, '¶') and contains($source, ' ')">
+                                       <value-of select="substring-after($source, ' ')"/>
+                               </when>
+                               <when test="starts-with($source, '¶')"/>
+                               <otherwise>
+                                       <value-of select="$source"/>
+                               </otherwise>
+                       </choose>
+               </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()]"/>
+                       </if>
+               </variable>
+               <variable name="langtag">
+                       <if test="translate($maybe-langtag, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-', '')=''">
+                               <value-of select="$maybe-langtag"/>
+                       </if>
+               </variable>
+               <variable name="id">
+                       <choose>
+                               <when test="string($langtag)!=''">
+                                       <value-of select="substring($id-and-lang, 1, string-length($id-and-lang)-(string-length($langtag)+2))"/>
+                               </when>
+                               <otherwise>
+                                       <value-of select="$id-and-lang"/>
+                               </otherwise>
+                       </choose>
+               </variable>
+               <if test="string($id)!=''">
+                       <attribute name="id">
+                               <value-of select="$id"/>
+                       </attribute>
+               </if>
+               <if test="string($langtag)!=''">
+                       <attribute name="lang">
+                               <value-of select="$langtag"/>
+                       </attribute>
+                       <attribute name="xml:lang">
+                               <value-of select="$langtag"/>
+                       </attribute>
+               </if>
+               <value-of select="$restoftext"/>
        </template>
        <template name="LesML:parse">
                <param name="lines" select="/.."/>
        </template>
        <template name="LesML:parse">
                <param name="lines" select="/.."/>
@@ -211,15 +281,15 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                <variable name="params" select="exsl:node-set($params-fragment)/*"/>
                <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="params" select="exsl:node-set($params-fragment)/*"/>
                <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)]]"/>
+               <variable name="doclines" select="exslset:leading($noshebang, $docsep)"/>
                <if test="starts-with($first-line, '##') and $first-line!='##'">
                <if test="starts-with($first-line, '##') and $first-line!='##'">
-                       <comment>
-                               <value-of select="substring-after($first-line, '##')"/>
-                       </comment>
+                       <call-template name="LesML:comment-out">
+                               <with-param name="source" select="substring-after($first-line, '##')"/>
+                       </call-template>
                </if>
                </if>
-               <if test="$shebang!='' or $doclines[normalize-space()!='']">
+               <if test="$doclines[normalize-space()!='']">
                        <variable name="record-separators" select="$doclines[starts-with(., '%%')]"/>
                        <variable name="record-separators" select="$doclines[starts-with(., '%%')]"/>
-                       <element name="html:article">
+                       <element name="article" namespace="&xhtml;">
                                <for-each select="$params/html:div/html:dt[string()=' LANG ']">
                                        <attribute name="lang">
                                                <value-of select="following-sibling::html:dd"/>
                                <for-each select="$params/html:div/html:dt[string()=' LANG ']">
                                        <attribute name="lang">
                                                <value-of select="following-sibling::html:dd"/>
@@ -234,26 +304,26 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                        </attribute>
                                </for-each>
                                <if test="$record-separators[preceding-sibling::*[normalize-space()!='']]">
                                        </attribute>
                                </for-each>
                                <if test="$record-separators[preceding-sibling::*[normalize-space()!='']]">
-                                       <element name="html:footer">
+                                       <element name="footer" namespace="&xhtml;">
                                                <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]"/>
                                                <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)])]"/>
+                                                       <variable name="fields" select="exslset:leading(exslset:trailing($doclines, $prev-separator), .)"/>
                                                        <if test="$fields">
                                                        <if test="$fields">
-                                                               <element name="html:dl">
+                                                               <element name="dl" namespace="&xhtml;">
                                                                        <for-each select="$fields">
                                                                                <choose>
                                                                        <for-each select="$fields">
                                                                                <choose>
-                                                                                       <when test="starts-with(., ' ') and $fields[generate-id()=generate-id(current()/preceding-sibling::*[1])]"/>
+                                                                                       <when test="starts-with(., ' ') and exslset:leading($fields, .)"/>
                                                                                        <otherwise>
                                                                                        <otherwise>
-                                                                                               <variable name="next" select="following-sibling::*[not(starts-with(., ' '))]"/>
-                                                                                               <element name="html:div">
-                                                                                                       <element name="html:dt">
+                                                                                               <variable name="next" select="exslset:intersection(following-sibling::*[not(starts-with(., ' '))][1], $fields)"/>
+                                                                                               <element name="div" namespace="&xhtml;">
+                                                                                                       <element name="dt" namespace="&xhtml;">
                                                                                                                <value-of select="normalize-space(substring-before(., ':'))"/>
                                                                                                        </element>
                                                                                                                <value-of select="normalize-space(substring-before(., ':'))"/>
                                                                                                        </element>
-                                                                                                       <element name="html:dd">
+                                                                                                       <element name="dd" namespace="&xhtml;">
                                                                                                                <variable name="firstline">
                                                                                                                        <choose>
                                                                                                                                <when test="contains(., ':')">
                                                                                                                <variable name="firstline">
                                                                                                                        <choose>
                                                                                                                                <when test="contains(., ':')">
@@ -272,7 +342,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                                                                                <value-of select="$firstline"/>
                                                                                                                        </otherwise>
                                                                                                                </choose>
                                                                                                                                <value-of select="$firstline"/>
                                                                                                                        </otherwise>
                                                                                                                </choose>
-                                                                                                               <for-each select="following-sibling::*[starts-with(., ' ') and not(preceding-sibling::*[generate-id()=generate-id($next)])]">
+                                                                                                               <for-each select="exslset:intersection(following-sibling::*[starts-with(., ' ')], exslset:leading($fields, $next))">
                                                                                                                        <variable name="nextline" select="normalize-space(.)"/>
                                                                                                                        <choose>
                                                                                                                                <when test="substring($nextline, string-length($nextline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
                                                                                                                        <variable name="nextline" select="normalize-space(.)"/>
                                                                                                                        <choose>
                                                                                                                                <when test="substring($nextline, string-length($nextline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
@@ -291,341 +361,386 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </element>
                                                        </if>
                                                        <if test=".!='%%'">
                                                                </element>
                                                        </if>
                                                        <if test=".!='%%'">
-                                                               <comment>
-                                                                       <value-of select="substring-after(., '%%')"/>
-                                                               </comment>
+                                                               <call-template name="LesML:comment-out">
+                                                                       <with-param name="source" select="substring-after(., '%%')"/>
+                                                               </call-template>
                                                        </if>
                                                </for-each>
                                        </element>
                                </if>
                                                        </if>
                                                </for-each>
                                        </element>
                                </if>
-                               <element name="html:div">
+                               <element name="div" namespace="&xhtml;">
                                        <attribute name="class">
                                                <text>body</text>
                                        </attribute>
                                        <call-template name="LesML:paragraphize">
                                        <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()])]]"/>
+                                               <with-param name="lines" select="exslset:trailing($doclines, $record-separators[last()])"/>
                                        </call-template>
                                </element>
                        </element>
                </if>
                <if test="$docsep">
                        <call-template name="LesML:parse">
                                        </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="lines" select="$docsep|exslset:trailing($lines, $docsep)"/>
                                <with-param name="parent-params" select="$params"/>
                        </call-template>
                </if>
        </template>
                                <with-param name="parent-params" select="$params"/>
                        </call-template>
                </if>
        </template>
-       <template name="LesML:paragraphize">
+       <template name="LesML:block">
                <param name="lines" select="/.."/>
                <param name="lines" select="/.."/>
-               <variable name="last-lines" select="$lines[normalize-space()!='' and normalize-space(following-sibling::*[1])='']|$lines[last()]"/>
-               <variable name="blocked">
-                       <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="preformatted" select="not($linespans[not(starts-with(normalize-space(), '|'))])"/>
-                               <variable name="text">
-                                       <for-each select="$linespans">
-                                               <choose>
-                                                       <when test="$preformatted">
-                                                               <value-of select="substring-after(., '|')"/>
-                                                       </when>
-                                                       <otherwise>
-                                                               <value-of select="normalize-space()"/>
-                                                       </otherwise>
-                                               </choose>
-                                               <if test="position()!=count($linespans)">
+               <variable name="last-lines" select="$lines[normalize-space()!='' and (normalize-space(following-sibling::*[1])='' or position()=last())]"/>
+               <for-each select="$last-lines">
+                       <variable name="position" select="position()"/>
+                       <variable name="prev-last" select="$last-lines[($position)-1]"/>
+                       <variable name="linespans" select="(exslset:intersection(exslset:trailing($lines, $prev-last), exslset:leading($lines, .))|.)[normalize-space()!='']"/>
+                       <variable name="prefix" select="substring(translate(., ' &#x9;', ''), 1, 1)"/>
+                       <variable name="all-prefixed" select="not($linespans[not(starts-with(translate(., ' &#x9;', ''), $prefix))])"/>
+                       <variable name="quoted" select="$all-prefixed and $prefix='»'"/>
+                       <variable name="bracketed" select="$all-prefixed and $prefix=']'"/>
+                       <choose>
+                               <when test="count($linespans)=1 and translate(., concat($LESML_SECTION_BREAK_CHARS, ' &#x9;'), '')=''">
+                                       <element name="hr" namespace="&xhtml;"/>
+                               </when>
+                               <when test="$quoted or $bracketed">
+                                       <variable name="innerlines-fragment">
+                                               <for-each select="$linespans">
+                                                       <variable name="inner">
+                                                               <value-of select="substring-after(., $prefix)"/>
+                                                       </variable>
+                                                       <copy>
+                                                               <choose>
+                                                                       <when test="starts-with($inner, ' ') or starts-with($inner, '&#x9;')">
+                                                                               <value-of select="substring($inner, 1+count(exslstr:tokenize($inner, '')[normalize-space()='' and not(preceding-sibling::*[normalize-space()!=''])]))"/>
+                                                                       </when>
+                                                                       <otherwise>
+                                                                               <value-of select="$inner"/>
+                                                                       </otherwise>
+                                                               </choose>
+                                                       </copy>
+                                               </for-each>
+                                       </variable>
+                                       <variable name="blocked-fragment">
+                                               <call-template name="LesML:block">
+                                                       <with-param name="lines" select="exsl:node-set($innerlines-fragment)/*"/>
+                                               </call-template>
+                                       </variable>
+                                       <variable name="innerpars" select="exsl:node-set($blocked-fragment)/node()"/>
+                                       <choose>
+                                               <when test="$quoted and $innerpars[position()=last() and self::html:footer]">
+                                                       <element name="figure" namespace="&xhtml;">
+                                                               <element name="blockquote" namespace="&xhtml;">
+                                                                       <copy-of select="$innerpars[position()!=last()]"/>
+                                                               </element>
+                                                               <element name="figcaption" namespace="&xhtml;">
+                                                                       <copy-of select="$innerpars[last()]/node()"/>
+                                                               </element>
+                                                       </element>
+                                               </when>
+                                               <when test="$quoted">
+                                                       <element name="blockquote" namespace="&xhtml;">
+                                                               <copy-of select="$innerpars"/>
+                                                       </element>
+                                               </when>
+                                               <when test="$bracketed">
+                                                       <element name="footer" namespace="&xhtml;">
+                                                               <copy-of select="$innerpars"/>
+                                                       </element>
+                                               </when>
+                                       </choose>
+                               </when>
+                               <otherwise>
+                                       <variable name="preformatted" select="$all-prefixed and $prefix='|'"/>
+                                       <variable name="text">
+                                               <for-each select="$linespans">
                                                        <choose>
                                                                <when test="$preformatted">
                                                        <choose>
                                                                <when test="$preformatted">
-                                                                       <text>&#xA;</text>
+                                                                       <value-of select="substring-after(., '|')"/>
                                                                </when>
                                                                <otherwise>
                                                                </when>
                                                                <otherwise>
-                                                                       <text> </text>
+                                                                       <value-of select="normalize-space()"/>
                                                                </otherwise>
                                                        </choose>
                                                                </otherwise>
                                                        </choose>
-                                               </if>
-                                       </for-each>
-                               </variable>
-                               <if test="string($text)!=''">
-                                       <variable name="par">
-                                               <choose>
-                                                       <when test="$preformatted">
-                                                               <element name="html:pre">
+                                                       <if test="position()!=count($linespans)">
+                                                               <choose>
+                                                                       <when test="$preformatted">
+                                                                               <text>&#xA;</text>
+                                                                       </when>
+                                                                       <otherwise>
+                                                                               <text> </text>
+                                                                       </otherwise>
+                                                               </choose>
+                                                       </if>
+                                               </for-each>
+                                       </variable>
+                                       <choose>
+                                               <when test="$preformatted">
+                                                       <element name="pre" namespace="&xhtml;">
+                                                               <call-template name="LesML:id-and-contents">
+                                                                       <with-param name="source" select="$text"/>
+                                                               </call-template>
+                                                       </element>
+                                               </when>
+                                               <when test="string($text)=''"/>
+                                               <when test="starts-with($text, '⁌') and &sigiled-text;">
+                                                       <element name="h1" namespace="&xhtml;">
+                                                               <call-template name="LesML:id-and-contents">
+                                                                       <with-param name="source" select="&unsigiled-text;"/>
+                                                               </call-template>
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '§') and &sigiled-text;">
+                                                       <element name="h2" namespace="&xhtml;">
+                                                               <call-template name="LesML:id-and-contents">
+                                                                       <with-param name="source" select="&unsigiled-text;"/>
+                                                               </call-template>
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '❦') and &sigiled-text;">
+                                                       <element name="h3" namespace="&xhtml;">
+                                                               <call-template name="LesML:id-and-contents">
+                                                                       <with-param name="source" select="&unsigiled-text;"/>
+                                                               </call-template>
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '✠') and &sigiled-text;">
+                                                       <element name="h4" namespace="&xhtml;">
+                                                               <call-template name="LesML:id-and-contents">
+                                                                       <with-param name="source" select="&unsigiled-text;"/>
+                                                               </call-template>
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '•') and &sigiled-text;">
+                                                       <element name="li" namespace="&xhtml;">
+                                                               <attribute name="class">
+                                                                       <text>unordered</text>
+                                                               </attribute>
+                                                               <attribute name="data-level">
+                                                                       <text>1</text>
+                                                               </attribute>
+                                                               <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                        <call-template name="LesML:id-and-contents">
-                                                                               <with-param name="source" select="$text"/>
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </element>
                                                                        </call-template>
                                                                </element>
-                                                       </when>
-                                                       <when test="starts-with($text, '⁌') and &sigiled-text;">
-                                                               <element name="html:h1">
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '🔢') and &sigiled-text;">
+                                                       <element name="li" namespace="&xhtml;">
+                                                               <attribute name="class">
+                                                                       <text>ordered</text>
+                                                               </attribute>
+                                                               <attribute name="data-level">
+                                                                       <text>1</text>
+                                                               </attribute>
+                                                               <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </element>
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </element>
-                                                       </when>
-                                                       <when test="starts-with($text, '§') and &sigiled-text;">
-                                                               <element name="html:h2">
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '◦') and &sigiled-text;">
+                                                       <element name="li" namespace="&xhtml;">
+                                                               <attribute name="class">
+                                                                       <text>unordered</text>
+                                                               </attribute>
+                                                               <attribute name="data-level">
+                                                                       <text>2</text>
+                                                               </attribute>
+                                                               <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </element>
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </element>
-                                                       </when>
-                                                       <when test="starts-with($text, '❦') and &sigiled-text;">
-                                                               <element name="html:h3">
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '🔠') and &sigiled-text;">
+                                                       <element name="li" namespace="&xhtml;">
+                                                               <attribute name="class">
+                                                                       <text>ordered</text>
+                                                               </attribute>
+                                                               <attribute name="data-level">
+                                                                       <text>2</text>
+                                                               </attribute>
+                                                               <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </element>
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </element>
-                                                       </when>
-                                                       <when test="starts-with($text, '✠') and &sigiled-text;">
-                                                               <element name="html:h4">
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '▪') and &sigiled-text;">
+                                                       <element name="li" namespace="&xhtml;">
+                                                               <attribute name="class">
+                                                                       <text>unordered</text>
+                                                               </attribute>
+                                                               <attribute name="data-level">
+                                                                       <text>3</text>
+                                                               </attribute>
+                                                               <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </element>
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </element>
-                                                       </when>
-                                                       <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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
-                                                               </element>
-                                                       </when>
-                                                       <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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
-                                                               </element>
-                                                       </when>
-                                                       <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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
-                                                               </element>
-                                                       </when>
-                                                       <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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
-                                                               </element>
-                                                       </when>
-                                                       <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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
-                                                               </element>
-                                                       </when>
-                                                       <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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
-                                                               </element>
-                                                       </when>
-                                                       <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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
-                                                               </element>
-                                                       </when>
-                                                       <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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '🔡') and &sigiled-text;">
+                                                       <element name="li" namespace="&xhtml;">
+                                                               <attribute name="class">
+                                                                       <text>ordered</text>
+                                                               </attribute>
+                                                               <attribute name="data-level">
+                                                                       <text>3</text>
+                                                               </attribute>
+                                                               <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="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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '⁃') and &sigiled-text;">
+                                                       <element name="li" namespace="&xhtml;">
+                                                               <attribute name="class">
+                                                                       <text>unordered</text>
+                                                               </attribute>
+                                                               <attribute name="data-level">
+                                                                       <text>4</text>
+                                                               </attribute>
+                                                               <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="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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '🔣') and &sigiled-text;">
+                                                       <element name="li" namespace="&xhtml;">
+                                                               <attribute name="class">
+                                                                       <text>ordered</text>
+                                                               </attribute>
+                                                               <attribute name="data-level">
+                                                                       <text>4</text>
+                                                               </attribute>
+                                                               <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="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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '🛈') and &sigiled-text;">
+                                                       <element name="div" namespace="&xhtml;">
+                                                               <attribute name="role">
+                                                                       <text>note</text>
+                                                               </attribute>
+                                                               <attribute name="class">
+                                                                       <text>info</text>
+                                                               </attribute>
+                                                               <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="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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '⯑') and &sigiled-text;">
+                                                       <element name="div" namespace="&xhtml;">
+                                                               <attribute name="role">
+                                                                       <text>note</text>
+                                                               </attribute>
+                                                               <attribute name="class">
+                                                                       <text>query</text>
+                                                               </attribute>
+                                                               <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="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">
-                                                                                       <with-param name="source" select="&unsigiled-text;"/>
-                                                                               </call-template>
-                                                                       </element>
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '⚠︎') and &sigiled-text;">
+                                                       <element name="div" namespace="&xhtml;">
+                                                               <attribute name="role">
+                                                                       <text>note</text>
+                                                               </attribute>
+                                                               <attribute name="class">
+                                                                       <text>warn</text>
+                                                               </attribute>
+                                                               <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="html:div">
-                                                                       <attribute name="class">
-                                                                               <text>continuation</text>
-                                                                       </attribute>
-                                                                       <element name="html:p">
-                                                                               <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="div" namespace="&xhtml;">
+                                                               <attribute name="role">
+                                                                       <text>note</text>
+                                                               </attribute>
+                                                               <attribute name="class">
+                                                                       <text>note</text>
+                                                               </attribute>
+                                                               <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;">
-                                                               <comment>
-                                                                       <value-of select="&unsigiled-text;"/>
-                                                               </comment>
-                                                       </when>
-                                                       <otherwise>
-                                                               <element name="html:p">
+                                                       </element>
+                                               </when>
+                                               <when test="starts-with($text, '☡') and &sigiled-text;">
+                                                       <element name="div" namespace="&xhtml;">
+                                                               <attribute name="role">
+                                                                       <text>note</text>
+                                                               </attribute>
+                                                               <attribute name="class">
+                                                                       <text>caution</text>
+                                                               </attribute>
+                                                               <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                        <call-template name="LesML:id-and-contents">
-                                                                               <with-param name="source" select="$text"/>
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </element>
                                                                        </call-template>
                                                                </element>
-                                                       </otherwise>
-                                               </choose>
-                                       </variable>
-                                       <choose>
-                                               <when test="translate(string($text), '&section-break; ', '')=''">
-                                                       <element name="html:hr"/>
+                                                       </element>
                                                </when>
                                                </when>
-                                               <when test="$quoted">
-                                                       <element name="html:blockquote">
-                                                               <copy-of select="$par"/>
+                                               <when test="starts-with($text, '⋯') and &sigiled-text;">
+                                                       <element name="div" namespace="&xhtml;">
+                                                               <processing-instruction name="LesML-Continuation"/>
+                                                               <element name="p" namespace="&xhtml;">
+                                                                       <call-template name="LesML:id-and-contents">
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
+                                                                       </call-template>
+                                                               </element>
                                                        </element>
                                                </when>
                                                        </element>
                                                </when>
+                                               <when test="starts-with($text, '#') and &sigiled-text;">
+                                                       <call-template name="LesML:comment-out">
+                                                               <with-param name="source" select="&unsigiled-text;"/>
+                                                       </call-template>
+                                               </when>
                                                <otherwise>
                                                <otherwise>
-                                                       <copy-of select="$par"/>
+                                                       <element name="p" namespace="&xhtml;">
+                                                               <call-template name="LesML:id-and-contents">
+                                                                       <with-param name="source" select="$text"/>
+                                                               </call-template>
+                                                       </element>
                                                </otherwise>
                                        </choose>
                                                </otherwise>
                                        </choose>
-                               </if>
-                       </for-each>
+                               </otherwise>
+                       </choose>
+               </for-each>
+       </template>
+       <template name="LesML:paragraphize">
+               <param name="lines" select="/.."/>
+               <variable name="blocked-fragment">
+                       <call-template name="LesML:block">
+                               <with-param name="lines" select="$lines"/>
+                       </call-template>
                </variable>
                </variable>
-               <variable name="inlined">
-                       <apply-templates select="exsl:node-set($blocked)/node()" mode="LesML:linkify"/>
+               <variable name="inlined-fragment">
+                       <apply-templates select="exsl:node-set($blocked-fragment)/node()" mode="LesML:comment"/>
                </variable>
                </variable>
-               <apply-templates select="exsl:node-set($inlined)/node()" mode="LesML:finalize-tree"/>
+               <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">
        </template>
        <template match="html:script[@type='text/lesml']">
                <variable name="lines-fragment">
@@ -637,62 +752,89 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                </with-param>
                        </call-template>
                </variable>
                                </with-param>
                        </call-template>
                </variable>
-               <call-template name="LesML:parse">
-                       <with-param name="lines" select="exsl:node-set($lines-fragment)/*"/>
-               </call-template>
+               <element name="div" namespace="&xhtml;">
+                       <call-template name="LesML:parse">
+                               <with-param name="lines" select="exsl:node-set($lines-fragment)/*"/>
+                       </call-template>
+               </element>
        </template>
        </template>
-       <template match="html:blockquote" mode="LesML:finalize-tree">
-               <if test="not(preceding-sibling::node()) or preceding-sibling::node()[position()=1 and not(self::html:blockquote)]">
-                       <variable name="notquote" select="following-sibling::node()[not(self::html:blockquote)][1]"/>
-                       <variable name="contents">
-                               <copy-of select="node()"/>
-                               <for-each select="following-sibling::node()[not($notquote) or following-sibling::node()[generate-id()=generate-id($notquote)]]">
-                                       <copy-of select="node()"/>
-                               </for-each>
-                       </variable>
-                       <variable name="content-nodes" select="exsl:node-set($contents)/node()"/>
-                       <variable name="laststarttext" select="$content-nodes[last()]/self::html:p[not(@class) and not(@role)]/node()[self::text() or self::*][position()=1 and self::text()]"/>
+       <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="LesML:attribute[preceding-sibling::node()[position()=1 and (self::text() or self::*)]]|text()[preceding-sibling::node()[position()=1 and self::*] and following-sibling::node()[position()=1 and self::LesML:attribute] and translate(., ' &#x9;', '')='']" mode="LesML:finalize-tree" priority="2"/>
+       <template match="LesML:attribute|text()[following-sibling::node()[position()=1 and self::LesML:attribute]]" mode="LesML:finalize-tree" priority="1">
+               <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>
+                       </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())])">
+                       <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
                        <choose>
                        <choose>
-                               <when test="starts-with($laststarttext, '— ')">
-                                       <variable name="caption">
-                                               <copy-of select="$laststarttext/preceding-sibling::node()"/>
-                                               <value-of select="substring-after($laststarttext, '— ')"/>
-                                               <copy-of select="$laststarttext/following-sibling::node()"/>
-                                       </variable>
-                                       <element name="html:figure">
+                               <when test="processing-instruction()[local-name()='LesML-Continuation'] and $notcontinuation[self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
+                                       <variable name="notcontinuation2" select="$notcontinuation/following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
+                                       <element name="hgroup" namespace="&xhtml;">
+                                               <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                               <for-each select="exslset:leading(following-sibling::node(), $notcontinuation2)">
+                                                       <choose>
+                                                               <when test="self::html:div">
+                                                                       <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                                               </when>
+                                                               <otherwise>
+                                                                       <copy>
+                                                                               <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+                                                                       </copy>
+                                                               </otherwise>
+                                                       </choose>
+                                               </for-each>
+                                       </element>
+                               </when>
+                               <otherwise>
+                                       <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>
+                               </otherwise>
+                       </choose>
+               </if>
+       </template>
+       <template match="html:h1|html:h2|html:h3|html:h4|html:h5|html:h6" mode="LesML:finalize-tree">
+               <if test="not(preceding-sibling::node()[position()=1 and self::html:div/processing-instruction()[local-name()='LesML-Continuation']]) or preceding-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][position()=1 and self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
+                       <choose>
+                               <when test="following-sibling::node()[position()=1 and self::html:div]/processing-instruction()[local-name()='LesML-Continuation']">
+                                       <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
+                                       <element name="hgroup" namespace="&xhtml;">
                                                <copy>
                                                <copy>
-                                                       <apply-templates select="@*|$content-nodes[position()!=last()]" mode="LesML:finalize-tree"/>
+                                                       <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
                                                </copy>
                                                </copy>
-                                               <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>
-                                               </element>
+                                               <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
+                                                       <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                               </for-each>
                                        </element>
                                </when>
                                <otherwise>
                                        <copy>
                                        </element>
                                </when>
                                <otherwise>
                                        <copy>
-                                               <apply-templates select="@*|$content-nodes" mode="LesML:finalize-tree"/>
+                                               <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
                                        </copy>
                                </otherwise>
                        </choose>
                </if>
        </template>
                                        </copy>
                                </otherwise>
                        </choose>
                </if>
        </template>
-       <template match="html:div" mode="LesML:finalize-tree">
-               <if test="not(@class='continuation') or not(preceding-sibling::node()) or preceding-sibling::node()[position()=1 and not(self::html:div or self::html:li)]">
-                       <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div and @class='continuation')][1]"/>
-                       <copy>
-                               <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
-                               <for-each select="following-sibling::node()[not($notcontinuation) or following-sibling::node()[generate-id()=generate-id($notcontinuation)]]">
-                                       <apply-templates select="node()" mode="LesML:finalize-tree"/>
-                               </for-each>
-                       </copy>
-               </if>
-       </template>
        <template match="html:li" mode="LesML:finalize-tree">
        <template match="html:li" mode="LesML:finalize-tree">
-               <if test="not(preceding-sibling::node()) or preceding-sibling::node()[not(preceding-sibling::* and self::html:div and @class='continuation')][position()=1 and not(self::html:li)]">
+               <if test="not(preceding-sibling::node()) or preceding-sibling::node()[not(preceding-sibling::* and self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][position()=1 and not(self::html:li)]">
                        <apply-templates select="." mode="LesML:finalize-list"/>
                </if>
        </template>
                        <apply-templates select="." mode="LesML:finalize-list"/>
                </if>
        </template>
@@ -710,13 +852,13 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                </otherwise>
                        </choose>
                </variable>
                                </otherwise>
                        </choose>
                </variable>
-               <variable name="notinlist" select="following-sibling::node()[not(self::html:div and @class='continuation' or self::html:li and (@data-level>$current-level or @data-level=$current-level and @class=$current-class))][1]"/>
-               <element name="html:{$wrapper}" namespace="http://www.w3.org/1999/xhtml">
-                       <for-each select=".|following-sibling::html:li[@data-level=$current-level and (not($notinlist) or following-sibling::node()[generate-id()=generate-id($notinlist)])]">
-                               <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div and @class='continuation')][1]"/>
+               <variable name="notinlist" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'] or self::html:li and (@data-level>$current-level or @data-level=$current-level and @class=$current-class))][1]"/>
+               <element name="{$wrapper}" namespace="&xhtml;">
+                       <for-each select=".|exslset:leading(following-sibling::node(), $notinlist)[self::html:li and @data-level=$current-level]">
+                               <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"/>
                                <copy>
                                        <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
-                                       <for-each select="following-sibling::node()[not($notcontinuation) or following-sibling::node()[generate-id()=generate-id($notcontinuation)]]">
+                                       <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
                                                <apply-templates select="node()" mode="LesML:finalize-tree"/>
                                        </for-each>
                                        <if test="$notcontinuation/self::html:li[@data-level>$current-level]">
                                                <apply-templates select="node()" mode="LesML:finalize-tree"/>
                                        </for-each>
                                        <if test="$notcontinuation/self::html:li[@data-level>$current-level]">
@@ -733,8 +875,9 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        </apply-templates>
                </if>
        </template>
                        </apply-templates>
                </if>
        </template>
-       <template match="processing-instruction()[local-name()='LesML-Link-Escape']" mode="LesML:finalize-tree">
-               <text>🔗</text>
+       <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">
        </template>
        <template match="text()" mode="LesML:finalize-tree">
                <call-template name="LesML:break-and-unescape">
@@ -743,16 +886,89 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        </template>
        <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
                <copy>
        </template>
        <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
                <copy>
-                       <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+                       <apply-templates select="." mode="LesML:finalize-attributes"/>
+                       <apply-templates select="node()" mode="LesML:finalize-tree"/>
                </copy>
        </template>
                </copy>
        </template>
+       <template match="node()" mode="LesML:comment">
+               <variable name="result">
+                       <choose>
+                               <when test="self::*">
+                                       <variable name="start-node" select="text()[contains(., '⌦')][1]"/>
+                                       <variable name="after-start">
+                                               <if test="$start-node">
+                                                       <value-of select="substring-after($start-node, '⌦')"/>
+                                               </if>
+                                       </variable>
+                                       <variable name="has-end-node" select="contains($after-start, '⌫') or $start-node/following-sibling::text()[contains(., '⌫')]"/>
+                                       <choose>
+                                               <when test="$start-node and $has-end-node">
+                                                       <variable name="following">
+                                                               <value-of select="$after-start"/>
+                                                               <copy-of select="$start-node/following-sibling::node()"/>
+                                                       </variable>
+                                                       <variable name="end-node" select="exsl:node-set($following)/text()[contains(., '⌫')][last()]"/>
+                                                       <variable name="comment">
+                                                               <for-each select="$end-node/preceding-sibling::node()">
+                                                                       <value-of select="."/>
+                                                               </for-each>
+                                                               <value-of select="substring-before($end-node, '⌫')"/>
+                                                       </variable>
+                                                       <variable name="rest-fragment">
+                                                               <element name="span" namespace="&xhtml;">
+                                                                       <value-of select="substring-after($end-node, '⌫')"/>
+                                                                       <copy-of select="$end-node/following-sibling::node()"/>
+                                                               </element>
+                                                       </variable>
+                                                       <variable name="commented-rest-fragment">
+                                                               <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:comment"/>
+                                                       </variable>
+                                                       <copy>
+                                                               <copy-of select="@*"/>
+                                                               <copy-of select="$start-node/preceding-sibling::node()"/>
+                                                               <copy-of select="substring-before($start-node, '⌦')"/>
+                                                               <call-template name="LesML:comment-out">
+                                                                       <with-param name="source" select="string($comment)"/>
+                                                               </call-template>
+                                                               <copy-of select="exsl:node-set($commented-rest-fragment)/*/node()"/>
+                                                       </copy>
+                                               </when>
+                                               <otherwise>
+                                                       <copy>
+                                                               <copy-of select="@*"/>
+                                                               <apply-templates select="node()" mode="LesML:comment"/>
+                                                       </copy>
+                                               </otherwise>
+                                       </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()">
+                                               <value-of select="."/>
+                                               <if test="position()!=last()">
+                                                       <call-template name="LesML:comment-out"/>
+                                               </if>
+                                       </for-each>
+                               </when>
+                               <otherwise>
+                                       <copy-of select="."/>
+                               </otherwise>
+                       </choose>
+               </variable>
+               <apply-templates select="exsl:node-set($result)/node()" mode="LesML:attrify"/>
+       </template>
        <template match="node()" mode="LesML:inline">
                <param name="element-name"/>
                <param name="element-namespace" select="'http://www.w3.org/1999/xhtml'"/>
                <param name="start-sigil"/>
                <param name="end-sigil"/>
        <template match="node()" mode="LesML:inline">
                <param name="element-name"/>
                <param name="element-namespace" select="'http://www.w3.org/1999/xhtml'"/>
                <param name="start-sigil"/>
                <param name="end-sigil"/>
+               <param name="class"/>
                <param name="role"/>
                <param name="role"/>
-               <param name="langtag-supported" select="false()"/>
                <choose>
                        <when test="self::*">
                                <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
                <choose>
                        <when test="self::*">
                                <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
@@ -764,17 +980,6 @@ 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="restoftext" select="substring-after($end-node, $end-sigil)"/>
-                                               <variable name="maybe-langtag">
-                                                       <if test="$langtag-supported and starts-with($restoftext, '@') and contains($restoftext, '$')">
-                                                               <value-of select="substring-before(substring-after($restoftext, '@'), '$')"/>
-                                                       </if>
-                                               </variable>
-                                               <variable name="langtag">
-                                                       <if test="translate($maybe-langtag, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-', '')=''">
-                                                               <value-of select="$maybe-langtag"/>
-                                                       </if>
-                                               </variable>
                                                <variable name="start-tokens-fragment">
                                                        <call-template name="LesML:split">
                                                                <with-param name="source" select="string($start-node)"/>
                                                <variable name="start-tokens-fragment">
                                                        <call-template name="LesML:split">
                                                                <with-param name="source" select="string($start-node)"/>
@@ -798,27 +1003,15 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                                        <value-of select="$role"/>
                                                                                </attribute>
                                                                        </if>
                                                                                        <value-of select="$role"/>
                                                                                </attribute>
                                                                        </if>
-                                                                       <if test="string($langtag)!=''">
-                                                                               <if test="$element-namespace='http://www.w3.org/1999/xhtml'">
-                                                                                       <attribute name="lang">
-                                                                                               <value-of select="$langtag"/>
-                                                                                       </attribute>
-                                                                               </if>
-                                                                               <attribute name="xml:lang">
-                                                                                       <value-of select="$langtag"/>
+                                                                       <if test="string($class)!=''">
+                                                                               <attribute name="class">
+                                                                                       <value-of select="$class"/>
                                                                                </attribute>
                                                                        </if>
                                                                        <value-of select="$start-tokens[last()]"/>
                                                                        <copy-of select="$start-node/following-sibling::node()"/>
                                                                </element>
                                                                                </attribute>
                                                                        </if>
                                                                        <value-of select="$start-tokens[last()]"/>
                                                                        <copy-of select="$start-node/following-sibling::node()"/>
                                                                </element>
-                                                               <choose>
-                                                                       <when test="string($langtag)!=''">
-                                                                               <value-of select="substring-after($restoftext, '$')"/>
-                                                                       </when>
-                                                                       <otherwise>
-                                                                               <value-of select="$restoftext"/>
-                                                                       </otherwise>
-                                                               </choose>
+                                                               <value-of select="substring-after($end-node, $end-sigil)"/>
                                                                <copy-of select="$end-node/following-sibling::node()"/>
                                                        </copy>
                                                </variable>
                                                                <copy-of select="$end-node/following-sibling::node()"/>
                                                        </copy>
                                                </variable>
@@ -828,7 +1021,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                        <with-param name="start-sigil" select="$start-sigil"/>
                                                        <with-param name="end-sigil" select="$end-sigil"/>
                                                        <with-param name="role" select="$role"/>
                                                        <with-param name="start-sigil" select="$start-sigil"/>
                                                        <with-param name="end-sigil" select="$end-sigil"/>
                                                        <with-param name="role" select="$role"/>
-                                                       <with-param name="langtag-supported" select="$langtag-supported"/>
                                                </apply-templates>
                                        </when>
                                        <otherwise>
                                                </apply-templates>
                                        </when>
                                        <otherwise>
@@ -840,7 +1032,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                <with-param name="start-sigil" select="$start-sigil"/>
                                                                <with-param name="end-sigil" select="$end-sigil"/>
                                                                <with-param name="role" select="$role"/>
                                                                <with-param name="start-sigil" select="$start-sigil"/>
                                                                <with-param name="end-sigil" select="$end-sigil"/>
                                                                <with-param name="role" select="$role"/>
-                                                               <with-param name="langtag-supported" select="$langtag-supported"/>
                                                        </apply-templates>
                                                </copy>
                                        </otherwise>
                                                        </apply-templates>
                                                </copy>
                                        </otherwise>
@@ -851,110 +1042,261 @@ 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 match="node()" mode="LesML:linkify">
+       <template match="*" mode="LesML:partition">
+               <param name="start-sigil"/>
+               <param name="end-sigil"/>
+               <param name="separator"/>
+               <param name="ncname-keys" select="false()"/>
+               <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
+               <variable name="has-start-node" select="$end-node/preceding-sibling::text()[contains(., $start-sigil) and not(following-sibling::* or following-sibling::comment())] or string-length(substring-after($end-node, $start-sigil))>string-length(substring-after($end-node, $end-sigil))"/>
+               <choose>
+                       <when test="$end-node and $has-start-node">
+                               <variable name="preceding">
+                                       <copy-of select="$end-node/preceding-sibling::node()"/>
+                                       <value-of select="substring-before($end-node, $end-sigil)"/>
+                               </variable>
+                               <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., $start-sigil) and not(following-sibling::*)][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="innards">
+                                       <value-of select="$start-tokens[last()]"/>
+                                       <for-each select="$start-node/following-sibling::node()">
+                                               <value-of select="."/>
+                                       </for-each>
+                               </variable>
+                               <choose>
+                                       <when test="contains($innards, $separator)">
+                                               <variable name="keyval-fragment">
+                                                       <call-template name="LesML:split">
+                                                               <with-param name="source" select="$innards"/>
+                                                               <with-param name="separator" select="$separator"/>
+                                                       </call-template>
+                                               </variable>
+                                               <variable name="keyval" select="exsl:node-set($keyval-fragment)/*"/>
+                                               <variable name="key">
+                                                       <choose>
+                                                               <when test="$ncname-keys">
+                                                                       <value-of select="$keyval[1]"/>
+                                                               </when>
+                                                               <otherwise>
+                                                                       <for-each select="$keyval[position()!=last()]">
+                                                                               <value-of select="."/>
+                                                                               <if test="position()!=last()">
+                                                                                       <value-of select="$separator"/>
+                                                                               </if>
+                                                                       </for-each>
+                                                               </otherwise>
+                                                       </choose>
+                                               </variable>
+                                               <variable name="value">
+                                                       <choose>
+                                                               <when test="$ncname-keys">
+                                                                       <for-each select="$keyval[position()!=1]">
+                                                                               <value-of select="."/>
+                                                                               <if test="position()!=last()">
+                                                                                       <value-of select="$separator"/>
+                                                                               </if>
+                                                                       </for-each>
+                                                               </when>
+                                                               <otherwise>
+                                                                       <value-of select="$keyval[last()]"/>
+                                                               </otherwise>
+                                                       </choose>
+                                               </variable>
+                                               <choose>
+                                                       <when test="not($ncname-keys) or /self::node()[translate(normalize-space($key), ' /([,*', '')=string($key) and exsldyn:evaluate(concat('not(self::html:', $key, ')'))]">
+                                                               <element name="span" namespace="&xhtml;">
+                                                                       <copy-of select="$start-node/preceding-sibling::node()"/>
+                                                                       <for-each select="$start-tokens[position()!=last()]">
+                                                                               <value-of select="."/>
+                                                                               <if test="position()!=last()">
+                                                                                       <value-of select="$start-sigil"/>
+                                                                               </if>
+                                                                       </for-each>
+                                                               </element>
+                                                               <element name="span" namespace="&xhtml;">
+                                                                       <value-of select="$key"/>
+                                                               </element>
+                                                               <element name="span" namespace="&xhtml;">
+                                                                       <value-of select="$value"/>
+                                                               </element>
+                                                               <element name="span" namespace="&xhtml;">
+                                                                       <value-of select="substring-after($end-node, $end-sigil)"/>
+                                                                       <copy-of select="$end-node/following-sibling::node()"/>
+                                                               </element>
+                                                       </when>
+                                                       <otherwise>
+                                                               <element name="span" namespace="&xhtml;">
+                                                                       <copy-of select="$start-node/preceding-sibling::node()"/>
+                                                                       <for-each select="$start-tokens[position()!=last()]">
+                                                                               <value-of select="."/>
+                                                                               <if test="position()!=last()">
+                                                                                       <value-of select="$start-sigil"/>
+                                                                               </if>
+                                                                       </for-each>
+                                                                       <processing-instruction name="LesML-Token-Escape">
+                                                                               <value-of select="$start-sigil"/>
+                                                                       </processing-instruction>
+                                                                       <value-of select="$start-tokens[last()]"/>
+                                                                       <value-of select="$start-node/following-sibling::node()"/>
+                                                                       <value-of select="$end-sigil"/>
+                                                                       <value-of select="substring-after($end-node, $end-sigil)"/>
+                                                                       <copy-of select="$end-node/following-sibling::node()"/>
+                                                               </element>
+                                                       </otherwise>
+                                               </choose>
+                                       </when>
+                                       <otherwise>
+                                               <element name="span" namespace="&xhtml;">
+                                                       <copy-of select="$start-node/preceding-sibling::node()"/>
+                                                       <for-each select="$start-tokens[position()!=last()]">
+                                                               <value-of select="."/>
+                                                               <if test="position()!=last()">
+                                                                       <value-of select="$start-sigil"/>
+                                                               </if>
+                                                       </for-each>
+                                                       <processing-instruction name="LesML-Token-Escape">
+                                                               <value-of select="$start-sigil"/>
+                                                       </processing-instruction>
+                                                       <value-of select="$start-tokens[last()]"/>
+                                                       <value-of select="$start-node/following-sibling::node()"/>
+                                                       <value-of select="$end-sigil"/>
+                                                       <value-of select="substring-after($end-node, $end-sigil)"/>
+                                                       <copy-of select="$end-node/following-sibling::node()"/>
+                                               </element>
+                                       </otherwise>
+                               </choose>
+                       </when>
+                       <when test="$end-node">
+                               <element name="span" namespace="&xhtml;">
+                                       <copy-of select="$end-node/preceding-sibling::node()"/>
+                                       <value-of select="substring-before($end-node, $end-sigil)"/>
+                                       <processing-instruction name="LesML-Token-Escape">
+                                               <value-of select="$end-sigil"/>
+                                       </processing-instruction>
+                                       <value-of select="substring-after($end-node, $end-sigil)"/>
+                                       <copy-of select="$end-node/following-sibling::node()"/>
+                               </element>
+                       </when>
+                       <otherwise>
+                               <processing-instruction name="LesML-All-Done"/>
+                       </otherwise>
+               </choose>
+       </template>
+       <template match="node()" mode="LesML:attrify">
                <variable name="result">
                        <choose>
                                <when test="self::*">
                <variable name="result">
                        <choose>
                                <when test="self::*">
-                                       <variable name="end-node" select="text()[contains(., '>}')][1]"/>
-                                       <variable name="has-start-node" select="$end-node/preceding-sibling::text()[contains(., '{🔗') and not(following-sibling::*)] or string-length(substring-after($end-node, '{🔗'))>string-length(substring-after($end-node, '>}'))"/>
+                                       <variable name="partitioned-fragment">
+                                               <apply-templates mode="LesML:partition" select=".">
+                                                       <with-param name="start-sigil" select="'{@'"/>
+                                                       <with-param name="end-sigil" select="'&quot;}'"/>
+                                                       <with-param name="separator" select="'=&quot;'"/>
+                                                       <with-param name="ncname-keys" select="true()"/>
+                                               </apply-templates>
+                                       </variable>
+                                       <variable name="partitioned" select="exsl:node-set($partitioned-fragment)/node()"/>
                                        <choose>
                                        <choose>
-                                               <when test="$end-node and $has-start-node">
-                                                       <variable name="preceding">
-                                                               <copy-of select="$end-node/preceding-sibling::node()"/>
-                                                               <value-of select="substring-before($end-node, '>}')"/>
+                                               <when test="count($partitioned)>1">
+                                                       <variable name="processed">
+                                                               <copy>
+                                                                       <copy-of select="@*"/>
+                                                                       <copy-of select="$partitioned[1]/node()"/>
+                                                                       <element name="LesML:attribute" namespace="&LesML;">
+                                                                               <attribute name="{$partitioned[2]}">
+                                                                                       <value-of select="$partitioned[3]"/>
+                                                                               </attribute>
+                                                                       </element>
+                                                                       <copy-of select="$partitioned[4]/node()"/>
+                                                               </copy>
                                                        </variable>
                                                        </variable>
-                                                       <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., '{🔗') and not(following-sibling::*)][last()]"/>
-                                                       <variable name="start-tokens-fragment">
-                                                               <call-template name="LesML:split">
-                                                                       <with-param name="source" select="string($start-node)"/>
-                                                                       <with-param name="separator" select="'{🔗'"/>
-                                                               </call-template>
+                                                       <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:attrify"/>
+                                               </when>
+                                               <when test="$partitioned[self::processing-instruction() and local-name()='LesML-All-Done']">
+                                                       <copy>
+                                                               <copy-of select="@*"/>
+                                                               <apply-templates select="node()" mode="LesML:attrify"/>
+                                                       </copy>
+                                               </when>
+                                               <otherwise>
+                                                       <variable name="processed">
+                                                               <copy>
+                                                                       <copy-of select="@*"/>
+                                                                       <copy-of select="$partitioned/node()"/>
+                                                               </copy>
                                                        </variable>
                                                        </variable>
-                                                       <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
-                                                       <variable name="hyperlink">
-                                                               <value-of select="$start-tokens[last()]"/>
-                                                               <for-each select="$start-node/following-sibling::node()">
-                                                                       <choose>
-                                                                               <when test="self::text()">
-                                                                                       <value-of select="."/>
-                                                                               </when>
-                                                                               <when test="self::processing-instruction()[local-name()='LesML-Link-Escape']">
-                                                                                       <text>🔗</text>
-                                                                               </when>
-                                                                       </choose>
-                                                               </for-each>
+                                                       <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:attrify"/>
+                                               </otherwise>
+                                       </choose>
+                               </when>
+                               <otherwise>
+                                       <copy-of select="."/>
+                               </otherwise>
+                       </choose>
+               </variable>
+               <apply-templates select="exsl:node-set($result)/node()" mode="LesML:linkify"/>
+       </template>
+       <template match="node()" mode="LesML:linkify">
+               <variable name="result">
+                       <choose>
+                               <when test="processing-instruction()[local-name()='LesML-All-Done']">
+                                       <copy>
+                                               <copy-of select="@*|node()[not(self::processing-instruction() and local-name()='LesML-All-Done')]"/>
+                                       </copy>
+                               </when>
+                               <when test="self::*">
+                                       <variable name="partitioned-fragment">
+                                               <apply-templates mode="LesML:partition" select=".">
+                                                       <with-param name="start-sigil" select="'{🔗'"/>
+                                                       <with-param name="end-sigil" select="'>}'"/>
+                                                       <with-param name="separator" select="'&lt;'"/>
+                                               </apply-templates>
+                                       </variable>
+                                       <variable name="partitioned" select="exsl:node-set($partitioned-fragment)/node()"/>
+                                       <choose>
+                                               <when test="count($partitioned)>1">
+                                                       <variable name="processed">
+                                                               <copy>
+                                                                       <copy-of select="@*"/>
+                                                                       <copy-of select="$partitioned[1]/node()"/>
+                                                                       <element name="a" namespace="&xhtml;">
+                                                                               <attribute name="href">
+                                                                                       <value-of select="$partitioned[3]"/>
+                                                                               </attribute>
+                                                                               <processing-instruction name="LesML-All-Done"/>
+                                                                               <choose>
+                                                                                       <when test="string($partitioned[2])=''">
+                                                                                               <value-of select="$partitioned[3]"/>
+                                                                                       </when>
+                                                                                       <otherwise>
+                                                                                               <value-of select="$partitioned[2]"/>
+                                                                                       </otherwise>
+                                                                               </choose>
+                                                                       </element>
+                                                                       <copy-of select="$partitioned[4]/node()"/>
+                                                               </copy>
                                                        </variable>
                                                        </variable>
-                                                       <choose>
-                                                               <when test="contains($hyperlink, '&lt;')">
-                                                                       <variable name="ltcomponents-fragment">
-                                                                               <call-template name="LesML:split">
-                                                                                       <with-param name="source" select="$hyperlink"/>
-                                                                                       <with-param name="separator" select="'&lt;'"/>
-                                                                               </call-template>
-                                                                       </variable>
-                                                                       <variable name="ltcomponents" select="exsl:node-set($ltcomponents-fragment)/*"/>
-                                                                       <variable name="wrapped">
-                                                                               <copy>
-                                                                                       <copy-of select="@*"/>
-                                                                                       <copy-of select="$start-node/preceding-sibling::node()"/>
-                                                                                       <for-each select="$start-tokens[position()!=last()]">
-                                                                                               <value-of select="."/>
-                                                                                               <if test="position()!=last()">
-                                                                                                       <text>{🔗</text>
-                                                                                               </if>
-                                                                                       </for-each>
-                                                                                       <element name="html:a">
-                                                                                               <attribute name="href">
-                                                                                                       <value-of select="$ltcomponents[last()]"/>
-                                                                                               </attribute>
-                                                                                               <choose>
-                                                                                                       <when test="count($ltcomponents)>2 or normalize-space($ltcomponents[1])!=''">
-                                                                                                               <for-each select="$ltcomponents[position()!=last()]">
-                                                                                                                       <value-of select="."/>
-                                                                                                                       <if test="position()!=last()">
-                                                                                                                               <text>&lt;</text>
-                                                                                                                       </if>
-                                                                                                               </for-each>
-                                                                                                       </when>
-                                                                                                       <otherwise>
-                                                                                                               <value-of select="$ltcomponents[last()]"/>
-                                                                                                       </otherwise>
-                                                                                               </choose>
-                                                                                       </element>
-                                                                                       <value-of select="substring-after($end-node, '>}')"/>
-                                                                                       <copy-of select="$end-node/following-sibling::node()"/>
-                                                                               </copy>
-                                                                       </variable>
-                                                                       <apply-templates select="exsl:node-set($wrapped)/*" mode="LesML:linkify"/>
-                                                               </when>
-                                                               <otherwise>
-                                                                       <variable name="escaped">
-                                                                               <copy>
-                                                                                       <copy-of select="@*"/>
-                                                                                       <copy-of select="$start-node/preceding-sibling::node()"/>
-                                                                                       <for-each select="$start-tokens[position()!=last()]">
-                                                                                               <value-of select="."/>
-                                                                                               <if test="position()!=last()">
-                                                                                                       <text>{🔗</text>
-                                                                                               </if>
-                                                                                       </for-each>
-                                                                                       <text>{</text>
-                                                                                       <processing-instruction name="LesML-Link-Escape"/>
-                                                                                       <copy-of select="$hyperlink"/>
-                                                                                       <text>>}</text>
-                                                                                       <value-of select="substring-after($end-node, '>}')"/>
-                                                                                       <copy-of select="$end-node/following-sibling::node()"/>
-                                                                               </copy>
-                                                                       </variable>
-                                                                       <apply-templates select="exsl:node-set($escaped)/*" mode="LesML:linkify"/>
-                                                               </otherwise>
-                                                       </choose>
+                                                       <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:linkify"/>
                                                </when>
                                                </when>
-                                               <otherwise>
+                                               <when test="$partitioned[self::processing-instruction() and local-name()='LesML-All-Done']">
                                                        <copy>
                                                                <copy-of select="@*"/>
                                                                <apply-templates select="node()" mode="LesML:linkify"/>
                                                        </copy>
                                                        <copy>
                                                                <copy-of select="@*"/>
                                                                <apply-templates select="node()" mode="LesML:linkify"/>
                                                        </copy>
+                                               </when>
+                                               <otherwise>
+                                                       <variable name="processed">
+                                                               <copy>
+                                                                       <copy-of select="@*"/>
+                                                                       <copy-of select="$partitioned/node()"/>
+                                                               </copy>
+                                                       </variable>
+                                                       <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:linkify"/>
                                                </otherwise>
                                        </choose>
                                </when>
                                                </otherwise>
                                        </choose>
                                </when>
@@ -968,7 +1310,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        <template match="node()" mode="LesML:strikethrough">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
        <template match="node()" mode="LesML:strikethrough">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
-                               <with-param name="element-name" select="'html:s'"/>
+                               <with-param name="element-name" select="'s'"/>
+                               <with-param name="element-namespace" select="'&xhtml;'"/>
                                <with-param name="start-sigil" select="'⸠'"/>
                                <with-param name="end-sigil" select="'⸡'"/>
                        </apply-templates>
                                <with-param name="start-sigil" select="'⸠'"/>
                                <with-param name="end-sigil" select="'⸡'"/>
                        </apply-templates>
@@ -978,7 +1321,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        <template match="node()" mode="LesML:underline">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
        <template match="node()" mode="LesML:underline">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
-                               <with-param name="element-name" select="'html:u'"/>
+                               <with-param name="element-name" select="'u'"/>
+                               <with-param name="element-namespace" select="'&xhtml;'"/>
                                <with-param name="start-sigil" select="'⸤'"/>
                                <with-param name="end-sigil" select="'⸥'"/>
                        </apply-templates>
                                <with-param name="start-sigil" select="'⸤'"/>
                                <with-param name="end-sigil" select="'⸥'"/>
                        </apply-templates>
@@ -988,7 +1332,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        <template match="node()" mode="LesML:noted">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
        <template match="node()" mode="LesML:noted">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
-                               <with-param name="element-name" select="'html:small'"/>
+                               <with-param name="element-name" select="'small'"/>
+                               <with-param name="element-namespace" select="'&xhtml;'"/>
                                <with-param name="start-sigil" select="'⟦'"/>
                                <with-param name="end-sigil" select="'⟧'"/>
                                <with-param name="role" select="'note'"/>
                                <with-param name="start-sigil" select="'⟦'"/>
                                <with-param name="end-sigil" select="'⟧'"/>
                                <with-param name="role" select="'note'"/>
@@ -999,7 +1344,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        <template match="node()" mode="LesML:parenthetical">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
        <template match="node()" mode="LesML:parenthetical">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
-                               <with-param name="element-name" select="'html:small'"/>
+                               <with-param name="element-name" select="'small'"/>
+                               <with-param name="element-namespace" select="'&xhtml;'"/>
                                <with-param name="start-sigil" select="'⸨'"/>
                                <with-param name="end-sigil" select="'⸩'"/>
                        </apply-templates>
                                <with-param name="start-sigil" select="'⸨'"/>
                                <with-param name="end-sigil" select="'⸩'"/>
                        </apply-templates>
@@ -1009,7 +1355,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        <template match="node()" mode="LesML:code">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
        <template match="node()" mode="LesML:code">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
-                               <with-param name="element-name" select="'html:code'"/>
+                               <with-param name="element-name" select="'code'"/>
+                               <with-param name="element-namespace" select="'&xhtml;'"/>
                                <with-param name="start-sigil" select="'`'"/>
                                <with-param name="end-sigil" select="'´'"/>
                        </apply-templates>
                                <with-param name="start-sigil" select="'`'"/>
                                <with-param name="end-sigil" select="'´'"/>
                        </apply-templates>
@@ -1019,20 +1366,33 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        <template match="node()" mode="LesML:titled">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
        <template match="node()" mode="LesML:titled">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
-                               <with-param name="element-name" select="'html:cite'"/>
+                               <with-param name="element-name" select="'cite'"/>
+                               <with-param name="element-namespace" select="'&xhtml;'"/>
                                <with-param name="start-sigil" select="'⟪'"/>
                                <with-param name="end-sigil" select="'⟫'"/>
                        </apply-templates>
                </variable>
                                <with-param name="start-sigil" select="'⟪'"/>
                                <with-param name="end-sigil" select="'⟫'"/>
                        </apply-templates>
                </variable>
+               <apply-templates select="exsl:node-set($result)/node()" mode="LesML:named"/>
+       </template>
+       <template match="node()" mode="LesML:named">
+               <variable name="result">
+                       <apply-templates select="." mode="LesML:inline">
+                               <with-param name="element-name" select="'u'"/>
+                               <with-param name="element-namespace" select="'&xhtml;'"/>
+                               <with-param name="start-sigil" select="'⸶'"/>
+                               <with-param name="end-sigil" select="'⸷'"/>
+                               <with-param name="class" select="'name'"/>
+                       </apply-templates>
+               </variable>
                <apply-templates select="exsl:node-set($result)/node()" mode="LesML:offset"/>
        </template>
        <template match="node()" mode="LesML:offset">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
                <apply-templates select="exsl:node-set($result)/node()" mode="LesML:offset"/>
        </template>
        <template match="node()" mode="LesML:offset">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
-                               <with-param name="element-name" select="'html:i'"/>
+                               <with-param name="element-name" select="'i'"/>
+                               <with-param name="element-namespace" select="'&xhtml;'"/>
                                <with-param name="start-sigil" select="'⟨'"/>
                                <with-param name="end-sigil" select="'⟩'"/>
                                <with-param name="start-sigil" select="'⟨'"/>
                                <with-param name="end-sigil" select="'⟩'"/>
-                               <with-param name="langtag-supported" select="true()"/>
                        </apply-templates>
                </variable>
                <apply-templates select="exsl:node-set($result)/node()" mode="LesML:bolded"/>
                        </apply-templates>
                </variable>
                <apply-templates select="exsl:node-set($result)/node()" mode="LesML:bolded"/>
@@ -1040,7 +1400,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        <template match="node()" mode="LesML:bolded">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
        <template match="node()" mode="LesML:bolded">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
-                               <with-param name="element-name" select="'html:b'"/>
+                               <with-param name="element-name" select="'b'"/>
+                               <with-param name="element-namespace" select="'&xhtml;'"/>
                                <with-param name="start-sigil" select="'⦃'"/>
                                <with-param name="end-sigil" select="'⦄'"/>
                        </apply-templates>
                                <with-param name="start-sigil" select="'⦃'"/>
                                <with-param name="end-sigil" select="'⦄'"/>
                        </apply-templates>
@@ -1050,7 +1411,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        <template match="node()" mode="LesML:important">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
        <template match="node()" mode="LesML:important">
                <variable name="result">
                        <apply-templates select="." mode="LesML:inline">
-                               <with-param name="element-name" select="'html:strong'"/>
+                               <with-param name="element-name" select="'strong'"/>
+                               <with-param name="element-namespace" select="'&xhtml;'"/>
                                <with-param name="start-sigil" select="'☞'"/>
                                <with-param name="end-sigil" select="'☜'"/>
                        </apply-templates>
                                <with-param name="start-sigil" select="'☞'"/>
                                <with-param name="end-sigil" select="'☜'"/>
                        </apply-templates>
@@ -1059,7 +1421,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        </template>
        <template match="node()" mode="LesML:emphasized">
                <apply-templates select="." mode="LesML:inline">
        </template>
        <template match="node()" mode="LesML:emphasized">
                <apply-templates select="." mode="LesML:inline">
-                       <with-param name="element-name" select="'html:em'"/>
+                       <with-param name="element-name" select="'em'"/>
+                       <with-param name="element-namespace" select="'&xhtml;'"/>
                        <with-param name="start-sigil" select="'⹐'"/>
                        <with-param name="end-sigil" select="'⹑'"/>
                </apply-templates>
                        <with-param name="start-sigil" select="'⹐'"/>
                        <with-param name="end-sigil" select="'⹑'"/>
                </apply-templates>
This page took 0.315553 seconds and 4 git commands to generate.