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 section-break "*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~">
16 <!ENTITY sigiled-text "(string-length($text)=1 or substring($text, 2, 1)=' ')">
17 <!ENTITY unsigiled-text "substring($text, 3, string-length($text)-2)">
20 xmlns="http://www.w3.org/1999/XSL/Transform"
21 xmlns:LesML="urn:fdc:ladys.computer:20240512:LesML"
22 xmlns:exsl="http://exslt.org/common"
23 xmlns:exslstr="http://exslt.org/strings"
24 xmlns:html="http://www.w3.org/1999/xhtml"
25 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
26 exclude-result-prefixes="LesML"
27 extension-element-prefixes="exsl exslstr"
30 <书社:id>urn:fdc:ladys.computer:20240512:LesML:parser.xslt</书社:id>
31 <template name="LesML:split">
32 <param name="source"/>
33 <param name="separator" select="'
'"/>
35 <when test="contains($source, $separator)">
37 <value-of select="substring-before($source, $separator)"/>
39 <call-template name="LesML:split">
40 <with-param name="source" select="substring-after($source, $separator)"/>
41 <with-param name="separator" select="$separator"/>
46 <value-of select="$source"/>
51 <template name="LesML:break-and-unescape">
52 <param name="source"/>
53 <variable name="broken-fragment">
54 <call-template name="LesML:split">
55 <with-param name="source" select="$source"/>
56 <with-param name="separator" select="'
'"/>
59 <variable name="broken" select="exsl:node-set($broken-fragment)/node()"/>
60 <for-each select="$broken">
61 <call-template name="LesML:unescape">
62 <with-param name="source" select="string()"/>
64 <if test="position()!=count($broken)">
65 <element name="html:br"/>
69 <template name="LesML:unescape">
70 <param name="source"/>
72 <when test="contains($source, '{U+')">
73 <variable name="after" select="substring-after($source, '{U+')"/>
75 <when test="contains($after, '}')">
76 <variable name="inner" select="substring-before($after, '}')"/>
77 <variable name="components">
78 <call-template name="LesML:split">
79 <with-param name="source" select="$inner"/>
80 <with-param name="separator" select="'.'"/>
83 <variable name="component-nodes" select="exsl:node-set($components)/node()"/>
84 <value-of select="substring-before($source, '{U+')"/>
86 <when test="$component-nodes[string(.)='' or translate(., '0123456789ABCDEF', '')!='']">
88 <value-of select="$inner"/>
90 <call-template name="LesML:unescape">
91 <with-param name="source" select="substring-after($after, '}')"/>
95 <for-each select="$component-nodes">
96 <text disable-output-escaping="yes">&#x</text>
97 <value-of select="."/>
100 <call-template name="LesML:unescape">
101 <with-param name="source" select="substring-after($after, '}')"/>
107 <value-of select="substring-before($source, '{U+')"/>
109 <call-template name="LesML:unescape">
110 <with-param name="source" select="$after"/>
116 <value-of select="$source"/>
120 <template name="LesML:id-and-contents">
121 <param name="source"/>
123 <when test="starts-with($source, '¶')">
125 <when test="contains($source, ' ')">
126 <variable name="id" select="substring-before(substring-after($source, '¶'), ' ')"/>
128 <attribute name="id">
129 <value-of select="$id"/>
132 <value-of select="substring-after($source, ' ')"/>
135 <attribute name="id">
136 <value-of select="substring-after($source, '¶')"/>
142 <value-of select="$source"/>
146 <template name="LesML:parse">
147 <param name="lines" select="/.."/>
148 <param name="parent-params" select="/.."/>
149 <variable name="first-line" select="$lines[1]"/>
150 <variable name="shebang">
151 <if test="starts-with($first-line, '#!lesml')">
152 <value-of select="$first-line"/>
155 <variable name="params-string">
157 <when test="starts-with($shebang, '#!lesml@')">
158 <value-of select="substring-after($shebang, '$')"/>
161 <value-of select="substring-after($shebang, '#!lesml')"/>
165 <variable name="params-fragment">
167 <when test="$shebang!=''">
169 <if test="starts-with($shebang, '#!lesml@') and contains($shebang, '$')">
175 <value-of select="substring-before(substring-after($shebang, '#!lesml@'), '$')"/>
179 <for-each select="exslstr:tokenize($params-string)">
181 <when test="contains(., '=')">
184 <value-of select="substring-before(., '=')"/>
187 <value-of select="substring-after(., '=')"/>
194 <value-of select="."/>
203 <when test="$parent-params">
204 <copy-of select="$parent-params"/>
211 <variable name="params" select="exsl:node-set($params-fragment)/*"/>
212 <variable name="noshebang" select="$lines[position()>1 or not(starts-with(., '#!lesml') or starts-with(., '##'))]"/>
213 <variable name="docsep" select="$noshebang[starts-with(., '#!lesml') or starts-with(., '##')][1]"/>
214 <variable name="doclines" select="$noshebang[not($docsep) or following-sibling::*[generate-id()=generate-id($docsep)]]"/>
215 <if test="starts-with($first-line, '##') and $first-line!='##'">
217 <value-of select="substring-after($first-line, '##')"/>
220 <if test="$shebang!='' or $doclines[normalize-space()!='']">
221 <variable name="record-separators" select="$doclines[starts-with(., '%%')]"/>
222 <element name="html:article">
223 <for-each select="$params/html:div/html:dt[string()=' LANG ']">
224 <attribute name="lang">
225 <value-of select="following-sibling::html:dd"/>
227 <attribute name="xml:lang">
228 <value-of select="following-sibling::html:dd"/>
231 <for-each select="$params/html:div/html:dt[string()='profile']">
232 <attribute name="data-lesml-profile">
233 <value-of select="following-sibling::html:dd"/>
236 <if test="$record-separators[preceding-sibling::*[normalize-space()!='']]">
237 <element name="html:footer">
238 <attribute name="class">
241 <for-each select="$record-separators">
242 <variable name="position" select="position()"/>
243 <variable name="prev-separator" select="$record-separators[($position)-1]"/>
244 <variable name="fields" select="$noshebang[following-sibling::*[generate-id()=generate-id(current())] and (not($prev-separator) or preceding-sibling::*[generate-id()=generate-id($prev-separator)])]"/>
246 <element name="html:dl">
247 <for-each select="$fields">
249 <when test="starts-with(., ' ') and $fields[generate-id()=generate-id(current()/preceding-sibling::*[1])]"/>
251 <variable name="next" select="following-sibling::*[not(starts-with(., ' '))]"/>
252 <element name="html:div">
253 <element name="html:dt">
254 <value-of select="normalize-space(substring-before(., ':'))"/>
256 <element name="html:dd">
257 <variable name="firstline">
259 <when test="contains(., ':')">
260 <value-of select="normalize-space(substring-after(., ':'))"/>
263 <value-of select="normalize-space(.)"/>
268 <when test="substring($firstline, string-length($firstline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
269 <value-of select="substring($firstline, 1, string-length($firstline)-1)"/>
272 <value-of select="$firstline"/>
275 <for-each select="following-sibling::*[starts-with(., ' ') and not(preceding-sibling::*[generate-id()=generate-id($next)])]">
276 <variable name="nextline" select="normalize-space(.)"/>
278 <when test="substring($nextline, string-length($nextline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
279 <value-of select="substring($nextline, 1, string-length($nextline)-1)"/>
282 <value-of select="$nextline"/>
295 <value-of select="substring-after(., '%%')"/>
301 <element name="html:div">
302 <attribute name="class">
305 <call-template name="LesML:paragraphize">
306 <with-param name="lines" select="$doclines[not($record-separators) or preceding-sibling::*[generate-id()=generate-id($record-separators[last()])]]"/>
312 <call-template name="LesML:parse">
313 <with-param name="lines" select="$docsep|$lines[preceding-sibling::*[generate-id()=generate-id($docsep)]]"/>
314 <with-param name="parent-params" select="$params"/>
318 <template name="LesML:paragraphize">
319 <param name="lines" select="/.."/>
320 <variable name="last-lines" select="$lines[normalize-space()!='' and normalize-space(following-sibling::*[1])='']|$lines[last()]"/>
321 <variable name="blocked">
322 <for-each select="$last-lines">
323 <variable name="position" select="position()"/>
324 <variable name="prev-last" select="$last-lines[($position)-1]"/>
325 <variable name="linespans" select="$lines[following-sibling::*[generate-id()=generate-id(current())] and (not($prev-last) or preceding-sibling::*[generate-id()=generate-id($prev-last)]) and normalize-space()!='']|."/>
326 <variable name="quoted" select="not($linespans[not(starts-with(., ' ') or starts-with(., '	'))])"/>
327 <variable name="preformatted" select="not($linespans[not(starts-with(normalize-space(), '|'))])"/>
328 <variable name="text">
329 <for-each select="$linespans">
331 <when test="$preformatted">
332 <value-of select="substring-after(., '|')"/>
335 <value-of select="normalize-space()"/>
338 <if test="position()!=count($linespans)">
340 <when test="$preformatted">
350 <if test="string($text)!=''">
351 <variable name="par">
353 <when test="$preformatted">
354 <element name="html:pre">
355 <call-template name="LesML:id-and-contents">
356 <with-param name="source" select="$text"/>
360 <when test="starts-with($text, '⁌') and &sigiled-text;">
361 <element name="html:h1">
362 <call-template name="LesML:id-and-contents">
363 <with-param name="source" select="&unsigiled-text;"/>
367 <when test="starts-with($text, '§') and &sigiled-text;">
368 <element name="html:h2">
369 <call-template name="LesML:id-and-contents">
370 <with-param name="source" select="&unsigiled-text;"/>
374 <when test="starts-with($text, '❦') and &sigiled-text;">
375 <element name="html:h3">
376 <call-template name="LesML:id-and-contents">
377 <with-param name="source" select="&unsigiled-text;"/>
381 <when test="starts-with($text, '✠') and &sigiled-text;">
382 <element name="html:h4">
383 <call-template name="LesML:id-and-contents">
384 <with-param name="source" select="&unsigiled-text;"/>
388 <when test="starts-with($text, '•') and &sigiled-text;">
389 <element name="html:li">
390 <attribute name="class">
391 <text>unordered</text>
393 <attribute name="data-level">
396 <element name="html:p">
397 <call-template name="LesML:id-and-contents">
398 <with-param name="source" select="&unsigiled-text;"/>
403 <when test="starts-with($text, '🔢') and &sigiled-text;">
404 <element name="html:li">
405 <attribute name="class">
408 <attribute name="data-level">
411 <element name="html:p">
412 <call-template name="LesML:id-and-contents">
413 <with-param name="source" select="&unsigiled-text;"/>
418 <when test="starts-with($text, '◦') and &sigiled-text;">
419 <element name="html:li">
420 <attribute name="class">
421 <text>unordered</text>
423 <attribute name="data-level">
426 <element name="html:p">
427 <call-template name="LesML:id-and-contents">
428 <with-param name="source" select="&unsigiled-text;"/>
433 <when test="starts-with($text, '🔠') and &sigiled-text;">
434 <element name="html:li">
435 <attribute name="class">
438 <attribute name="data-level">
441 <element name="html:p">
442 <call-template name="LesML:id-and-contents">
443 <with-param name="source" select="&unsigiled-text;"/>
448 <when test="starts-with($text, '▪') and &sigiled-text;">
449 <element name="html:li">
450 <attribute name="class">
451 <text>unordered</text>
453 <attribute name="data-level">
456 <element name="html:p">
457 <call-template name="LesML:id-and-contents">
458 <with-param name="source" select="&unsigiled-text;"/>
463 <when test="starts-with($text, '🔡') and &sigiled-text;">
464 <element name="html:li">
465 <attribute name="class">
468 <attribute name="data-level">
471 <element name="html:p">
472 <call-template name="LesML:id-and-contents">
473 <with-param name="source" select="&unsigiled-text;"/>
478 <when test="starts-with($text, '⁃') and &sigiled-text;">
479 <element name="html:li">
480 <attribute name="class">
481 <text>unordered</text>
483 <attribute name="data-level">
486 <element name="html:p">
487 <call-template name="LesML:id-and-contents">
488 <with-param name="source" select="&unsigiled-text;"/>
493 <when test="starts-with($text, '🔣') and &sigiled-text;">
494 <element name="html:li">
495 <attribute name="class">
498 <attribute name="data-level">
501 <element name="html:p">
502 <call-template name="LesML:id-and-contents">
503 <with-param name="source" select="&unsigiled-text;"/>
508 <when test="starts-with($text, '🛈') and &sigiled-text;">
509 <element name="html:div">
510 <attribute name="role">
513 <attribute name="class">
516 <element name="html:p">
517 <call-template name="LesML:id-and-contents">
518 <with-param name="source" select="&unsigiled-text;"/>
523 <when test="starts-with($text, '⯑') and &sigiled-text;">
524 <element name="html:div">
525 <attribute name="role">
528 <attribute name="class">
531 <element name="html:p">
532 <call-template name="LesML:id-and-contents">
533 <with-param name="source" select="&unsigiled-text;"/>
538 <when test="starts-with($text, '⚠︎') and &sigiled-text;">
539 <element name="html:div">
540 <attribute name="role">
543 <attribute name="class">
546 <element name="html:p">
547 <call-template name="LesML:id-and-contents">
548 <with-param name="source" select="&unsigiled-text;"/>
553 <when test="starts-with($text, '※') and &sigiled-text;">
554 <element name="html:div">
555 <attribute name="role">
558 <attribute name="class">
561 <element name="html:p">
562 <call-template name="LesML:id-and-contents">
563 <with-param name="source" select="&unsigiled-text;"/>
568 <when test="starts-with($text, '☡') and &sigiled-text;">
569 <element name="html:div">
570 <attribute name="role">
573 <attribute name="class">
576 <element name="html:p">
577 <call-template name="LesML:id-and-contents">
578 <with-param name="source" select="&unsigiled-text;"/>
583 <when test="starts-with($text, '⋯') and &sigiled-text;">
584 <element name="html:div">
585 <attribute name="class">
586 <text>continuation</text>
588 <element name="html:p">
589 <call-template name="LesML:id-and-contents">
590 <with-param name="source" select="&unsigiled-text;"/>
595 <when test="starts-with($text, '#') and &sigiled-text;">
597 <value-of select="&unsigiled-text;"/>
601 <element name="html:p">
602 <call-template name="LesML:id-and-contents">
603 <with-param name="source" select="$text"/>
610 <when test="translate(string($text), '§ion-break; ', '')=''">
611 <element name="html:hr"/>
613 <when test="$quoted">
614 <element name="html:blockquote">
615 <copy-of select="$par"/>
619 <copy-of select="$par"/>
625 <variable name="inlined">
626 <apply-templates select="exsl:node-set($blocked)/node()" mode="LesML:linkify"/>
628 <apply-templates select="exsl:node-set($inlined)/node()" mode="LesML:finalize-tree"/>
630 <template match="html:script[@type='text/lesml']">
631 <variable name="lines-fragment">
632 <call-template name="LesML:split">
633 <with-param name="source">
634 <for-each select=".//text()">
635 <value-of select="."/>
640 <call-template name="LesML:parse">
641 <with-param name="lines" select="exsl:node-set($lines-fragment)/*"/>
644 <template match="html:blockquote" mode="LesML:finalize-tree">
645 <if test="not(preceding-sibling::node()) or preceding-sibling::node()[position()=1 and not(self::html:blockquote)]">
646 <variable name="notquote" select="following-sibling::node()[not(self::html:blockquote)][1]"/>
647 <variable name="contents">
648 <copy-of select="node()"/>
649 <for-each select="following-sibling::node()[not($notquote) or following-sibling::node()[generate-id()=generate-id($notquote)]]">
650 <copy-of select="node()"/>
653 <variable name="content-nodes" select="exsl:node-set($contents)/node()"/>
654 <variable name="laststarttext" select="$content-nodes[last()]/self::html:p[not(@class) and not(@role)]/node()[self::text() or self::*][position()=1 and self::text()]"/>
656 <when test="starts-with($laststarttext, '— ')">
657 <variable name="caption">
658 <copy-of select="$laststarttext/preceding-sibling::node()"/>
659 <value-of select="substring-after($laststarttext, '— ')"/>
660 <copy-of select="$laststarttext/following-sibling::node()"/>
662 <element name="html:figure">
664 <apply-templates select="@*|$content-nodes[position()!=last()]" mode="LesML:finalize-tree"/>
666 <element name="html:figcaption">
667 <for-each select="$content-nodes[last()]">
669 <apply-templates select="@*|exsl:node-set($caption)/node()" mode="LesML:finalize-tree"/>
677 <apply-templates select="@*|$content-nodes" mode="LesML:finalize-tree"/>
683 <template match="html:div" mode="LesML:finalize-tree">
684 <if test="not(@class='continuation') or not(preceding-sibling::node()) or preceding-sibling::node()[position()=1 and not(self::html:div or self::html:li)]">
685 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div and @class='continuation')][1]"/>
687 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
688 <for-each select="following-sibling::node()[not($notcontinuation) or following-sibling::node()[generate-id()=generate-id($notcontinuation)]]">
689 <apply-templates select="node()" mode="LesML:finalize-tree"/>
694 <template match="html:li" mode="LesML:finalize-tree">
695 <if test="not(preceding-sibling::node()) or preceding-sibling::node()[not(preceding-sibling::* and self::html:div and @class='continuation')][position()=1 and not(self::html:li)]">
696 <apply-templates select="." mode="LesML:finalize-list"/>
699 <template match="html:li" mode="LesML:finalize-list">
700 <param name="parent-level" select="0"/>
701 <variable name="current-class" select="string(@class)"/>
702 <variable name="current-level" select="number(@data-level)"/>
703 <variable name="wrapper">
705 <when test="@class='ordered'">
713 <variable name="notinlist" select="following-sibling::node()[not(self::html:div and @class='continuation' or self::html:li and (@data-level>$current-level or @data-level=$current-level and @class=$current-class))][1]"/>
714 <element name="html:{$wrapper}" namespace="http://www.w3.org/1999/xhtml">
715 <for-each select=".|following-sibling::html:li[@data-level=$current-level and (not($notinlist) or following-sibling::node()[generate-id()=generate-id($notinlist)])]">
716 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div and @class='continuation')][1]"/>
718 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
719 <for-each select="following-sibling::node()[not($notcontinuation) or following-sibling::node()[generate-id()=generate-id($notcontinuation)]]">
720 <apply-templates select="node()" mode="LesML:finalize-tree"/>
722 <if test="$notcontinuation/self::html:li[@data-level>$current-level]">
723 <apply-templates select="$notcontinuation" mode="LesML:finalize-list">
724 <with-param name="parent-level" select="$current-level"/>
730 <if test="$notinlist/self::html:li[@data-level>$parent-level]">
731 <apply-templates select="$notinlist" mode="LesML:finalize-list">
732 <with-param name="parent-level" select="$parent-level"/>
736 <template match="processing-instruction()[local-name()='LesML-Link-Escape']" mode="LesML:finalize-tree">
739 <template match="text()" mode="LesML:finalize-tree">
740 <call-template name="LesML:break-and-unescape">
741 <with-param name="source" select="string(.)"/>
744 <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
746 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
749 <template match="node()" mode="LesML:inline">
750 <param name="element-name"/>
751 <param name="element-namespace" select="'http://www.w3.org/1999/xhtml'"/>
752 <param name="start-sigil"/>
753 <param name="end-sigil"/>
755 <param name="langtag-supported" select="false()"/>
757 <when test="self::*">
758 <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
759 <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))"/>
761 <when test="$end-node and $has-start-node">
762 <variable name="preceding">
763 <copy-of select="$end-node/preceding-sibling::node()"/>
764 <value-of select="substring-before($end-node, $end-sigil)"/>
766 <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., $start-sigil)][last()]"/>
767 <variable name="restoftext" select="substring-after($end-node, $end-sigil)"/>
768 <variable name="maybe-langtag">
769 <if test="$langtag-supported and starts-with($restoftext, '@') and contains($restoftext, '$')">
770 <value-of select="substring-before(substring-after($restoftext, '@'), '$')"/>
773 <variable name="langtag">
774 <if test="translate($maybe-langtag, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-', '')=''">
775 <value-of select="$maybe-langtag"/>
778 <variable name="start-tokens-fragment">
779 <call-template name="LesML:split">
780 <with-param name="source" select="string($start-node)"/>
781 <with-param name="separator" select="$start-sigil"/>
784 <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
785 <variable name="wrapped">
787 <copy-of select="@*"/>
788 <copy-of select="$start-node/preceding-sibling::node()"/>
789 <for-each select="$start-tokens[position()!=last()]">
790 <value-of select="."/>
791 <if test="position()!=last()">
792 <value-of select="$start-sigil"/>
795 <element name="{$element-name}" namespace="{$element-namespace}">
796 <if test="string($role)!=''">
797 <attribute name="role">
798 <value-of select="$role"/>
801 <if test="string($langtag)!=''">
802 <if test="$element-namespace='http://www.w3.org/1999/xhtml'">
803 <attribute name="lang">
804 <value-of select="$langtag"/>
807 <attribute name="xml:lang">
808 <value-of select="$langtag"/>
811 <value-of select="$start-tokens[last()]"/>
812 <copy-of select="$start-node/following-sibling::node()"/>
815 <when test="string($langtag)!=''">
816 <value-of select="substring-after($restoftext, '$')"/>
819 <value-of select="$restoftext"/>
822 <copy-of select="$end-node/following-sibling::node()"/>
825 <apply-templates select="exsl:node-set($wrapped)/*" mode="LesML:inline">
826 <with-param name="element-name" select="$element-name"/>
827 <with-param name="element-namespace" select="$element-namespace"/>
828 <with-param name="start-sigil" select="$start-sigil"/>
829 <with-param name="end-sigil" select="$end-sigil"/>
830 <with-param name="role" select="$role"/>
831 <with-param name="langtag-supported" select="$langtag-supported"/>
836 <copy-of select="@*"/>
837 <apply-templates select="node()" mode="LesML:inline">
838 <with-param name="element-name" select="$element-name"/>
839 <with-param name="element-namespace" select="$element-namespace"/>
840 <with-param name="start-sigil" select="$start-sigil"/>
841 <with-param name="end-sigil" select="$end-sigil"/>
842 <with-param name="role" select="$role"/>
843 <with-param name="langtag-supported" select="$langtag-supported"/>
850 <copy-of select="."/>
854 <template match="node()" mode="LesML:linkify">
855 <variable name="result">
857 <when test="self::*">
858 <variable name="end-node" select="text()[contains(., '>}')][1]"/>
859 <variable name="has-start-node" select="$end-node/preceding-sibling::text()[contains(., '{🔗') and not(following-sibling::*)] or string-length(substring-after($end-node, '{🔗'))>string-length(substring-after($end-node, '>}'))"/>
861 <when test="$end-node and $has-start-node">
862 <variable name="preceding">
863 <copy-of select="$end-node/preceding-sibling::node()"/>
864 <value-of select="substring-before($end-node, '>}')"/>
866 <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., '{🔗') and not(following-sibling::*)][last()]"/>
867 <variable name="start-tokens-fragment">
868 <call-template name="LesML:split">
869 <with-param name="source" select="string($start-node)"/>
870 <with-param name="separator" select="'{🔗'"/>
873 <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
874 <variable name="hyperlink">
875 <value-of select="$start-tokens[last()]"/>
876 <for-each select="$start-node/following-sibling::node()">
878 <when test="self::text()">
879 <value-of select="."/>
881 <when test="self::processing-instruction()[local-name()='LesML-Link-Escape']">
888 <when test="contains($hyperlink, '<')">
889 <variable name="ltcomponents-fragment">
890 <call-template name="LesML:split">
891 <with-param name="source" select="$hyperlink"/>
892 <with-param name="separator" select="'<'"/>
895 <variable name="ltcomponents" select="exsl:node-set($ltcomponents-fragment)/*"/>
896 <variable name="wrapped">
898 <copy-of select="@*"/>
899 <copy-of select="$start-node/preceding-sibling::node()"/>
900 <for-each select="$start-tokens[position()!=last()]">
901 <value-of select="."/>
902 <if test="position()!=last()">
906 <element name="html:a">
907 <attribute name="href">
908 <value-of select="$ltcomponents[last()]"/>
911 <when test="count($ltcomponents)>2 or normalize-space($ltcomponents[1])!=''">
912 <for-each select="$ltcomponents[position()!=last()]">
913 <value-of select="."/>
914 <if test="position()!=last()">
920 <value-of select="$ltcomponents[last()]"/>
924 <value-of select="substring-after($end-node, '>}')"/>
925 <copy-of select="$end-node/following-sibling::node()"/>
928 <apply-templates select="exsl:node-set($wrapped)/*" mode="LesML:linkify"/>
931 <variable name="escaped">
933 <copy-of select="@*"/>
934 <copy-of select="$start-node/preceding-sibling::node()"/>
935 <for-each select="$start-tokens[position()!=last()]">
936 <value-of select="."/>
937 <if test="position()!=last()">
942 <processing-instruction name="LesML-Link-Escape"/>
943 <copy-of select="$hyperlink"/>
945 <value-of select="substring-after($end-node, '>}')"/>
946 <copy-of select="$end-node/following-sibling::node()"/>
949 <apply-templates select="exsl:node-set($escaped)/*" mode="LesML:linkify"/>
955 <copy-of select="@*"/>
956 <apply-templates select="node()" mode="LesML:linkify"/>
962 <copy-of select="."/>
966 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:strikethrough"/>
968 <template match="node()" mode="LesML:strikethrough">
969 <variable name="result">
970 <apply-templates select="." mode="LesML:inline">
971 <with-param name="element-name" select="'html:s'"/>
972 <with-param name="start-sigil" select="'⸠'"/>
973 <with-param name="end-sigil" select="'⸡'"/>
976 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:underline"/>
978 <template match="node()" mode="LesML:underline">
979 <variable name="result">
980 <apply-templates select="." mode="LesML:inline">
981 <with-param name="element-name" select="'html:u'"/>
982 <with-param name="start-sigil" select="'⸤'"/>
983 <with-param name="end-sigil" select="'⸥'"/>
986 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:noted"/>
988 <template match="node()" mode="LesML:noted">
989 <variable name="result">
990 <apply-templates select="." mode="LesML:inline">
991 <with-param name="element-name" select="'html:small'"/>
992 <with-param name="start-sigil" select="'⟦'"/>
993 <with-param name="end-sigil" select="'⟧'"/>
994 <with-param name="role" select="'note'"/>
997 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:parenthetical"/>
999 <template match="node()" mode="LesML:parenthetical">
1000 <variable name="result">
1001 <apply-templates select="." mode="LesML:inline">
1002 <with-param name="element-name" select="'html:small'"/>
1003 <with-param name="start-sigil" select="'⸨'"/>
1004 <with-param name="end-sigil" select="'⸩'"/>
1007 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:important"/>
1009 <template match="node()" mode="LesML:important">
1010 <variable name="result">
1011 <apply-templates select="." mode="LesML:inline">
1012 <with-param name="element-name" select="'html:strong'"/>
1013 <with-param name="start-sigil" select="'☞'"/>
1014 <with-param name="end-sigil" select="'☜'"/>
1017 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:emphasized"/>
1019 <template match="node()" mode="LesML:emphasized">
1020 <variable name="result">
1021 <apply-templates select="." mode="LesML:inline">
1022 <with-param name="element-name" select="'html:em'"/>
1023 <with-param name="start-sigil" select="'⹐'"/>
1024 <with-param name="end-sigil" select="'⹑'"/>
1027 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:titled"/>
1029 <template match="node()" mode="LesML:titled">
1030 <variable name="result">
1031 <apply-templates select="." mode="LesML:inline">
1032 <with-param name="element-name" select="'html:cite'"/>
1033 <with-param name="start-sigil" select="'⟪'"/>
1034 <with-param name="end-sigil" select="'⟫'"/>
1037 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:offset"/>
1039 <template match="node()" mode="LesML:offset">
1040 <variable name="result">
1041 <apply-templates select="." mode="LesML:inline">
1042 <with-param name="element-name" select="'html:i'"/>
1043 <with-param name="start-sigil" select="'⟨'"/>
1044 <with-param name="end-sigil" select="'⟩'"/>
1045 <with-param name="langtag-supported" select="true()"/>
1048 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:bolded"/>
1050 <template match="node()" mode="LesML:bolded">
1051 <variable name="result">
1052 <apply-templates select="." mode="LesML:inline">
1053 <with-param name="element-name" select="'html:b'"/>
1054 <with-param name="start-sigil" select="'⦃'"/>
1055 <with-param name="end-sigil" select="'⦄'"/>
1058 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:code"/>
1060 <template match="node()" mode="LesML:code">
1061 <apply-templates select="." mode="LesML:inline">
1062 <with-param name="element-name" select="'html:code'"/>
1063 <with-param name="start-sigil" select="'`'"/>
1064 <with-param name="end-sigil" select="'´'"/>