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 pilcrow-atts "(local-name()='id' or local-name()='lang') and namespace-uri()='' or local-name()='lang' and namespace-uri()='http://www.w3.org/XML/1998/namespace'">
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:exslfunc="http://exslt.org/functions"
27 xmlns:exslset="http://exslt.org/sets"
28 xmlns:exslstr="http://exslt.org/strings"
29 xmlns:html="http://www.w3.org/1999/xhtml"
30 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
31 exclude-result-prefixes="LesML"
32 extension-element-prefixes="exsl exsldyn exslfunc exslset exslstr"
35 <书社:id>urn:fdc:ladys.computer:20240512:LesML:parser.xslt</书社:id>
36 <param name="LESML_SECTION_BREAK_CHARS" select="'*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~'"/>
37 <exslfunc:function name="LesML:split">
38 <param name="source" select="string()"/>
39 <param name="separator" select="'
'"/>
40 <variable name="result-fragment">
41 <call-template name="LesML:do-split">
42 <with-param name="source" select="$source"/>
43 <with-param name="separator" select="$separator"/>
46 <exslfunc:result select="exsl:node-set($result-fragment)/node()"/>
48 <template name="LesML:do-split">
49 <param name="source"/>
50 <param name="separator" select="'
'"/>
52 <when test="contains($source, $separator)">
54 <value-of select="substring-before($source, $separator)"/>
56 <call-template name="LesML:do-split">
57 <with-param name="source" select="substring-after($source, $separator)"/>
58 <with-param name="separator" select="$separator"/>
63 <value-of select="$source"/>
68 <template name="LesML:break-and-unescape">
69 <param name="source"/>
70 <for-each select="LesML:split($source)">
71 <call-template name="LesML:unescape">
72 <with-param name="source" select="string()"/>
74 <if test="position()!=last()">
75 <element name="br" namespace="&xhtml;"/>
79 <template name="LesML:unescape">
80 <param name="source"/>
82 <when test="contains($source, '{U+')">
83 <variable name="after" select="substring-after($source, '{U+')"/>
85 <when test="contains($after, '}')">
86 <variable name="inner" select="substring-before($after, '}')"/>
87 <variable name="components" select="LesML:split($inner, '.')"/>
88 <value-of select="substring-before($source, '{U+')"/>
90 <when test="$components[string(.)='' or translate(., '0123456789ABCDEF', '')!='']">
92 <value-of select="$inner"/>
94 <call-template name="LesML:unescape">
95 <with-param name="source" select="substring-after($after, '}')"/>
99 <for-each select="$components">
100 <text disable-output-escaping="yes">&#x</text>
101 <value-of select="."/>
104 <call-template name="LesML:unescape">
105 <with-param name="source" select="substring-after($after, '}')"/>
111 <value-of select="substring-before($source, '{U+')"/>
113 <call-template name="LesML:unescape">
114 <with-param name="source" select="$after"/>
120 <value-of select="$source"/>
124 <template name="LesML:comment-out">
125 <param name="source"/>
127 <for-each select="LesML:split($source, '--')">
128 <if test="string()='' or starts-with(., '‐')">
129 <text>͏</text>
131 <value-of select="."/>
132 <if test="substring(., string-length(.), 1)='‐'">
133 <text>͏</text>
136 <when test="position()!=last()">
137 <text>-͏-</text>
143 <template name="LesML:id-and-contents">
144 <param name="source"/>
145 <variable name="id-and-lang">
146 <if test="starts-with($source, '¶')">
148 <when test="contains($source, ' ')">
149 <value-of select="substring-before(substring-after($source, '¶'), ' ')"/>
152 <value-of select="substring-after($source, '¶')"/>
157 <variable name="restoftext">
159 <when test="starts-with($source, '¶') and contains($source, ' ')">
160 <value-of select="substring-after($source, ' ')"/>
162 <when test="starts-with($source, '¶')"/>
164 <value-of select="$source"/>
168 <variable name="maybe-langtag">
169 <if test="substring($id-and-lang, string-length($id-and-lang), 1)='$' and contains($id-and-lang, '@')">
170 <value-of select="LesML:split(substring($id-and-lang, 2, string-length($id-and-lang)-2), '@')[last()]"/>
173 <variable name="langtag">
174 <if test="translate($maybe-langtag, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-', '')=''">
175 <value-of select="$maybe-langtag"/>
180 <when test="string($langtag)!=''">
181 <value-of select="substring($id-and-lang, 1, string-length($id-and-lang)-(string-length($langtag)+2))"/>
184 <value-of select="$id-and-lang"/>
188 <if test="string($id)!=''">
189 <attribute name="id">
190 <value-of select="$id"/>
193 <if test="string($langtag)!=''">
194 <attribute name="lang">
195 <value-of select="$langtag"/>
197 <attribute name="xml:lang">
198 <value-of select="$langtag"/>
201 <value-of select="$restoftext"/>
203 <template name="LesML:parse">
204 <param name="lines" select="/.."/>
205 <param name="parent-params" select="/.."/>
206 <variable name="first-line" select="$lines[1]"/>
207 <variable name="shebang">
208 <if test="starts-with($first-line, '#!lesml')">
209 <value-of select="$first-line"/>
212 <variable name="params-string">
214 <when test="starts-with($shebang, '#!lesml@')">
215 <value-of select="substring-after($shebang, '$')"/>
218 <value-of select="substring-after($shebang, '#!lesml')"/>
222 <variable name="params-fragment">
224 <when test="$shebang!=''">
226 <if test="starts-with($shebang, '#!lesml@') and contains($shebang, '$')">
232 <value-of select="substring-before(substring-after($shebang, '#!lesml@'), '$')"/>
236 <for-each select="exslstr:tokenize($params-string)">
238 <when test="contains(., '=')">
241 <value-of select="substring-before(., '=')"/>
244 <value-of select="substring-after(., '=')"/>
251 <value-of select="."/>
260 <when test="$parent-params">
261 <copy-of select="$parent-params"/>
268 <variable name="params" select="exsl:node-set($params-fragment)/*"/>
269 <variable name="noshebang" select="$lines[position()>1 or not(starts-with(., '#!lesml') or starts-with(., '##'))]"/>
270 <variable name="docsep" select="$noshebang[starts-with(., '#!lesml') or starts-with(., '##')][1]"/>
271 <variable name="doclines" select="exslset:leading($noshebang, $docsep)"/>
272 <if test="starts-with($first-line, '##') and $first-line!='##'">
273 <call-template name="LesML:comment-out">
274 <with-param name="source" select="substring-after($first-line, '##')"/>
277 <if test="$doclines[normalize-space()!='']">
278 <variable name="record-separators" select="$doclines[starts-with(., '%%')]"/>
279 <variable name="paragraphized-fragment">
280 <call-template name="LesML:paragraphize">
281 <with-param name="lines" select="exslset:trailing($doclines, $record-separators[last()])"/>
284 <variable name="paragraphized" select="exsl:node-set($paragraphized-fragment)"/>
285 <variable name="filtered-ordered-footnotes-fragment">
286 <for-each select="$paragraphized//html:li[processing-instruction()[local-name()='LesML-Footnote'] and html:p[position()=1 and @id]]">
287 <sort select="count(($paragraphized//html:a[@role='doc-noteref' and @href=concat('#', string(current()/html:p[1]/@id))])[1]/preceding::*)" data-type="number"/>
288 <if test="$paragraphized//html:a[@role='doc-noteref' and @href=concat('#', string(current()/html:p[1]/@id))]">
289 <copy-of select="."/>
293 <variable name="used-footnotes-fragment">
294 <for-each select="exsl:node-set($filtered-ordered-footnotes-fragment)/node()">
295 <variable name="links" select="$paragraphized//html:a[@role='doc-noteref' and @href=concat('#', string(current()/html:p[1]/@id))]"/>
296 <element name="li" namespace="&xhtml;">
297 <variable name="numero" select="position()"/>
298 <attribute name="id">
299 <value-of select="html:p[1]/@id"/>
301 <attribute name="value">
302 <value-of select="$numero"/>
304 <copy-of select="@*|node()"/>
305 <element name="footer" namespace="&xhtml;">
306 <attribute name="class">
307 <text>backlinks</text>
309 <for-each select="$links[@id]">
310 <if test="position()>1">
313 <element name="a" namespace="&xhtml;">
314 <attribute name="role">
315 <text>doc-backlink</text>
317 <attribute name="href">
319 <value-of select="@id"/>
321 <value-of select="position()"/>
328 <variable name="used-footnote-nodes" select="exsl:node-set($used-footnotes-fragment)/node()"/>
329 <element name="article" namespace="&xhtml;">
330 <for-each select="$params/html:div/html:dt[string()=' LANG ']">
331 <attribute name="lang">
332 <value-of select="following-sibling::html:dd"/>
334 <attribute name="xml:lang">
335 <value-of select="following-sibling::html:dd"/>
338 <for-each select="$params/html:div/html:dt[string()='profile']">
339 <attribute name="data-lesml-profile">
340 <value-of select="following-sibling::html:dd"/>
343 <if test="$record-separators[preceding-sibling::*[normalize-space()!='']]">
344 <element name="footer" namespace="&xhtml;">
345 <attribute name="class">
348 <for-each select="$record-separators">
349 <variable name="position" select="position()"/>
350 <variable name="prev-separator" select="$record-separators[($position)-1]"/>
351 <variable name="fields" select="exslset:leading(exslset:trailing($doclines, $prev-separator), .)"/>
353 <element name="dl" namespace="&xhtml;">
354 <for-each select="$fields">
356 <when test="starts-with(., ' ') and exslset:leading($fields, .)"/>
358 <variable name="next" select="exslset:intersection(following-sibling::*[not(starts-with(., ' '))][1], $fields)"/>
359 <element name="div" namespace="&xhtml;">
360 <element name="dt" namespace="&xhtml;">
361 <value-of select="normalize-space(substring-before(., ':'))"/>
363 <element name="dd" namespace="&xhtml;">
364 <variable name="firstline">
366 <when test="contains(., ':')">
367 <value-of select="normalize-space(substring-after(., ':'))"/>
370 <value-of select="normalize-space(.)"/>
375 <when test="substring($firstline, string-length($firstline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
376 <value-of select="substring($firstline, 1, string-length($firstline)-1)"/>
379 <value-of select="$firstline"/>
382 <for-each select="exslset:intersection(following-sibling::*[starts-with(., ' ')], exslset:leading($fields, $next))">
383 <variable name="nextline" select="normalize-space(.)"/>
385 <when test="substring($nextline, string-length($nextline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
386 <value-of select="substring($nextline, 1, string-length($nextline)-1)"/>
389 <value-of select="$nextline"/>
401 <call-template name="LesML:comment-out">
402 <with-param name="source" select="substring-after(., '%%')"/>
408 <element name="div" namespace="&xhtml;">
409 <attribute name="class">
412 <apply-templates select="$paragraphized/node()" mode="LesML:finalize">
413 <with-param name="used-footnotes" select="$used-footnote-nodes"/>
416 <if test="$used-footnote-nodes">
417 <element name="section" namespace="&xhtml;">
418 <attribute name="role">
419 <text>doc-endnotes</text>
421 <element name="ol" namespace="&xhtml;">
422 <apply-templates select="$used-footnote-nodes" mode="LesML:finalize">
423 <with-param name="used-footnotes" select="$used-footnote-nodes"/>
431 <call-template name="LesML:parse">
432 <with-param name="lines" select="$docsep|exslset:trailing($lines, $docsep)"/>
433 <with-param name="parent-params" select="$params"/>
437 <template name="LesML:block">
438 <param name="lines" select="/.."/>
439 <variable name="last-lines" select="$lines[normalize-space()!='' and (normalize-space(following-sibling::*[1])='' or position()=last())]"/>
440 <for-each select="$last-lines">
441 <variable name="position" select="position()"/>
442 <variable name="prev-last" select="$last-lines[($position)-1]"/>
443 <variable name="linespans" select="(exslset:intersection(exslset:trailing($lines, $prev-last), exslset:leading($lines, .))|.)[normalize-space()!='']"/>
444 <variable name="prefix" select="substring(translate(., ' 	', ''), 1, 1)"/>
445 <variable name="all-prefixed" select="not($linespans[not(starts-with(translate(., ' 	', ''), $prefix))])"/>
446 <variable name="quoted" select="$all-prefixed and $prefix='»'"/>
447 <variable name="bracketed" select="$all-prefixed and $prefix=']'"/>
449 <when test="count($linespans)=1 and translate(., concat($LESML_SECTION_BREAK_CHARS, ' 	'), '')=''">
450 <element name="hr" namespace="&xhtml;"/>
452 <when test="$quoted or $bracketed">
453 <variable name="innerlines-fragment">
454 <for-each select="$linespans">
455 <variable name="inner">
456 <value-of select="substring-after(., $prefix)"/>
460 <when test="starts-with($inner, ' ') or starts-with($inner, '	')">
461 <value-of select="substring($inner, 1+count(exslstr:tokenize($inner, '')[normalize-space()='' and not(preceding-sibling::*[normalize-space()!=''])]))"/>
464 <value-of select="$inner"/>
470 <variable name="blocked-fragment">
471 <call-template name="LesML:block">
472 <with-param name="lines" select="exsl:node-set($innerlines-fragment)/*"/>
475 <variable name="innerpars" select="exsl:node-set($blocked-fragment)/node()"/>
477 <when test="$quoted and $innerpars[position()=last() and self::html:footer]">
478 <element name="figure" namespace="&xhtml;">
479 <element name="blockquote" namespace="&xhtml;">
480 <copy-of select="$innerpars[position()!=last()]"/>
482 <element name="figcaption" namespace="&xhtml;">
483 <copy-of select="$innerpars[last()]/node()"/>
487 <when test="$quoted">
488 <element name="blockquote" namespace="&xhtml;">
489 <copy-of select="$innerpars"/>
492 <when test="$bracketed">
493 <element name="footer" namespace="&xhtml;">
494 <copy-of select="$innerpars"/>
500 <variable name="preformatted" select="$all-prefixed and $prefix='|'"/>
501 <variable name="text">
502 <for-each select="$linespans">
504 <when test="$preformatted">
505 <value-of select="substring-after(., '|')"/>
508 <value-of select="normalize-space()"/>
511 <if test="position()!=count($linespans)">
513 <when test="$preformatted">
524 <when test="$preformatted">
525 <element name="pre" namespace="&xhtml;">
526 <call-template name="LesML:id-and-contents">
527 <with-param name="source" select="$text"/>
531 <when test="string($text)=''"/>
532 <when test="starts-with($text, '⁌') and &sigiled-text;">
533 <element name="h1" namespace="&xhtml;">
534 <call-template name="LesML:id-and-contents">
535 <with-param name="source" select="&unsigiled-text;"/>
539 <when test="starts-with($text, '§') and &sigiled-text;">
540 <element name="h2" namespace="&xhtml;">
541 <call-template name="LesML:id-and-contents">
542 <with-param name="source" select="&unsigiled-text;"/>
546 <when test="starts-with($text, '❦') and &sigiled-text;">
547 <element name="h3" namespace="&xhtml;">
548 <call-template name="LesML:id-and-contents">
549 <with-param name="source" select="&unsigiled-text;"/>
553 <when test="starts-with($text, '✠') and &sigiled-text;">
554 <element name="h4" namespace="&xhtml;">
555 <call-template name="LesML:id-and-contents">
556 <with-param name="source" select="&unsigiled-text;"/>
560 <when test="starts-with($text, '•') and &sigiled-text;">
561 <element name="li" namespace="&xhtml;">
562 <attribute name="class">
563 <text>unordered</text>
565 <attribute name="aria-level">
568 <element name="p" namespace="&xhtml;">
569 <call-template name="LesML:id-and-contents">
570 <with-param name="source" select="&unsigiled-text;"/>
575 <when test="starts-with($text, '🔢') and &sigiled-text;">
576 <element name="li" namespace="&xhtml;">
577 <attribute name="class">
580 <attribute name="aria-level">
583 <element name="p" namespace="&xhtml;">
584 <call-template name="LesML:id-and-contents">
585 <with-param name="source" select="&unsigiled-text;"/>
590 <when test="starts-with($text, '◦') and &sigiled-text;">
591 <element name="li" namespace="&xhtml;">
592 <attribute name="class">
593 <text>unordered</text>
595 <attribute name="aria-level">
598 <element name="p" namespace="&xhtml;">
599 <call-template name="LesML:id-and-contents">
600 <with-param name="source" select="&unsigiled-text;"/>
605 <when test="starts-with($text, '🔠') and &sigiled-text;">
606 <element name="li" namespace="&xhtml;">
607 <attribute name="class">
610 <attribute name="aria-level">
613 <element name="p" namespace="&xhtml;">
614 <call-template name="LesML:id-and-contents">
615 <with-param name="source" select="&unsigiled-text;"/>
620 <when test="starts-with($text, '▪') and &sigiled-text;">
621 <element name="li" namespace="&xhtml;">
622 <attribute name="class">
623 <text>unordered</text>
625 <attribute name="aria-level">
628 <element name="p" namespace="&xhtml;">
629 <call-template name="LesML:id-and-contents">
630 <with-param name="source" select="&unsigiled-text;"/>
635 <when test="starts-with($text, '🔡') and &sigiled-text;">
636 <element name="li" namespace="&xhtml;">
637 <attribute name="class">
640 <attribute name="aria-level">
643 <element name="p" namespace="&xhtml;">
644 <call-template name="LesML:id-and-contents">
645 <with-param name="source" select="&unsigiled-text;"/>
650 <when test="starts-with($text, '⁃') and &sigiled-text;">
651 <element name="li" namespace="&xhtml;">
652 <attribute name="class">
653 <text>unordered</text>
655 <attribute name="aria-level">
658 <element name="p" namespace="&xhtml;">
659 <call-template name="LesML:id-and-contents">
660 <with-param name="source" select="&unsigiled-text;"/>
665 <when test="starts-with($text, '🔣') and &sigiled-text;">
666 <element name="li" namespace="&xhtml;">
667 <attribute name="class">
670 <attribute name="aria-level">
673 <element name="p" namespace="&xhtml;">
674 <call-template name="LesML:id-and-contents">
675 <with-param name="source" select="&unsigiled-text;"/>
680 <when test="starts-with($text, '※') and &sigiled-text;">
681 <element name="section" namespace="&xhtml;">
682 <attribute name="role">
685 <attribute name="class">
688 <element name="p" namespace="&xhtml;">
689 <call-template name="LesML:id-and-contents">
690 <with-param name="source" select="&unsigiled-text;"/>
695 <when test="starts-with($text, '☡') and &sigiled-text;">
696 <element name="section" namespace="&xhtml;">
697 <attribute name="role">
700 <attribute name="class">
703 <element name="p" namespace="&xhtml;">
704 <call-template name="LesML:id-and-contents">
705 <with-param name="source" select="&unsigiled-text;"/>
710 <when test="starts-with($text, '⯑') and &sigiled-text;">
711 <element name="section" namespace="&xhtml;">
712 <attribute name="role">
715 <attribute name="class">
718 <element name="p" namespace="&xhtml;">
719 <call-template name="LesML:id-and-contents">
720 <with-param name="source" select="&unsigiled-text;"/>
725 <when test="starts-with($text, '@') and &sigiled-text;">
726 <element name="section" namespace="&xhtml;">
727 <attribute name="role">
728 <text>doc-abstract</text>
730 <element name="p" namespace="&xhtml;">
731 <call-template name="LesML:id-and-contents">
732 <with-param name="source" select="&unsigiled-text;"/>
737 <when test="starts-with($text, '🛈') and &sigiled-text;">
738 <element name="section" namespace="&xhtml;">
739 <attribute name="role">
742 <element name="p" namespace="&xhtml;">
743 <call-template name="LesML:id-and-contents">
744 <with-param name="source" select="&unsigiled-text;"/>
749 <when test="starts-with($text, '⚠') and &sigiled-text;">
750 <element name="section" namespace="&xhtml;">
751 <attribute name="role">
752 <text>doc-notice</text>
754 <element name="p" namespace="&xhtml;">
755 <call-template name="LesML:id-and-contents">
756 <with-param name="source" select="&unsigiled-text;"/>
761 <when test="starts-with($text, '⋯') and &sigiled-text;">
762 <element name="div" namespace="&xhtml;">
763 <processing-instruction name="LesML-Continuation"/>
764 <element name="p" namespace="&xhtml;">
765 <call-template name="LesML:id-and-contents">
766 <with-param name="source" select="&unsigiled-text;"/>
771 <when test="starts-with($text, '^') and &sigiled-text;">
772 <element name="li" namespace="&xhtml;">
773 <attribute name="class">
774 <text>ordered footnote</text>
776 <attribute name="aria-level">
779 <processing-instruction name="LesML-Footnote"/>
780 <element name="p" namespace="&xhtml;">
781 <call-template name="LesML:id-and-contents">
782 <with-param name="source" select="&unsigiled-text;"/>
787 <when test="starts-with($text, '#') and &sigiled-text;">
788 <call-template name="LesML:comment-out">
789 <with-param name="source" select="&unsigiled-text;"/>
793 <element name="p" namespace="&xhtml;">
794 <call-template name="LesML:id-and-contents">
795 <with-param name="source" select="$text"/>
804 <template name="LesML:paragraphize">
805 <param name="lines" select="/.."/>
806 <variable name="blocked-fragment">
807 <call-template name="LesML:block">
808 <with-param name="lines" select="$lines"/>
811 <variable name="blocked" select="exsl:node-set($blocked-fragment)"/>
812 <variable name="footnote-ids" select="$blocked//html:li[processing-instruction()[local-name()='LesML-Footnote']]/html:p[1]/@id"/>
813 <variable name="inlined-fragment">
814 <apply-templates select="$blocked/node()" mode="LesML:comment">
815 <with-param name="footnote-ids" select="$footnote-ids"/>
818 <apply-templates select="exsl:node-set($inlined-fragment)/node()" mode="LesML:finalize-tree"/>
820 <template match="html:script[@type='text/lesml']">
821 <variable name="source">
822 <for-each select=".//text()">
823 <value-of select="."/>
826 <element name="div" namespace="&xhtml;">
827 <call-template name="LesML:parse">
828 <with-param name="lines" select="LesML:split($source)"/>
832 <template match="html:ol[processing-instruction()[local-name()='LesML-Footnote']]|processing-instruction()[local-name()='LesML-Footnote']" mode="LesML:finalize" priority="1"/>
833 <template match="html:a[@role='doc-noteref']" mode="LesML:finalize">
834 <param name="used-footnotes" select="/.."/>
835 <variable name="matching-note" select="$used-footnotes[concat('#', @id)=current()/@href]"/>
837 <apply-templates select="@*" mode="LesML:finalize">
838 <with-param name="used-footnotes" select="$used-footnotes"/>
841 <when test="$matching-note">
842 <value-of select="$matching-note/@value"/>
845 <apply-templates select="node()" mode="LesML:finalize">
846 <with-param name="used-footnotes" select="$used-footnotes"/>
852 <template match="html:p[position()=1 and ancestor::*]" mode="LesML:finalize">
853 <param name="used-footnotes" select="/.."/>
854 <variable name="content" select="@*[not(&pilcrow-atts;)]|node()"/>
857 <apply-templates select="$content" mode="LesML:finalize">
858 <with-param name="used-footnotes" select="$used-footnotes"/>
863 <template match="html:section" mode="LesML:finalize">
864 <param name="used-footnotes" select="/.."/>
865 <variable name="notinsection" select="following-sibling::node()[not(html:li/@aria-level>1)][1]"/>
867 <apply-templates select="@*|html:p[1]/@*[&pilcrow-atts;]" mode="LesML:finalize"/>
868 <apply-templates select="node()" mode="LesML:finalize"/>
869 <for-each select="exslset:leading(following-sibling::node(), $notinsection)">
871 <apply-templates select="@*|node()" mode="LesML:finalize">
872 <with-param name="used-footnotes" select="$used-footnotes"/>
878 <template match="html:*[html:li/@aria-level>1]" mode="LesML:finalize">
879 <param name="used-footnotes" select="/.."/>
880 <if test="not(preceding-sibling::node()[not(html:li/@aria-level>1)][1]/self::html:section)">
882 <apply-templates select="@*|node()" mode="LesML:finalize">
883 <with-param name="used-footnotes" select="$used-footnotes"/>
888 <template match="text()" mode="LesML:finalize">
889 <call-template name="LesML:break-and-unescape">
890 <with-param name="source" select="string()"/>
893 <template match="@*|node()" mode="LesML:finalize" priority="-1">
894 <param name="used-footnotes" select="/.."/>
896 <apply-templates select="@*|html:p[1]/@*[&pilcrow-atts;]" mode="LesML:finalize"/>
897 <apply-templates select="node()" mode="LesML:finalize">
898 <with-param name="used-footnotes" select="$used-footnotes"/>
902 <template match="node()" mode="LesML:finalize-attributes">
903 <variable name="notattr" select="following-sibling::node()[not(self::text() and translate(., ' 	', '')='' or self::LesML:attribute)]"/>
904 <for-each select="(.|exslset:leading(following-sibling::node(), $notattr)[self::LesML:attribute])/@*">
905 <copy-of select="."/>
906 <if test="local-name()='lang' and namespace-uri()=''">
907 <attribute name="xml:lang">
908 <value-of select="."/>
913 <template match="html:li" mode="LesML:finalize-list">
914 <param name="parent-level" select="0"/>
915 <variable name="current-class" select="string(@class)"/>
916 <variable name="current-level" select="number(@aria-level)"/>
917 <variable name="wrapper">
919 <when test="contains(concat(' ', @class, ' '), ' ordered ')">
927 <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]"/>
928 <element name="{$wrapper}" namespace="&xhtml;">
929 <if test="contains(concat(' ', @class, ' '), ' footnote ')">
930 <processing-instruction name="LesML-Footnote"/>
932 <for-each select=".|exslset:leading(following-sibling::node(), $notinlist)[self::html:li and @aria-level=$current-level]">
933 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
935 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
936 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
937 <apply-templates select="node()" mode="LesML:finalize-tree"/>
939 <if test="$notcontinuation/self::html:li[@aria-level>$current-level]">
940 <apply-templates select="$notcontinuation" mode="LesML:finalize-list">
941 <with-param name="parent-level" select="$current-level"/>
947 <if test="$notinlist/self::html:li[@aria-level>$parent-level]">
948 <apply-templates select="$notinlist" mode="LesML:finalize-list">
949 <with-param name="parent-level" select="$parent-level"/>
953 <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"/>
954 <template match="LesML:attribute|text()[following-sibling::node()[position()=1 and self::LesML:attribute]]" mode="LesML:finalize-tree" priority="1">
955 <element name="span" namespace="&xhtml;">
956 <apply-templates select="." mode="LesML:finalize-attributes"/>
957 <if test="self::text()">
962 <template match="html:div" mode="LesML:finalize-tree">
963 <if test="not(processing-instruction()[local-name()='LesML-Continuation']) or not(preceding-sibling::node()[position()=1 and self::html:* and contains(' div h1 h2 h3 h4 h5 h6 li section ', local-name())])">
964 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
966 <when test="processing-instruction()[local-name()='LesML-Continuation'] and $notcontinuation[self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
967 <variable name="notcontinuation2" select="$notcontinuation/following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
968 <element name="hgroup" namespace="&xhtml;">
969 <apply-templates select="node()" mode="LesML:finalize-tree"/>
970 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation2)">
972 <when test="self::html:div">
973 <apply-templates select="node()" mode="LesML:finalize-tree"/>
977 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
984 <when test="not(processing-instruction()[local-name()='LesML-Continuation'])">
986 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
987 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
988 <apply-templates select="node()" mode="LesML:finalize-tree"/>
993 <apply-templates select="node()" mode="LesML:finalize-tree"/>
994 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
995 <apply-templates select="node()" mode="LesML:finalize-tree"/>
1001 <template match="html:h1|html:h2|html:h3|html:h4|html:h5|html:h6" mode="LesML:finalize-tree">
1002 <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())]">
1004 <when test="following-sibling::node()[position()=1 and self::html:div]/processing-instruction()[local-name()='LesML-Continuation']">
1005 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
1006 <element name="hgroup" namespace="&xhtml;">
1008 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
1010 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
1011 <apply-templates select="node()" mode="LesML:finalize-tree"/>
1017 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
1023 <template match="html:li" mode="LesML:finalize-tree">
1024 <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)]">
1025 <apply-templates select="." mode="LesML:finalize-list"/>
1028 <template match="html:section" mode="LesML:finalize-tree">
1029 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
1031 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
1032 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
1033 <apply-templates select="node()" mode="LesML:finalize-tree"/>
1037 <template match="processing-instruction()[local-name()='LesML-Continuation']" mode="LesML:finalize-tree"/>
1038 <template match="processing-instruction()[local-name()='LesML-Token-Escape']" mode="LesML:finalize-tree">
1039 <value-of select="."/>
1041 <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
1043 <apply-templates select="." mode="LesML:finalize-attributes"/>
1044 <apply-templates select="node()" mode="LesML:finalize-tree"/>
1047 <template match="node()" mode="LesML:inline">
1048 <param name="element-name"/>
1049 <param name="element-namespace" select="'http://www.w3.org/1999/xhtml'"/>
1050 <param name="start-sigil"/>
1051 <param name="end-sigil"/>
1052 <param name="class"/>
1053 <param name="role"/>
1055 <when test="self::*">
1056 <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
1057 <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))"/>
1059 <when test="$end-node and $has-start-node">
1060 <variable name="preceding">
1061 <copy-of select="$end-node/preceding-sibling::node()"/>
1062 <value-of select="substring-before($end-node, $end-sigil)"/>
1064 <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., $start-sigil)][last()]"/>
1065 <variable name="start-tokens" select="LesML:split($start-node, $start-sigil)"/>
1066 <variable name="wrapped">
1068 <copy-of select="@*"/>
1069 <copy-of select="$start-node/preceding-sibling::node()"/>
1070 <for-each select="$start-tokens[position()!=last()]">
1071 <value-of select="."/>
1072 <if test="position()!=last()">
1073 <value-of select="$start-sigil"/>
1076 <element name="{$element-name}" namespace="{$element-namespace}">
1077 <if test="string($role)!=''">
1078 <attribute name="role">
1079 <value-of select="$role"/>
1082 <if test="string($class)!=''">
1083 <attribute name="class">
1084 <value-of select="$class"/>
1087 <value-of select="$start-tokens[last()]"/>
1088 <copy-of select="$start-node/following-sibling::node()"/>
1090 <value-of select="substring-after($end-node, $end-sigil)"/>
1091 <copy-of select="$end-node/following-sibling::node()"/>
1094 <apply-templates select="exsl:node-set($wrapped)/*" mode="LesML:inline">
1095 <with-param name="element-name" select="$element-name"/>
1096 <with-param name="element-namespace" select="$element-namespace"/>
1097 <with-param name="start-sigil" select="$start-sigil"/>
1098 <with-param name="end-sigil" select="$end-sigil"/>
1099 <with-param name="role" select="$role"/>
1104 <copy-of select="@*"/>
1105 <apply-templates select="node()" mode="LesML:inline">
1106 <with-param name="element-name" select="$element-name"/>
1107 <with-param name="element-namespace" select="$element-namespace"/>
1108 <with-param name="start-sigil" select="$start-sigil"/>
1109 <with-param name="end-sigil" select="$end-sigil"/>
1110 <with-param name="role" select="$role"/>
1117 <copy-of select="."/>
1121 <template match="*" mode="LesML:partition">
1122 <param name="start-sigil"/>
1123 <param name="end-sigil"/>
1124 <param name="separator"/>
1125 <param name="ncname-keys" select="false()"/>
1126 <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
1127 <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))"/>
1129 <when test="$end-node and $has-start-node">
1130 <variable name="preceding-fragment">
1131 <copy-of select="$end-node/preceding-sibling::node()"/>
1132 <value-of select="substring-before($end-node, $end-sigil)"/>
1134 <variable name="preceding" select="exsl:node-set($preceding-fragment)/node()"/>
1135 <variable name="start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()][not($ncname-keys) or not(following-sibling::* or following-sibling::comment())]"/>
1136 <variable name="start-tokens" select="LesML:split($start-node, $start-sigil)"/>
1137 <variable name="innards-fragment">
1138 <value-of select="$start-tokens[last()]"/>
1139 <copy-of select="$start-node/following-sibling::node()"/>
1141 <variable name="innards" select="exsl:node-set($innards-fragment)/node()"/>
1142 <variable name="separator-node" select="($innards[self::text() and contains(., $separator)])[not($ncname-keys)*(last()-1)+1]"/>
1144 <when test="not($start-node) or $separator-node[following-sibling::* or following-sibling::comment()]">
1145 <variable name="bad-start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()]"/>
1146 <element name="span" namespace="&xhtml;">
1147 <copy-of select="$bad-start-node/preceding-sibling::node()"/>
1148 <for-each select="LesML:split($bad-start-node, $start-sigil)">
1149 <value-of select="."/>
1150 <if test="position()!=last()">
1151 <processing-instruction name="LesML-Token-Escape">
1152 <value-of select="$start-sigil"/>
1153 </processing-instruction>
1156 <copy-of select="$bad-start-node/following-sibling::node()"/>
1157 <value-of select="$end-sigil"/>
1158 <value-of select="substring-after($end-node, $end-sigil)"/>
1159 <copy-of select="$end-node/following-sibling::node()"/>
1162 <when test="$separator-node">
1163 <variable name="keyval" select="LesML:split($separator-node, $separator)"/>
1164 <variable name="key-fragment">
1166 <when test="$ncname-keys">
1167 <for-each select="$separator-node/preceding-sibling::node()">
1168 <value-of select="."/>
1170 <value-of select="$keyval[1]"/>
1173 <copy-of select="$separator-node/preceding-sibling::node()"/>
1174 <for-each select="$keyval[position()!=last()]">
1175 <value-of select="."/>
1176 <if test="position()!=last()">
1177 <value-of select="$separator"/>
1183 <variable name="value">
1185 <when test="$ncname-keys">
1186 <for-each select="$keyval[position()!=1]">
1187 <value-of select="."/>
1188 <if test="position()!=last()">
1189 <value-of select="$separator"/>
1194 <value-of select="$keyval[last()]"/>
1197 <for-each select="$separator-node/following-sibling::node()">
1198 <value-of select="."/>
1202 <when test="not($ncname-keys) or /self::node()[translate(normalize-space($key-fragment), ' /([,*', '')=$key-fragment and exsldyn:evaluate(concat('not(self::html:', $key-fragment, ')'))]">
1203 <element name="span" namespace="&xhtml;">
1204 <copy-of select="$start-node/preceding-sibling::node()"/>
1205 <for-each select="$start-tokens[position()!=last()]">
1206 <value-of select="."/>
1207 <if test="position()!=last()">
1208 <value-of select="$start-sigil"/>
1212 <element name="span" namespace="&xhtml;">
1213 <copy-of select="$key-fragment"/>
1215 <element name="span" namespace="&xhtml;">
1216 <value-of select="$value"/>
1218 <element name="span" namespace="&xhtml;">
1219 <value-of select="substring-after($end-node, $end-sigil)"/>
1220 <copy-of select="$end-node/following-sibling::node()"/>
1224 <element name="span" namespace="&xhtml;">
1225 <copy-of select="$start-node/preceding-sibling::node()"/>
1226 <for-each select="$start-tokens[position()!=last()]">
1227 <value-of select="."/>
1228 <if test="position()!=last()">
1229 <value-of select="$start-sigil"/>
1232 <processing-instruction name="LesML-Token-Escape">
1233 <value-of select="$start-sigil"/>
1234 </processing-instruction>
1235 <value-of select="$start-tokens[last()]"/>
1236 <value-of select="$start-node/following-sibling::node()"/>
1237 <value-of select="$end-sigil"/>
1238 <value-of select="substring-after($end-node, $end-sigil)"/>
1239 <copy-of select="$end-node/following-sibling::node()"/>
1245 <element name="span" namespace="&xhtml;">
1246 <copy-of select="$start-node/preceding-sibling::node()"/>
1247 <for-each select="$start-tokens[position()!=last()]">
1248 <value-of select="."/>
1249 <if test="position()!=last()">
1250 <value-of select="$start-sigil"/>
1253 <processing-instruction name="LesML-Token-Escape">
1254 <value-of select="$start-sigil"/>
1255 </processing-instruction>
1256 <value-of select="$start-tokens[last()]"/>
1257 <copy-of select="$start-node/following-sibling::node()"/>
1258 <value-of select="$end-sigil"/>
1259 <value-of select="substring-after($end-node, $end-sigil)"/>
1260 <copy-of select="$end-node/following-sibling::node()"/>
1265 <when test="$end-node">
1266 <element name="span" namespace="&xhtml;">
1267 <copy-of select="$end-node/preceding-sibling::node()"/>
1268 <value-of select="substring-before($end-node, $end-sigil)"/>
1269 <processing-instruction name="LesML-Token-Escape">
1270 <value-of select="$end-sigil"/>
1271 </processing-instruction>
1272 <value-of select="substring-after($end-node, $end-sigil)"/>
1273 <copy-of select="$end-node/following-sibling::node()"/>
1277 <processing-instruction name="LesML-All-Done"/>
1281 <template match="node()" mode="LesML:comment">
1282 <param name="footnote-ids" select="/.."/>
1283 <variable name="result">
1285 <when test="self::*">
1286 <variable name="start-node" select="text()[contains(., '⌦')][1]"/>
1287 <variable name="after-start">
1288 <if test="$start-node">
1289 <value-of select="substring-after($start-node, '⌦')"/>
1292 <variable name="has-end-node" select="contains($after-start, '⌫') or $start-node/following-sibling::text()[contains(., '⌫')]"/>
1294 <when test="$start-node and $has-end-node">
1295 <variable name="following">
1296 <value-of select="$after-start"/>
1297 <copy-of select="$start-node/following-sibling::node()"/>
1299 <variable name="end-node" select="exsl:node-set($following)/text()[contains(., '⌫')][last()]"/>
1300 <variable name="comment">
1301 <for-each select="$end-node/preceding-sibling::node()">
1302 <value-of select="."/>
1304 <value-of select="substring-before($end-node, '⌫')"/>
1306 <variable name="rest-fragment">
1307 <element name="span" namespace="&xhtml;">
1308 <value-of select="substring-after($end-node, '⌫')"/>
1309 <copy-of select="$end-node/following-sibling::node()"/>
1312 <variable name="commented-rest-fragment">
1313 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:comment">
1314 <with-param name="footnote-ids" select="$footnote-ids"/>
1318 <copy-of select="@*"/>
1319 <copy-of select="$start-node/preceding-sibling::node()"/>
1320 <copy-of select="substring-before($start-node, '⌦')"/>
1321 <call-template name="LesML:comment-out">
1322 <with-param name="source" select="string($comment)"/>
1324 <copy-of select="exsl:node-set($commented-rest-fragment)/*/node()"/>
1327 <when test="$start-node">
1328 <variable name="rest-fragment">
1329 <element name="div" namespace="&xhtml;">
1330 <value-of select="substring-after($after-start, '⌦')"/>
1331 <copy-of select="$start-node/following-sibling::node()"/>
1334 <variable name="commented-rest-fragment">
1335 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:comment">
1336 <with-param name="footnote-ids" select="$footnote-ids"/>
1340 <copy-of select="@*"/>
1341 <copy-of select="$start-node/preceding-sibling::node()"/>
1342 <copy-of select="substring-before($start-node, '⌦')"/>
1344 <copy-of select="exsl:node-set($commented-rest-fragment)/*/node()"/>
1349 <copy-of select="@*"/>
1350 <apply-templates select="node()" mode="LesML:comment">
1351 <with-param name="footnote-ids" select="$footnote-ids"/>
1357 <when test="self::text()[contains(., '⌧')]">
1358 <for-each select="LesML:split(., '⌧')">
1359 <value-of select="."/>
1360 <if test="position()!=last()">
1361 <call-template name="LesML:comment-out"/>
1366 <copy-of select="."/>
1370 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:attrify">
1371 <with-param name="footnote-ids" select="$footnote-ids"/>
1374 <template match="node()" mode="LesML:attrify">
1375 <param name="footnote-ids" select="/.."/>
1376 <variable name="result">
1378 <when test="self::*">
1379 <variable name="partitioned-fragment">
1380 <apply-templates mode="LesML:partition" select=".">
1381 <with-param name="start-sigil" select="'{@'"/>
1382 <with-param name="end-sigil" select="'"}'"/>
1383 <with-param name="separator" select="'="'"/>
1384 <with-param name="ncname-keys" select="true()"/>
1387 <variable name="partitioned" select="exsl:node-set($partitioned-fragment)/node()"/>
1389 <when test="count($partitioned)>1">
1390 <variable name="processed">
1392 <copy-of select="@*"/>
1393 <copy-of select="$partitioned[1]/node()"/>
1394 <element name="LesML:attribute" namespace="&LesML;">
1395 <attribute name="{$partitioned[2]}">
1396 <value-of select="$partitioned[3]"/>
1399 <copy-of select="$partitioned[4]/node()"/>
1402 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:attrify">
1403 <with-param name="footnote-ids" select="$footnote-ids"/>
1406 <when test="$partitioned[self::processing-instruction() and local-name()='LesML-All-Done']">
1408 <copy-of select="@*"/>
1409 <apply-templates select="node()" mode="LesML:attrify">
1410 <with-param name="footnote-ids" select="$footnote-ids"/>
1415 <variable name="processed">
1417 <copy-of select="@*"/>
1418 <copy-of select="$partitioned/node()"/>
1421 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:attrify">
1422 <with-param name="footnote-ids" select="$footnote-ids"/>
1428 <copy-of select="."/>
1432 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:linkify">
1433 <with-param name="footnote-ids" select="$footnote-ids"/>
1436 <template match="node()" mode="LesML:linkify">
1437 <param name="footnote-ids" select="/.."/>
1438 <variable name="result">
1440 <when test="processing-instruction()[local-name()='LesML-All-Done']">
1442 <copy-of select="@*|node()[not(self::processing-instruction() and local-name()='LesML-All-Done')]"/>
1445 <when test="self::*">
1446 <variable name="partitioned-fragment">
1447 <apply-templates mode="LesML:partition" select=".">
1448 <with-param name="start-sigil" select="'{🔗'"/>
1449 <with-param name="end-sigil" select="'>}'"/>
1450 <with-param name="separator" select="'<'"/>
1453 <variable name="partitioned" select="exsl:node-set($partitioned-fragment)/node()"/>
1455 <when test="count($partitioned)>1">
1456 <variable name="processed">
1458 <copy-of select="@*"/>
1459 <copy-of select="$partitioned[1]/node()"/>
1460 <element name="a" namespace="&xhtml;">
1461 <attribute name="href">
1462 <value-of select="$partitioned[3]"/>
1464 <processing-instruction name="LesML-All-Done"/>
1466 <when test="not($partitioned[2]/node())">
1467 <value-of select="$partitioned[3]"/>
1470 <copy-of select="$partitioned[2]/node()"/>
1474 <copy-of select="$partitioned[4]/node()"/>
1477 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:linkify">
1478 <with-param name="footnote-ids" select="$footnote-ids"/>
1481 <when test="$partitioned[self::processing-instruction() and local-name()='LesML-All-Done']">
1483 <copy-of select="@*"/>
1484 <apply-templates select="node()" mode="LesML:linkify">
1485 <with-param name="footnote-ids" select="$footnote-ids"/>
1490 <variable name="processed">
1492 <copy-of select="@*"/>
1493 <copy-of select="$partitioned/node()"/>
1496 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:linkify">
1497 <with-param name="footnote-ids" select="$footnote-ids"/>
1503 <copy-of select="."/>
1507 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:strikethrough">
1508 <with-param name="footnote-ids" select="$footnote-ids"/>
1511 <template match="node()" mode="LesML:strikethrough">
1512 <param name="footnote-ids" select="/.."/>
1513 <variable name="result">
1514 <apply-templates select="." mode="LesML:inline">
1515 <with-param name="element-name" select="'s'"/>
1516 <with-param name="element-namespace" select="'&xhtml;'"/>
1517 <with-param name="start-sigil" select="'⸠'"/>
1518 <with-param name="end-sigil" select="'⸡'"/>
1521 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:underline">
1522 <with-param name="footnote-ids" select="$footnote-ids"/>
1525 <template match="node()" mode="LesML:underline">
1526 <param name="footnote-ids" select="/.."/>
1527 <variable name="result">
1528 <apply-templates select="." mode="LesML:inline">
1529 <with-param name="element-name" select="'u'"/>
1530 <with-param name="element-namespace" select="'&xhtml;'"/>
1531 <with-param name="start-sigil" select="'⸤'"/>
1532 <with-param name="end-sigil" select="'⸥'"/>
1535 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:noted">
1536 <with-param name="footnote-ids" select="$footnote-ids"/>
1539 <template match="node()" mode="LesML:noted">
1540 <param name="footnote-ids" select="/.."/>
1541 <variable name="result">
1542 <apply-templates select="." mode="LesML:inline">
1543 <with-param name="element-name" select="'small'"/>
1544 <with-param name="element-namespace" select="'&xhtml;'"/>
1545 <with-param name="start-sigil" select="'⟦'"/>
1546 <with-param name="end-sigil" select="'⟧'"/>
1547 <with-param name="role" select="'note'"/>
1550 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:parenthetical">
1551 <with-param name="footnote-ids" select="$footnote-ids"/>
1554 <template match="node()" mode="LesML:parenthetical">
1555 <param name="footnote-ids" select="/.."/>
1556 <variable name="result">
1557 <apply-templates select="." mode="LesML:inline">
1558 <with-param name="element-name" select="'small'"/>
1559 <with-param name="element-namespace" select="'&xhtml;'"/>
1560 <with-param name="start-sigil" select="'⸨'"/>
1561 <with-param name="end-sigil" select="'⸩'"/>
1564 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:code">
1565 <with-param name="footnote-ids" select="$footnote-ids"/>
1568 <template match="node()" mode="LesML:code">
1569 <param name="footnote-ids" select="/.."/>
1570 <variable name="result">
1571 <apply-templates select="." mode="LesML:inline">
1572 <with-param name="element-name" select="'code'"/>
1573 <with-param name="element-namespace" select="'&xhtml;'"/>
1574 <with-param name="start-sigil" select="'`'"/>
1575 <with-param name="end-sigil" select="'´'"/>
1578 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:titled">
1579 <with-param name="footnote-ids" select="$footnote-ids"/>
1582 <template match="node()" mode="LesML:titled">
1583 <param name="footnote-ids" select="/.."/>
1584 <variable name="result">
1585 <apply-templates select="." mode="LesML:inline">
1586 <with-param name="element-name" select="'cite'"/>
1587 <with-param name="element-namespace" select="'&xhtml;'"/>
1588 <with-param name="start-sigil" select="'⟪'"/>
1589 <with-param name="end-sigil" select="'⟫'"/>
1592 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:named">
1593 <with-param name="footnote-ids" select="$footnote-ids"/>
1596 <template match="node()" mode="LesML:named">
1597 <param name="footnote-ids" select="/.."/>
1598 <variable name="result">
1599 <apply-templates select="." mode="LesML:inline">
1600 <with-param name="element-name" select="'u'"/>
1601 <with-param name="element-namespace" select="'&xhtml;'"/>
1602 <with-param name="start-sigil" select="'⸶'"/>
1603 <with-param name="end-sigil" select="'⸷'"/>
1604 <with-param name="class" select="'name'"/>
1607 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:offset">
1608 <with-param name="footnote-ids" select="$footnote-ids"/>
1611 <template match="node()" mode="LesML:offset">
1612 <param name="footnote-ids" select="/.."/>
1613 <variable name="result">
1614 <apply-templates select="." mode="LesML:inline">
1615 <with-param name="element-name" select="'i'"/>
1616 <with-param name="element-namespace" select="'&xhtml;'"/>
1617 <with-param name="start-sigil" select="'⟨'"/>
1618 <with-param name="end-sigil" select="'⟩'"/>
1621 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:bolded">
1622 <with-param name="footnote-ids" select="$footnote-ids"/>
1625 <template match="node()" mode="LesML:bolded">
1626 <param name="footnote-ids" select="/.."/>
1627 <variable name="result">
1628 <apply-templates select="." mode="LesML:inline">
1629 <with-param name="element-name" select="'b'"/>
1630 <with-param name="element-namespace" select="'&xhtml;'"/>
1631 <with-param name="start-sigil" select="'⦃'"/>
1632 <with-param name="end-sigil" select="'⦄'"/>
1635 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:important">
1636 <with-param name="footnote-ids" select="$footnote-ids"/>
1639 <template match="node()" mode="LesML:important">
1640 <param name="footnote-ids" select="/.."/>
1641 <variable name="result">
1642 <apply-templates select="." mode="LesML:inline">
1643 <with-param name="element-name" select="'strong'"/>
1644 <with-param name="element-namespace" select="'&xhtml;'"/>
1645 <with-param name="start-sigil" select="'☞'"/>
1646 <with-param name="end-sigil" select="'☜'"/>
1649 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:emphasized">
1650 <with-param name="footnote-ids" select="$footnote-ids"/>
1653 <template match="node()" mode="LesML:emphasized">
1654 <param name="footnote-ids" select="/.."/>
1655 <variable name="result">
1656 <apply-templates select="." mode="LesML:inline">
1657 <with-param name="element-name" select="'em'"/>
1658 <with-param name="element-namespace" select="'&xhtml;'"/>
1659 <with-param name="start-sigil" select="'⹐'"/>
1660 <with-param name="end-sigil" select="'⹑'"/>
1663 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:footnoted">
1664 <with-param name="footnote-ids" select="$footnote-ids"/>
1667 <template match="node()" mode="LesML:footnoted">
1668 <param name="footnote-ids" select="/.."/>
1670 <when test="self::*">
1671 <variable name="start-node" select="text()[contains(., '^')][1]"/>
1672 <variable name="after-start" select="substring-after($start-node, '^')"/>
1673 <variable name="footnote-id" select="substring-before($after-start, '.')"/>
1674 <variable name="matched-footnote" select="$footnote-ids[.=$footnote-id]"/>
1676 <when test="$footnote-id!='' and $matched-footnote">
1677 <variable name="rest-fragment">
1678 <element name="div" namespace="&xhtml;">
1679 <value-of select="substring-after($after-start, '.')"/>
1680 <copy-of select="$start-node/following-sibling::node()"/>
1683 <variable name="footnoted-rest-fragment">
1684 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:footnoted">
1685 <with-param name="footnote-ids" select="$footnote-ids"/>
1689 <copy-of select="@*"/>
1690 <copy-of select="$start-node/preceding-sibling::node()"/>
1691 <copy-of select="substring-before($start-node, '^')"/>
1692 <element name="a" namespace="&xhtml;">
1693 <attribute name="id">
1694 <text>LesML.fnref.</text>
1695 <value-of select="generate-id($start-node)"/>
1697 <attribute name="role">
1698 <text>doc-noteref</text>
1700 <attribute name="href">
1702 <value-of select="$footnote-id"/>
1704 <attribute name="target">
1708 <copy-of select="exsl:node-set($footnoted-rest-fragment)/*/node()"/>
1711 <when test="$start-node">
1712 <variable name="rest-fragment">
1713 <element name="div" namespace="&xhtml;">
1714 <value-of select="substring-after($after-start, '^')"/>
1715 <copy-of select="$start-node/following-sibling::node()"/>
1718 <variable name="footnoted-rest-fragment">
1719 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:footnoted">
1720 <with-param name="footnote-ids" select="$footnote-ids"/>
1724 <copy-of select="@*"/>
1725 <copy-of select="$start-node/preceding-sibling::node()"/>
1726 <copy-of select="substring-before($start-node, '^')"/>
1728 <copy-of select="exsl:node-set($footnoted-rest-fragment)/*/node()"/>
1733 <copy-of select="@*"/>
1734 <apply-templates select="node()" mode="LesML:footnoted">
1735 <with-param name="footnote-ids" select="$footnote-ids"/>
1742 <copy-of select="."/>