3 SPDX-FileCopyrightText: 2024, 2025 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
7 ⁌ 💄📝 Les·M·L ∷ parser.xslt
9 © 2024–2025 Lady [@ Ladys Computer]
11 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
12 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/>.
15 <!ENTITY LesML "urn:fdc:ladys.computer:20240512:LesML">
16 <!ENTITY section-break "">
17 <!ENTITY sigiled-text "(string-length($text)=1 or substring($text, 2, 1)=' ' or substring($text, 2, 1)='¶')">
18 <!ENTITY unsigiled-text "concat(translate(substring($text, 2, 1), ' ', ''), substring($text, 3, string-length($text)-2))">
19 <!ENTITY xhtml "http://www.w3.org/1999/xhtml">
22 xmlns="http://www.w3.org/1999/XSL/Transform"
23 xmlns:LesML="urn:fdc:ladys.computer:20240512:LesML"
24 xmlns:exsl="http://exslt.org/common"
25 xmlns:exsldyn="http://exslt.org/dynamic"
26 xmlns:exslset="http://exslt.org/sets"
27 xmlns:exslstr="http://exslt.org/strings"
28 xmlns:html="http://www.w3.org/1999/xhtml"
29 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
30 exclude-result-prefixes="LesML"
31 extension-element-prefixes="exsl exsldyn exslset exslstr"
34 <书社:id>urn:fdc:ladys.computer:20240512:LesML:parser.xslt</书社:id>
35 <param name="LESML_SECTION_BREAK_CHARS" select="'*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~'"/>
36 <template name="LesML:split">
37 <param name="source"/>
38 <param name="separator" select="'
'"/>
40 <when test="contains($source, $separator)">
42 <value-of select="substring-before($source, $separator)"/>
44 <call-template name="LesML:split">
45 <with-param name="source" select="substring-after($source, $separator)"/>
46 <with-param name="separator" select="$separator"/>
51 <value-of select="$source"/>
56 <template name="LesML:break-and-unescape">
57 <param name="source"/>
58 <variable name="broken-fragment">
59 <call-template name="LesML:split">
60 <with-param name="source" select="$source"/>
61 <with-param name="separator" select="'
'"/>
64 <variable name="broken" select="exsl:node-set($broken-fragment)/node()"/>
65 <for-each select="$broken">
66 <call-template name="LesML:unescape">
67 <with-param name="source" select="string()"/>
69 <if test="position()!=count($broken)">
70 <element name="br" namespace="&xhtml;"/>
74 <template name="LesML:unescape">
75 <param name="source"/>
77 <when test="contains($source, '{U+')">
78 <variable name="after" select="substring-after($source, '{U+')"/>
80 <when test="contains($after, '}')">
81 <variable name="inner" select="substring-before($after, '}')"/>
82 <variable name="components">
83 <call-template name="LesML:split">
84 <with-param name="source" select="$inner"/>
85 <with-param name="separator" select="'.'"/>
88 <variable name="component-nodes" select="exsl:node-set($components)/node()"/>
89 <value-of select="substring-before($source, '{U+')"/>
91 <when test="$component-nodes[string(.)='' or translate(., '0123456789ABCDEF', '')!='']">
93 <value-of select="$inner"/>
95 <call-template name="LesML:unescape">
96 <with-param name="source" select="substring-after($after, '}')"/>
100 <for-each select="$component-nodes">
101 <text disable-output-escaping="yes">&#x</text>
102 <value-of select="."/>
105 <call-template name="LesML:unescape">
106 <with-param name="source" select="substring-after($after, '}')"/>
112 <value-of select="substring-before($source, '{U+')"/>
114 <call-template name="LesML:unescape">
115 <with-param name="source" select="$after"/>
121 <value-of select="$source"/>
125 <template name="LesML:comment-out">
126 <param name="source"/>
127 <variable name="comment-split-fragment">
128 <call-template name="LesML:split">
129 <with-param name="source" select="$source"/>
130 <with-param name="separator" select="'--'"/>
134 <for-each select="exsl:node-set($comment-split-fragment)/*">
135 <if test="string()='' or starts-with(., '‐')">
136 <text>͏</text>
138 <value-of select="."/>
139 <if test="substring(., string-length(.), 1)='‐'">
140 <text>͏</text>
143 <when test="position()!=last()">
144 <text>-͏-</text>
150 <template name="LesML:id-and-contents">
151 <param name="source"/>
152 <variable name="id-and-lang">
153 <if test="starts-with($source, '¶')">
155 <when test="contains($source, ' ')">
156 <value-of select="substring-before(substring-after($source, '¶'), ' ')"/>
159 <value-of select="substring-after($source, '¶')"/>
164 <variable name="restoftext">
166 <when test="starts-with($source, '¶') and contains($source, ' ')">
167 <value-of select="substring-after($source, ' ')"/>
169 <when test="starts-with($source, '¶')"/>
171 <value-of select="$source"/>
175 <variable name="maybe-langtag">
176 <if test="substring($id-and-lang, string-length($id-and-lang), 1)='$' and contains($id-and-lang, '@')">
177 <variable name="split-tag-fragment">
178 <call-template name="LesML:split">
179 <with-param name="source" select="substring($id-and-lang, 2, string-length($id-and-lang)-2)"/>
180 <with-param name="separator" select="'@'"/>
183 <value-of select="exsl:node-set($split-tag-fragment)/*[last()]"/>
186 <variable name="langtag">
187 <if test="translate($maybe-langtag, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-', '')=''">
188 <value-of select="$maybe-langtag"/>
193 <when test="string($langtag)!=''">
194 <value-of select="substring($id-and-lang, 1, string-length($id-and-lang)-(string-length($langtag)+2))"/>
197 <value-of select="$id-and-lang"/>
201 <if test="string($id)!=''">
202 <attribute name="id">
203 <value-of select="$id"/>
206 <if test="string($langtag)!=''">
207 <attribute name="lang">
208 <value-of select="$langtag"/>
210 <attribute name="xml:lang">
211 <value-of select="$langtag"/>
214 <value-of select="$restoftext"/>
216 <template name="LesML:parse">
217 <param name="lines" select="/.."/>
218 <param name="parent-params" select="/.."/>
219 <variable name="first-line" select="$lines[1]"/>
220 <variable name="shebang">
221 <if test="starts-with($first-line, '#!lesml')">
222 <value-of select="$first-line"/>
225 <variable name="params-string">
227 <when test="starts-with($shebang, '#!lesml@')">
228 <value-of select="substring-after($shebang, '$')"/>
231 <value-of select="substring-after($shebang, '#!lesml')"/>
235 <variable name="params-fragment">
237 <when test="$shebang!=''">
239 <if test="starts-with($shebang, '#!lesml@') and contains($shebang, '$')">
245 <value-of select="substring-before(substring-after($shebang, '#!lesml@'), '$')"/>
249 <for-each select="exslstr:tokenize($params-string)">
251 <when test="contains(., '=')">
254 <value-of select="substring-before(., '=')"/>
257 <value-of select="substring-after(., '=')"/>
264 <value-of select="."/>
273 <when test="$parent-params">
274 <copy-of select="$parent-params"/>
281 <variable name="params" select="exsl:node-set($params-fragment)/*"/>
282 <variable name="noshebang" select="$lines[position()>1 or not(starts-with(., '#!lesml') or starts-with(., '##'))]"/>
283 <variable name="docsep" select="$noshebang[starts-with(., '#!lesml') or starts-with(., '##')][1]"/>
284 <variable name="doclines" select="exslset:leading($noshebang, $docsep)"/>
285 <if test="starts-with($first-line, '##') and $first-line!='##'">
286 <call-template name="LesML:comment-out">
287 <with-param name="source" select="substring-after($first-line, '##')"/>
290 <if test="$doclines[normalize-space()!='']">
291 <variable name="record-separators" select="$doclines[starts-with(., '%%')]"/>
292 <variable name="paragraphized-fragment">
293 <call-template name="LesML:paragraphize">
294 <with-param name="lines" select="exslset:trailing($doclines, $record-separators[last()])"/>
297 <variable name="paragraphized" select="exsl:node-set($paragraphized-fragment)"/>
298 <variable name="filtered-ordered-footnotes-fragment">
299 <for-each select="$paragraphized//html:li[processing-instruction()[local-name()='LesML-Footnote'] and html:p[position()=1 and @id]]">
300 <sort select="count(($paragraphized//html:a[@role='doc-noteref' and @href=concat('#', string(current()/html:p[1]/@id))])[1]/preceding::*)" data-type="number"/>
301 <if test="$paragraphized//html:a[@role='doc-noteref' and @href=concat('#', string(current()/html:p[1]/@id))]">
302 <copy-of select="."/>
306 <variable name="used-footnotes-fragment">
307 <for-each select="exsl:node-set($filtered-ordered-footnotes-fragment)/node()">
308 <variable name="links" select="$paragraphized//html:a[@role='doc-noteref' and @href=concat('#', string(current()/html:p[1]/@id))]"/>
309 <element name="li" namespace="&xhtml;">
310 <variable name="numero" select="position()"/>
311 <attribute name="id">
312 <value-of select="html:p[1]/@id"/>
314 <attribute name="value">
315 <value-of select="$numero"/>
317 <copy-of select="@*|node()"/>
318 <element name="footer" namespace="&xhtml;">
319 <attribute name="class">
320 <text>backlinks</text>
322 <for-each select="$links[@id]">
323 <if test="position()>1">
326 <element name="a" namespace="&xhtml;">
327 <attribute name="role">
328 <text>doc-backlink</text>
330 <attribute name="href">
332 <value-of select="@id"/>
334 <value-of select="position()"/>
341 <variable name="used-footnote-nodes" select="exsl:node-set($used-footnotes-fragment)/node()"/>
342 <element name="article" namespace="&xhtml;">
343 <for-each select="$params/html:div/html:dt[string()=' LANG ']">
344 <attribute name="lang">
345 <value-of select="following-sibling::html:dd"/>
347 <attribute name="xml:lang">
348 <value-of select="following-sibling::html:dd"/>
351 <for-each select="$params/html:div/html:dt[string()='profile']">
352 <attribute name="data-lesml-profile">
353 <value-of select="following-sibling::html:dd"/>
356 <if test="$record-separators[preceding-sibling::*[normalize-space()!='']]">
357 <element name="footer" namespace="&xhtml;">
358 <attribute name="class">
361 <for-each select="$record-separators">
362 <variable name="position" select="position()"/>
363 <variable name="prev-separator" select="$record-separators[($position)-1]"/>
364 <variable name="fields" select="exslset:leading(exslset:trailing($doclines, $prev-separator), .)"/>
366 <element name="dl" namespace="&xhtml;">
367 <for-each select="$fields">
369 <when test="starts-with(., ' ') and exslset:leading($fields, .)"/>
371 <variable name="next" select="exslset:intersection(following-sibling::*[not(starts-with(., ' '))][1], $fields)"/>
372 <element name="div" namespace="&xhtml;">
373 <element name="dt" namespace="&xhtml;">
374 <value-of select="normalize-space(substring-before(., ':'))"/>
376 <element name="dd" namespace="&xhtml;">
377 <variable name="firstline">
379 <when test="contains(., ':')">
380 <value-of select="normalize-space(substring-after(., ':'))"/>
383 <value-of select="normalize-space(.)"/>
388 <when test="substring($firstline, string-length($firstline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
389 <value-of select="substring($firstline, 1, string-length($firstline)-1)"/>
392 <value-of select="$firstline"/>
395 <for-each select="exslset:intersection(following-sibling::*[starts-with(., ' ')], exslset:leading($fields, $next))">
396 <variable name="nextline" select="normalize-space(.)"/>
398 <when test="substring($nextline, string-length($nextline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
399 <value-of select="substring($nextline, 1, string-length($nextline)-1)"/>
402 <value-of select="$nextline"/>
414 <call-template name="LesML:comment-out">
415 <with-param name="source" select="substring-after(., '%%')"/>
421 <element name="div" namespace="&xhtml;">
422 <attribute name="class">
425 <apply-templates select="$paragraphized/node()" mode="LesML:finalize-footnotes">
426 <with-param name="used-footnotes" select="$used-footnote-nodes"/>
429 <if test="$used-footnote-nodes">
430 <element name="section" namespace="&xhtml;">
431 <attribute name="role">
432 <text>doc-endnotes</text>
434 <element name="ol" namespace="&xhtml;">
435 <apply-templates select="$used-footnote-nodes" mode="LesML:finalize-footnotes">
436 <with-param name="used-footnotes" select="$used-footnote-nodes"/>
444 <call-template name="LesML:parse">
445 <with-param name="lines" select="$docsep|exslset:trailing($lines, $docsep)"/>
446 <with-param name="parent-params" select="$params"/>
450 <template name="LesML:block">
451 <param name="lines" select="/.."/>
452 <variable name="last-lines" select="$lines[normalize-space()!='' and (normalize-space(following-sibling::*[1])='' or position()=last())]"/>
453 <for-each select="$last-lines">
454 <variable name="position" select="position()"/>
455 <variable name="prev-last" select="$last-lines[($position)-1]"/>
456 <variable name="linespans" select="(exslset:intersection(exslset:trailing($lines, $prev-last), exslset:leading($lines, .))|.)[normalize-space()!='']"/>
457 <variable name="prefix" select="substring(translate(., ' 	', ''), 1, 1)"/>
458 <variable name="all-prefixed" select="not($linespans[not(starts-with(translate(., ' 	', ''), $prefix))])"/>
459 <variable name="quoted" select="$all-prefixed and $prefix='»'"/>
460 <variable name="bracketed" select="$all-prefixed and $prefix=']'"/>
462 <when test="count($linespans)=1 and translate(., concat($LESML_SECTION_BREAK_CHARS, ' 	'), '')=''">
463 <element name="hr" namespace="&xhtml;"/>
465 <when test="$quoted or $bracketed">
466 <variable name="innerlines-fragment">
467 <for-each select="$linespans">
468 <variable name="inner">
469 <value-of select="substring-after(., $prefix)"/>
473 <when test="starts-with($inner, ' ') or starts-with($inner, '	')">
474 <value-of select="substring($inner, 1+count(exslstr:tokenize($inner, '')[normalize-space()='' and not(preceding-sibling::*[normalize-space()!=''])]))"/>
477 <value-of select="$inner"/>
483 <variable name="blocked-fragment">
484 <call-template name="LesML:block">
485 <with-param name="lines" select="exsl:node-set($innerlines-fragment)/*"/>
488 <variable name="innerpars" select="exsl:node-set($blocked-fragment)/node()"/>
490 <when test="$quoted and $innerpars[position()=last() and self::html:footer]">
491 <element name="figure" namespace="&xhtml;">
492 <element name="blockquote" namespace="&xhtml;">
493 <copy-of select="$innerpars[position()!=last()]"/>
495 <element name="figcaption" namespace="&xhtml;">
496 <copy-of select="$innerpars[last()]/node()"/>
500 <when test="$quoted">
501 <element name="blockquote" namespace="&xhtml;">
502 <copy-of select="$innerpars"/>
505 <when test="$bracketed">
506 <element name="footer" namespace="&xhtml;">
507 <copy-of select="$innerpars"/>
513 <variable name="preformatted" select="$all-prefixed and $prefix='|'"/>
514 <variable name="text">
515 <for-each select="$linespans">
517 <when test="$preformatted">
518 <value-of select="substring-after(., '|')"/>
521 <value-of select="normalize-space()"/>
524 <if test="position()!=count($linespans)">
526 <when test="$preformatted">
537 <when test="$preformatted">
538 <element name="pre" namespace="&xhtml;">
539 <call-template name="LesML:id-and-contents">
540 <with-param name="source" select="$text"/>
544 <when test="string($text)=''"/>
545 <when test="starts-with($text, '⁌') and &sigiled-text;">
546 <element name="h1" namespace="&xhtml;">
547 <call-template name="LesML:id-and-contents">
548 <with-param name="source" select="&unsigiled-text;"/>
552 <when test="starts-with($text, '§') and &sigiled-text;">
553 <element name="h2" namespace="&xhtml;">
554 <call-template name="LesML:id-and-contents">
555 <with-param name="source" select="&unsigiled-text;"/>
559 <when test="starts-with($text, '❦') and &sigiled-text;">
560 <element name="h3" namespace="&xhtml;">
561 <call-template name="LesML:id-and-contents">
562 <with-param name="source" select="&unsigiled-text;"/>
566 <when test="starts-with($text, '✠') and &sigiled-text;">
567 <element name="h4" namespace="&xhtml;">
568 <call-template name="LesML:id-and-contents">
569 <with-param name="source" select="&unsigiled-text;"/>
573 <when test="starts-with($text, '•') and &sigiled-text;">
574 <element name="li" namespace="&xhtml;">
575 <attribute name="class">
576 <text>unordered</text>
578 <attribute name="aria-level">
581 <element name="p" namespace="&xhtml;">
582 <call-template name="LesML:id-and-contents">
583 <with-param name="source" select="&unsigiled-text;"/>
588 <when test="starts-with($text, '🔢') and &sigiled-text;">
589 <element name="li" namespace="&xhtml;">
590 <attribute name="class">
593 <attribute name="aria-level">
596 <element name="p" namespace="&xhtml;">
597 <call-template name="LesML:id-and-contents">
598 <with-param name="source" select="&unsigiled-text;"/>
603 <when test="starts-with($text, '◦') and &sigiled-text;">
604 <element name="li" namespace="&xhtml;">
605 <attribute name="class">
606 <text>unordered</text>
608 <attribute name="aria-level">
611 <element name="p" namespace="&xhtml;">
612 <call-template name="LesML:id-and-contents">
613 <with-param name="source" select="&unsigiled-text;"/>
618 <when test="starts-with($text, '🔠') and &sigiled-text;">
619 <element name="li" namespace="&xhtml;">
620 <attribute name="class">
623 <attribute name="aria-level">
626 <element name="p" namespace="&xhtml;">
627 <call-template name="LesML:id-and-contents">
628 <with-param name="source" select="&unsigiled-text;"/>
633 <when test="starts-with($text, '▪') and &sigiled-text;">
634 <element name="li" namespace="&xhtml;">
635 <attribute name="class">
636 <text>unordered</text>
638 <attribute name="aria-level">
641 <element name="p" namespace="&xhtml;">
642 <call-template name="LesML:id-and-contents">
643 <with-param name="source" select="&unsigiled-text;"/>
648 <when test="starts-with($text, '🔡') and &sigiled-text;">
649 <element name="li" namespace="&xhtml;">
650 <attribute name="class">
653 <attribute name="aria-level">
656 <element name="p" namespace="&xhtml;">
657 <call-template name="LesML:id-and-contents">
658 <with-param name="source" select="&unsigiled-text;"/>
663 <when test="starts-with($text, '⁃') and &sigiled-text;">
664 <element name="li" namespace="&xhtml;">
665 <attribute name="class">
666 <text>unordered</text>
668 <attribute name="aria-level">
671 <element name="p" namespace="&xhtml;">
672 <call-template name="LesML:id-and-contents">
673 <with-param name="source" select="&unsigiled-text;"/>
678 <when test="starts-with($text, '🔣') and &sigiled-text;">
679 <element name="li" namespace="&xhtml;">
680 <attribute name="class">
683 <attribute name="aria-level">
686 <element name="p" namespace="&xhtml;">
687 <call-template name="LesML:id-and-contents">
688 <with-param name="source" select="&unsigiled-text;"/>
693 <when test="starts-with($text, '🛈') and &sigiled-text;">
694 <element name="div" namespace="&xhtml;">
695 <attribute name="role">
698 <attribute name="class">
701 <element name="p" namespace="&xhtml;">
702 <call-template name="LesML:id-and-contents">
703 <with-param name="source" select="&unsigiled-text;"/>
708 <when test="starts-with($text, '⯑') and &sigiled-text;">
709 <element name="div" namespace="&xhtml;">
710 <attribute name="role">
713 <attribute name="class">
716 <element name="p" namespace="&xhtml;">
717 <call-template name="LesML:id-and-contents">
718 <with-param name="source" select="&unsigiled-text;"/>
723 <when test="starts-with($text, '⚠') and &sigiled-text;">
724 <element name="div" namespace="&xhtml;">
725 <attribute name="role">
728 <attribute name="class">
731 <element name="p" namespace="&xhtml;">
732 <call-template name="LesML:id-and-contents">
733 <with-param name="source" select="&unsigiled-text;"/>
738 <when test="starts-with($text, '※') and &sigiled-text;">
739 <element name="div" namespace="&xhtml;">
740 <attribute name="role">
743 <attribute name="class">
746 <element name="p" namespace="&xhtml;">
747 <call-template name="LesML:id-and-contents">
748 <with-param name="source" select="&unsigiled-text;"/>
753 <when test="starts-with($text, '☡') and &sigiled-text;">
754 <element name="div" namespace="&xhtml;">
755 <attribute name="role">
758 <attribute name="class">
761 <element name="p" namespace="&xhtml;">
762 <call-template name="LesML:id-and-contents">
763 <with-param name="source" select="&unsigiled-text;"/>
768 <when test="starts-with($text, '⋯') and &sigiled-text;">
769 <element name="div" namespace="&xhtml;">
770 <processing-instruction name="LesML-Continuation"/>
771 <element name="p" namespace="&xhtml;">
772 <call-template name="LesML:id-and-contents">
773 <with-param name="source" select="&unsigiled-text;"/>
778 <when test="starts-with($text, '^') and &sigiled-text;">
779 <element name="li" namespace="&xhtml;">
780 <attribute name="class">
781 <text>ordered footnote</text>
783 <attribute name="aria-level">
786 <processing-instruction name="LesML-Footnote"/>
787 <element name="p" namespace="&xhtml;">
788 <call-template name="LesML:id-and-contents">
789 <with-param name="source" select="&unsigiled-text;"/>
794 <when test="starts-with($text, '#') and &sigiled-text;">
795 <call-template name="LesML:comment-out">
796 <with-param name="source" select="&unsigiled-text;"/>
800 <element name="p" namespace="&xhtml;">
801 <call-template name="LesML:id-and-contents">
802 <with-param name="source" select="$text"/>
811 <template name="LesML:paragraphize">
812 <param name="lines" select="/.."/>
813 <variable name="blocked-fragment">
814 <call-template name="LesML:block">
815 <with-param name="lines" select="$lines"/>
818 <variable name="blocked" select="exsl:node-set($blocked-fragment)"/>
819 <variable name="footnote-ids" select="$blocked//html:li[processing-instruction()[local-name()='LesML-Footnote']]/html:p[1]/@id"/>
820 <variable name="inlined-fragment">
821 <apply-templates select="$blocked/node()" mode="LesML:comment">
822 <with-param name="footnote-ids" select="$footnote-ids"/>
825 <apply-templates select="exsl:node-set($inlined-fragment)/node()" mode="LesML:finalize-tree"/>
827 <template match="html:script[@type='text/lesml']">
828 <variable name="lines-fragment">
829 <call-template name="LesML:split">
830 <with-param name="source">
831 <for-each select=".//text()">
832 <value-of select="."/>
837 <element name="div" namespace="&xhtml;">
838 <call-template name="LesML:parse">
839 <with-param name="lines" select="exsl:node-set($lines-fragment)/*"/>
843 <template match="node()" mode="LesML:finalize-attributes">
844 <variable name="notattr" select="following-sibling::node()[not(self::text() and translate(., ' 	', '')='' or self::LesML:attribute)]"/>
845 <for-each select="(.|exslset:leading(following-sibling::node(), $notattr)[self::LesML:attribute])/@*">
846 <copy-of select="."/>
847 <if test="local-name()='lang' and namespace-uri()=''">
848 <attribute name="xml:lang">
849 <value-of select="."/>
854 <template match="html:a[@role='doc-noteref']" mode="LesML:finalize-footnotes">
855 <param name="used-footnotes" select="/.."/>
856 <variable name="matching-note" select="$used-footnotes[concat('#', @id)=current()/@href]"/>
858 <apply-templates select="@*" mode="LesML:finalize-footnotes">
859 <with-param name="used-footnotes" select="$used-footnotes"/>
862 <when test="$matching-note">
863 <value-of select="$matching-note/@value"/>
866 <apply-templates select="node()" mode="LesML:finalize-footnotes">
867 <with-param name="used-footnotes" select="$used-footnotes"/>
873 <template match="html:p[preceding-sibling::*[1]=processing-instruction()[local-name()='LesML-Footnote']]" mode="LesML:finalize-footnotes">
874 <variable name="content" select="@*[not(local-name()='@id' and namespace-uri()='')]|node()"/>
877 <apply-templates select="$content" mode="LesML:finalize-footnotes"/>
881 <template match="html:ol[processing-instruction()[local-name()='LesML-Footnote']]|processing-instruction()[local-name()='LesML-Footnote']" mode="LesML:finalize-footnotes"/>
882 <template match="@*|node()" mode="LesML:finalize-footnotes" priority="-1">
883 <param name="used-footnotes" select="/.."/>
885 <apply-templates select="@*|node()" mode="LesML:finalize-footnotes">
886 <with-param name="used-footnotes" select="$used-footnotes"/>
890 <template match="html:li" mode="LesML:finalize-list">
891 <param name="parent-level" select="0"/>
892 <variable name="current-class" select="string(@class)"/>
893 <variable name="current-level" select="number(@aria-level)"/>
894 <variable name="wrapper">
896 <when test="contains(concat(' ', @class, ' '), ' ordered ')">
904 <variable name="notinlist" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'] or self::html:li and (@aria-level>$current-level or @aria-level=$current-level and @class=$current-class))][1]"/>
905 <element name="{$wrapper}" namespace="&xhtml;">
906 <if test="contains(concat(' ', @class, ' '), ' footnote ')">
907 <processing-instruction name="LesML-Footnote"/>
909 <for-each select=".|exslset:leading(following-sibling::node(), $notinlist)[self::html:li and @aria-level=$current-level]">
910 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
912 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
913 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
914 <apply-templates select="node()" mode="LesML:finalize-tree"/>
916 <if test="$notcontinuation/self::html:li[@aria-level>$current-level]">
917 <apply-templates select="$notcontinuation" mode="LesML:finalize-list">
918 <with-param name="parent-level" select="$current-level"/>
924 <if test="$notinlist/self::html:li[@aria-level>$parent-level]">
925 <apply-templates select="$notinlist" mode="LesML:finalize-list">
926 <with-param name="parent-level" select="$parent-level"/>
930 <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(., ' 	', '')='']" mode="LesML:finalize-tree" priority="2"/>
931 <template match="LesML:attribute|text()[following-sibling::node()[position()=1 and self::LesML:attribute]]" mode="LesML:finalize-tree" priority="1">
932 <element name="span" namespace="&xhtml;">
933 <apply-templates select="." mode="LesML:finalize-attributes"/>
934 <if test="self::text()">
935 <call-template name="LesML:break-and-unescape">
936 <with-param name="source" select="string(.)"/>
941 <template match="html:div" mode="LesML:finalize-tree">
942 <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())])">
943 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
945 <when test="processing-instruction()[local-name()='LesML-Continuation'] and $notcontinuation[self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
946 <variable name="notcontinuation2" select="$notcontinuation/following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
947 <element name="hgroup" namespace="&xhtml;">
948 <apply-templates select="node()" mode="LesML:finalize-tree"/>
949 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation2)">
951 <when test="self::html:div">
952 <apply-templates select="node()" mode="LesML:finalize-tree"/>
956 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
963 <when test="not(processing-instruction()[local-name()='LesML-Continuation'])">
965 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
966 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
967 <apply-templates select="node()" mode="LesML:finalize-tree"/>
972 <apply-templates select="node()" mode="LesML:finalize-tree"/>
973 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
974 <apply-templates select="node()" mode="LesML:finalize-tree"/>
980 <template match="html:h1|html:h2|html:h3|html:h4|html:h5|html:h6" mode="LesML:finalize-tree">
981 <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())]">
983 <when test="following-sibling::node()[position()=1 and self::html:div]/processing-instruction()[local-name()='LesML-Continuation']">
984 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
985 <element name="hgroup" namespace="&xhtml;">
987 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
989 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
990 <apply-templates select="node()" mode="LesML:finalize-tree"/>
996 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
1002 <template match="html:li" mode="LesML:finalize-tree">
1003 <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)]">
1004 <apply-templates select="." mode="LesML:finalize-list"/>
1007 <template match="processing-instruction()[local-name()='LesML-Continuation']" mode="LesML:finalize-tree"/>
1008 <template match="processing-instruction()[local-name()='LesML-Token-Escape']" mode="LesML:finalize-tree">
1009 <value-of select="."/>
1011 <template match="text()" mode="LesML:finalize-tree">
1012 <call-template name="LesML:break-and-unescape">
1013 <with-param name="source" select="string(.)"/>
1016 <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
1018 <apply-templates select="." mode="LesML:finalize-attributes"/>
1019 <apply-templates select="node()" mode="LesML:finalize-tree"/>
1022 <template match="node()" mode="LesML:inline">
1023 <param name="element-name"/>
1024 <param name="element-namespace" select="'http://www.w3.org/1999/xhtml'"/>
1025 <param name="start-sigil"/>
1026 <param name="end-sigil"/>
1027 <param name="class"/>
1028 <param name="role"/>
1030 <when test="self::*">
1031 <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
1032 <variable name="has-start-node" select="$end-node/preceding-sibling::text()[contains(., $start-sigil)] or string-length(substring-after($end-node, $start-sigil))>string-length(substring-after($end-node, $end-sigil))"/>
1034 <when test="$end-node and $has-start-node">
1035 <variable name="preceding">
1036 <copy-of select="$end-node/preceding-sibling::node()"/>
1037 <value-of select="substring-before($end-node, $end-sigil)"/>
1039 <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., $start-sigil)][last()]"/>
1040 <variable name="start-tokens-fragment">
1041 <call-template name="LesML:split">
1042 <with-param name="source" select="string($start-node)"/>
1043 <with-param name="separator" select="$start-sigil"/>
1046 <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
1047 <variable name="wrapped">
1049 <copy-of select="@*"/>
1050 <copy-of select="$start-node/preceding-sibling::node()"/>
1051 <for-each select="$start-tokens[position()!=last()]">
1052 <value-of select="."/>
1053 <if test="position()!=last()">
1054 <value-of select="$start-sigil"/>
1057 <element name="{$element-name}" namespace="{$element-namespace}">
1058 <if test="string($role)!=''">
1059 <attribute name="role">
1060 <value-of select="$role"/>
1063 <if test="string($class)!=''">
1064 <attribute name="class">
1065 <value-of select="$class"/>
1068 <value-of select="$start-tokens[last()]"/>
1069 <copy-of select="$start-node/following-sibling::node()"/>
1071 <value-of select="substring-after($end-node, $end-sigil)"/>
1072 <copy-of select="$end-node/following-sibling::node()"/>
1075 <apply-templates select="exsl:node-set($wrapped)/*" mode="LesML:inline">
1076 <with-param name="element-name" select="$element-name"/>
1077 <with-param name="element-namespace" select="$element-namespace"/>
1078 <with-param name="start-sigil" select="$start-sigil"/>
1079 <with-param name="end-sigil" select="$end-sigil"/>
1080 <with-param name="role" select="$role"/>
1085 <copy-of select="@*"/>
1086 <apply-templates select="node()" mode="LesML:inline">
1087 <with-param name="element-name" select="$element-name"/>
1088 <with-param name="element-namespace" select="$element-namespace"/>
1089 <with-param name="start-sigil" select="$start-sigil"/>
1090 <with-param name="end-sigil" select="$end-sigil"/>
1091 <with-param name="role" select="$role"/>
1098 <copy-of select="."/>
1102 <template match="*" mode="LesML:partition">
1103 <param name="start-sigil"/>
1104 <param name="end-sigil"/>
1105 <param name="separator"/>
1106 <param name="ncname-keys" select="false()"/>
1107 <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
1108 <variable name="has-start-node" select="$end-node/preceding-sibling::text()[contains(., $start-sigil)] or string-length(substring-after($end-node, $start-sigil))>string-length(substring-after($end-node, $end-sigil))"/>
1110 <when test="$end-node and $has-start-node">
1111 <variable name="preceding-fragment">
1112 <copy-of select="$end-node/preceding-sibling::node()"/>
1113 <value-of select="substring-before($end-node, $end-sigil)"/>
1115 <variable name="preceding" select="exsl:node-set($preceding-fragment)/node()"/>
1116 <variable name="start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()][not($ncname-keys) or not(following-sibling::* or following-sibling::comment())]"/>
1117 <variable name="start-tokens-fragment">
1118 <if test="$start-node">
1119 <call-template name="LesML:split">
1120 <with-param name="source" select="string($start-node)"/>
1121 <with-param name="separator" select="$start-sigil"/>
1125 <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
1126 <variable name="innards-fragment">
1127 <value-of select="$start-tokens[last()]"/>
1128 <copy-of select="$start-node/following-sibling::node()"/>
1130 <variable name="innards" select="exsl:node-set($innards-fragment)/node()"/>
1131 <variable name="separator-node" select="($innards[self::text() and contains(., $separator)])[not($ncname-keys)*(last()-1)+1]"/>
1133 <when test="not($start-node) or $separator-node[following-sibling::* or following-sibling::comment()]">
1134 <variable name="bad-start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()]"/>
1135 <variable name="bad-start-tokens-fragment">
1136 <call-template name="LesML:split">
1137 <with-param name="source" select="string($bad-start-node)"/>
1138 <with-param name="separator" select="$start-sigil"/>
1141 <element name="span" namespace="&xhtml;">
1142 <copy-of select="$bad-start-node/preceding-sibling::node()"/>
1143 <for-each select="exsl:node-set($bad-start-tokens-fragment)/*">
1144 <value-of select="."/>
1145 <if test="position()!=last()">
1146 <processing-instruction name="LesML-Token-Escape">
1147 <value-of select="$start-sigil"/>
1148 </processing-instruction>
1151 <copy-of select="$bad-start-node/following-sibling::node()"/>
1152 <value-of select="$end-sigil"/>
1153 <value-of select="substring-after($end-node, $end-sigil)"/>
1154 <copy-of select="$end-node/following-sibling::node()"/>
1157 <when test="$separator-node">
1158 <variable name="keyval-fragment">
1159 <call-template name="LesML:split">
1160 <with-param name="source" select="$separator-node"/>
1161 <with-param name="separator" select="$separator"/>
1164 <variable name="keyval" select="exsl:node-set($keyval-fragment)/*"/>
1165 <variable name="key-fragment">
1167 <when test="$ncname-keys">
1168 <for-each select="$separator-node/preceding-sibling::node()">
1169 <value-of select="."/>
1171 <value-of select="$keyval[1]"/>
1174 <copy-of select="$separator-node/preceding-sibling::node()"/>
1175 <for-each select="$keyval[position()!=last()]">
1176 <value-of select="."/>
1177 <if test="position()!=last()">
1178 <value-of select="$separator"/>
1184 <variable name="value">
1186 <when test="$ncname-keys">
1187 <for-each select="$keyval[position()!=1]">
1188 <value-of select="."/>
1189 <if test="position()!=last()">
1190 <value-of select="$separator"/>
1195 <value-of select="$keyval[last()]"/>
1198 <for-each select="$separator-node/following-sibling::node()">
1199 <value-of select="."/>
1203 <when test="not($ncname-keys) or /self::node()[translate(normalize-space($key-fragment), ' /([,*', '')=$key-fragment and exsldyn:evaluate(concat('not(self::html:', $key-fragment, ')'))]">
1204 <element name="span" namespace="&xhtml;">
1205 <copy-of select="$start-node/preceding-sibling::node()"/>
1206 <for-each select="$start-tokens[position()!=last()]">
1207 <value-of select="."/>
1208 <if test="position()!=last()">
1209 <value-of select="$start-sigil"/>
1213 <element name="span" namespace="&xhtml;">
1214 <copy-of select="$key-fragment"/>
1216 <element name="span" namespace="&xhtml;">
1217 <value-of select="$value"/>
1219 <element name="span" namespace="&xhtml;">
1220 <value-of select="substring-after($end-node, $end-sigil)"/>
1221 <copy-of select="$end-node/following-sibling::node()"/>
1225 <element name="span" namespace="&xhtml;">
1226 <copy-of select="$start-node/preceding-sibling::node()"/>
1227 <for-each select="$start-tokens[position()!=last()]">
1228 <value-of select="."/>
1229 <if test="position()!=last()">
1230 <value-of select="$start-sigil"/>
1233 <processing-instruction name="LesML-Token-Escape">
1234 <value-of select="$start-sigil"/>
1235 </processing-instruction>
1236 <value-of select="$start-tokens[last()]"/>
1237 <value-of select="$start-node/following-sibling::node()"/>
1238 <value-of select="$end-sigil"/>
1239 <value-of select="substring-after($end-node, $end-sigil)"/>
1240 <copy-of select="$end-node/following-sibling::node()"/>
1246 <element name="span" namespace="&xhtml;">
1247 <copy-of select="$start-node/preceding-sibling::node()"/>
1248 <for-each select="$start-tokens[position()!=last()]">
1249 <value-of select="."/>
1250 <if test="position()!=last()">
1251 <value-of select="$start-sigil"/>
1254 <processing-instruction name="LesML-Token-Escape">
1255 <value-of select="$start-sigil"/>
1256 </processing-instruction>
1257 <value-of select="$start-tokens[last()]"/>
1258 <copy-of select="$start-node/following-sibling::node()"/>
1259 <value-of select="$end-sigil"/>
1260 <value-of select="substring-after($end-node, $end-sigil)"/>
1261 <copy-of select="$end-node/following-sibling::node()"/>
1266 <when test="$end-node">
1267 <element name="span" namespace="&xhtml;">
1268 <copy-of select="$end-node/preceding-sibling::node()"/>
1269 <value-of select="substring-before($end-node, $end-sigil)"/>
1270 <processing-instruction name="LesML-Token-Escape">
1271 <value-of select="$end-sigil"/>
1272 </processing-instruction>
1273 <value-of select="substring-after($end-node, $end-sigil)"/>
1274 <copy-of select="$end-node/following-sibling::node()"/>
1278 <processing-instruction name="LesML-All-Done"/>
1282 <template match="node()" mode="LesML:comment">
1283 <param name="footnote-ids" select="/.."/>
1284 <variable name="result">
1286 <when test="self::*">
1287 <variable name="start-node" select="text()[contains(., '⌦')][1]"/>
1288 <variable name="after-start">
1289 <if test="$start-node">
1290 <value-of select="substring-after($start-node, '⌦')"/>
1293 <variable name="has-end-node" select="contains($after-start, '⌫') or $start-node/following-sibling::text()[contains(., '⌫')]"/>
1295 <when test="$start-node and $has-end-node">
1296 <variable name="following">
1297 <value-of select="$after-start"/>
1298 <copy-of select="$start-node/following-sibling::node()"/>
1300 <variable name="end-node" select="exsl:node-set($following)/text()[contains(., '⌫')][last()]"/>
1301 <variable name="comment">
1302 <for-each select="$end-node/preceding-sibling::node()">
1303 <value-of select="."/>
1305 <value-of select="substring-before($end-node, '⌫')"/>
1307 <variable name="rest-fragment">
1308 <element name="span" namespace="&xhtml;">
1309 <value-of select="substring-after($end-node, '⌫')"/>
1310 <copy-of select="$end-node/following-sibling::node()"/>
1313 <variable name="commented-rest-fragment">
1314 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:comment">
1315 <with-param name="footnote-ids" select="$footnote-ids"/>
1319 <copy-of select="@*"/>
1320 <copy-of select="$start-node/preceding-sibling::node()"/>
1321 <copy-of select="substring-before($start-node, '⌦')"/>
1322 <call-template name="LesML:comment-out">
1323 <with-param name="source" select="string($comment)"/>
1325 <copy-of select="exsl:node-set($commented-rest-fragment)/*/node()"/>
1328 <when test="$start-node">
1329 <variable name="rest-fragment">
1330 <element name="div" namespace="&xhtml;">
1331 <value-of select="substring-after($after-start, '⌦')"/>
1332 <copy-of select="$start-node/following-sibling::node()"/>
1335 <variable name="commented-rest-fragment">
1336 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:comment">
1337 <with-param name="footnote-ids" select="$footnote-ids"/>
1341 <copy-of select="@*"/>
1342 <copy-of select="$start-node/preceding-sibling::node()"/>
1343 <copy-of select="substring-before($start-node, '⌦')"/>
1345 <copy-of select="exsl:node-set($commented-rest-fragment)/*/node()"/>
1350 <copy-of select="@*"/>
1351 <apply-templates select="node()" mode="LesML:comment">
1352 <with-param name="footnote-ids" select="$footnote-ids"/>
1358 <when test="self::text()[contains(., '⌧')]">
1359 <variable name="split-fragment">
1360 <call-template name="LesML:split">
1361 <with-param name="source" select="string()"/>
1362 <with-param name="separator" select="'⌧'"/>
1365 <for-each select="exsl:node-set($split-fragment)/node()">
1366 <value-of select="."/>
1367 <if test="position()!=last()">
1368 <call-template name="LesML:comment-out"/>
1373 <copy-of select="."/>
1377 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:attrify">
1378 <with-param name="footnote-ids" select="$footnote-ids"/>
1381 <template match="node()" mode="LesML:attrify">
1382 <param name="footnote-ids" select="/.."/>
1383 <variable name="result">
1385 <when test="self::*">
1386 <variable name="partitioned-fragment">
1387 <apply-templates mode="LesML:partition" select=".">
1388 <with-param name="start-sigil" select="'{@'"/>
1389 <with-param name="end-sigil" select="'"}'"/>
1390 <with-param name="separator" select="'="'"/>
1391 <with-param name="ncname-keys" select="true()"/>
1394 <variable name="partitioned" select="exsl:node-set($partitioned-fragment)/node()"/>
1396 <when test="count($partitioned)>1">
1397 <variable name="processed">
1399 <copy-of select="@*"/>
1400 <copy-of select="$partitioned[1]/node()"/>
1401 <element name="LesML:attribute" namespace="&LesML;">
1402 <attribute name="{$partitioned[2]}">
1403 <value-of select="$partitioned[3]"/>
1406 <copy-of select="$partitioned[4]/node()"/>
1409 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:attrify">
1410 <with-param name="footnote-ids" select="$footnote-ids"/>
1413 <when test="$partitioned[self::processing-instruction() and local-name()='LesML-All-Done']">
1415 <copy-of select="@*"/>
1416 <apply-templates select="node()" mode="LesML:attrify">
1417 <with-param name="footnote-ids" select="$footnote-ids"/>
1422 <variable name="processed">
1424 <copy-of select="@*"/>
1425 <copy-of select="$partitioned/node()"/>
1428 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:attrify">
1429 <with-param name="footnote-ids" select="$footnote-ids"/>
1435 <copy-of select="."/>
1439 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:linkify">
1440 <with-param name="footnote-ids" select="$footnote-ids"/>
1443 <template match="node()" mode="LesML:linkify">
1444 <param name="footnote-ids" select="/.."/>
1445 <variable name="result">
1447 <when test="processing-instruction()[local-name()='LesML-All-Done']">
1449 <copy-of select="@*|node()[not(self::processing-instruction() and local-name()='LesML-All-Done')]"/>
1452 <when test="self::*">
1453 <variable name="partitioned-fragment">
1454 <apply-templates mode="LesML:partition" select=".">
1455 <with-param name="start-sigil" select="'{🔗'"/>
1456 <with-param name="end-sigil" select="'>}'"/>
1457 <with-param name="separator" select="'<'"/>
1460 <variable name="partitioned" select="exsl:node-set($partitioned-fragment)/node()"/>
1462 <when test="count($partitioned)>1">
1463 <variable name="processed">
1465 <copy-of select="@*"/>
1466 <copy-of select="$partitioned[1]/node()"/>
1467 <element name="a" namespace="&xhtml;">
1468 <attribute name="href">
1469 <value-of select="$partitioned[3]"/>
1471 <processing-instruction name="LesML-All-Done"/>
1473 <when test="not($partitioned[2]/node())">
1474 <value-of select="$partitioned[3]"/>
1477 <copy-of select="$partitioned[2]/node()"/>
1481 <copy-of select="$partitioned[4]/node()"/>
1484 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:linkify">
1485 <with-param name="footnote-ids" select="$footnote-ids"/>
1488 <when test="$partitioned[self::processing-instruction() and local-name()='LesML-All-Done']">
1490 <copy-of select="@*"/>
1491 <apply-templates select="node()" mode="LesML:linkify">
1492 <with-param name="footnote-ids" select="$footnote-ids"/>
1497 <variable name="processed">
1499 <copy-of select="@*"/>
1500 <copy-of select="$partitioned/node()"/>
1503 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:linkify">
1504 <with-param name="footnote-ids" select="$footnote-ids"/>
1510 <copy-of select="."/>
1514 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:strikethrough">
1515 <with-param name="footnote-ids" select="$footnote-ids"/>
1518 <template match="node()" mode="LesML:strikethrough">
1519 <param name="footnote-ids" select="/.."/>
1520 <variable name="result">
1521 <apply-templates select="." mode="LesML:inline">
1522 <with-param name="element-name" select="'s'"/>
1523 <with-param name="element-namespace" select="'&xhtml;'"/>
1524 <with-param name="start-sigil" select="'⸠'"/>
1525 <with-param name="end-sigil" select="'⸡'"/>
1528 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:underline">
1529 <with-param name="footnote-ids" select="$footnote-ids"/>
1532 <template match="node()" mode="LesML:underline">
1533 <param name="footnote-ids" select="/.."/>
1534 <variable name="result">
1535 <apply-templates select="." mode="LesML:inline">
1536 <with-param name="element-name" select="'u'"/>
1537 <with-param name="element-namespace" select="'&xhtml;'"/>
1538 <with-param name="start-sigil" select="'⸤'"/>
1539 <with-param name="end-sigil" select="'⸥'"/>
1542 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:noted">
1543 <with-param name="footnote-ids" select="$footnote-ids"/>
1546 <template match="node()" mode="LesML:noted">
1547 <param name="footnote-ids" select="/.."/>
1548 <variable name="result">
1549 <apply-templates select="." mode="LesML:inline">
1550 <with-param name="element-name" select="'small'"/>
1551 <with-param name="element-namespace" select="'&xhtml;'"/>
1552 <with-param name="start-sigil" select="'⟦'"/>
1553 <with-param name="end-sigil" select="'⟧'"/>
1554 <with-param name="role" select="'note'"/>
1557 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:parenthetical">
1558 <with-param name="footnote-ids" select="$footnote-ids"/>
1561 <template match="node()" mode="LesML:parenthetical">
1562 <param name="footnote-ids" select="/.."/>
1563 <variable name="result">
1564 <apply-templates select="." mode="LesML:inline">
1565 <with-param name="element-name" select="'small'"/>
1566 <with-param name="element-namespace" select="'&xhtml;'"/>
1567 <with-param name="start-sigil" select="'⸨'"/>
1568 <with-param name="end-sigil" select="'⸩'"/>
1571 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:code">
1572 <with-param name="footnote-ids" select="$footnote-ids"/>
1575 <template match="node()" mode="LesML:code">
1576 <param name="footnote-ids" select="/.."/>
1577 <variable name="result">
1578 <apply-templates select="." mode="LesML:inline">
1579 <with-param name="element-name" select="'code'"/>
1580 <with-param name="element-namespace" select="'&xhtml;'"/>
1581 <with-param name="start-sigil" select="'`'"/>
1582 <with-param name="end-sigil" select="'´'"/>
1585 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:titled">
1586 <with-param name="footnote-ids" select="$footnote-ids"/>
1589 <template match="node()" mode="LesML:titled">
1590 <param name="footnote-ids" select="/.."/>
1591 <variable name="result">
1592 <apply-templates select="." mode="LesML:inline">
1593 <with-param name="element-name" select="'cite'"/>
1594 <with-param name="element-namespace" select="'&xhtml;'"/>
1595 <with-param name="start-sigil" select="'⟪'"/>
1596 <with-param name="end-sigil" select="'⟫'"/>
1599 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:named">
1600 <with-param name="footnote-ids" select="$footnote-ids"/>
1603 <template match="node()" mode="LesML:named">
1604 <param name="footnote-ids" select="/.."/>
1605 <variable name="result">
1606 <apply-templates select="." mode="LesML:inline">
1607 <with-param name="element-name" select="'u'"/>
1608 <with-param name="element-namespace" select="'&xhtml;'"/>
1609 <with-param name="start-sigil" select="'⸶'"/>
1610 <with-param name="end-sigil" select="'⸷'"/>
1611 <with-param name="class" select="'name'"/>
1614 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:offset">
1615 <with-param name="footnote-ids" select="$footnote-ids"/>
1618 <template match="node()" mode="LesML:offset">
1619 <param name="footnote-ids" select="/.."/>
1620 <variable name="result">
1621 <apply-templates select="." mode="LesML:inline">
1622 <with-param name="element-name" select="'i'"/>
1623 <with-param name="element-namespace" select="'&xhtml;'"/>
1624 <with-param name="start-sigil" select="'⟨'"/>
1625 <with-param name="end-sigil" select="'⟩'"/>
1628 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:bolded">
1629 <with-param name="footnote-ids" select="$footnote-ids"/>
1632 <template match="node()" mode="LesML:bolded">
1633 <param name="footnote-ids" select="/.."/>
1634 <variable name="result">
1635 <apply-templates select="." mode="LesML:inline">
1636 <with-param name="element-name" select="'b'"/>
1637 <with-param name="element-namespace" select="'&xhtml;'"/>
1638 <with-param name="start-sigil" select="'⦃'"/>
1639 <with-param name="end-sigil" select="'⦄'"/>
1642 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:important">
1643 <with-param name="footnote-ids" select="$footnote-ids"/>
1646 <template match="node()" mode="LesML:important">
1647 <param name="footnote-ids" select="/.."/>
1648 <variable name="result">
1649 <apply-templates select="." mode="LesML:inline">
1650 <with-param name="element-name" select="'strong'"/>
1651 <with-param name="element-namespace" select="'&xhtml;'"/>
1652 <with-param name="start-sigil" select="'☞'"/>
1653 <with-param name="end-sigil" select="'☜'"/>
1656 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:emphasized">
1657 <with-param name="footnote-ids" select="$footnote-ids"/>
1660 <template match="node()" mode="LesML:emphasized">
1661 <param name="footnote-ids" select="/.."/>
1662 <variable name="result">
1663 <apply-templates select="." mode="LesML:inline">
1664 <with-param name="element-name" select="'em'"/>
1665 <with-param name="element-namespace" select="'&xhtml;'"/>
1666 <with-param name="start-sigil" select="'⹐'"/>
1667 <with-param name="end-sigil" select="'⹑'"/>
1670 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:footnoted">
1671 <with-param name="footnote-ids" select="$footnote-ids"/>
1674 <template match="node()" mode="LesML:footnoted">
1675 <param name="footnote-ids" select="/.."/>
1677 <when test="self::*">
1678 <variable name="start-node" select="text()[contains(., '^')][1]"/>
1679 <variable name="after-start" select="substring-after($start-node, '^')"/>
1680 <variable name="footnote-id" select="substring-before($after-start, '.')"/>
1681 <variable name="matched-footnote" select="$footnote-ids[.=$footnote-id]"/>
1683 <when test="$footnote-id!='' and $matched-footnote">
1684 <variable name="rest-fragment">
1685 <element name="div" namespace="&xhtml;">
1686 <value-of select="substring-after($after-start, '.')"/>
1687 <copy-of select="$start-node/following-sibling::node()"/>
1690 <variable name="footnoted-rest-fragment">
1691 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:footnoted">
1692 <with-param name="footnote-ids" select="$footnote-ids"/>
1696 <copy-of select="@*"/>
1697 <copy-of select="$start-node/preceding-sibling::node()"/>
1698 <copy-of select="substring-before($start-node, '^')"/>
1699 <element name="a" namespace="&xhtml;">
1700 <attribute name="id">
1701 <text>LesML.fnref.</text>
1702 <value-of select="generate-id($start-node)"/>
1704 <attribute name="role">
1705 <text>doc-noteref</text>
1707 <attribute name="href">
1709 <value-of select="$footnote-id"/>
1711 <attribute name="target">
1715 <copy-of select="exsl:node-set($footnoted-rest-fragment)/*/node()"/>
1718 <when test="$start-node">
1719 <variable name="rest-fragment">
1720 <element name="div" namespace="&xhtml;">
1721 <value-of select="substring-after($after-start, '^')"/>
1722 <copy-of select="$start-node/following-sibling::node()"/>
1725 <variable name="footnoted-rest-fragment">
1726 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:footnoted">
1727 <with-param name="footnote-ids" select="$footnote-ids"/>
1731 <copy-of select="@*"/>
1732 <copy-of select="$start-node/preceding-sibling::node()"/>
1733 <copy-of select="substring-before($start-node, '^')"/>
1735 <copy-of select="exsl:node-set($footnoted-rest-fragment)/*/node()"/>
1740 <copy-of select="@*"/>
1741 <apply-templates select="node()" mode="LesML:footnoted">
1742 <with-param name="footnote-ids" select="$footnote-ids"/>
1749 <copy-of select="."/>