]> Lady’s Gitweb - LesML/blob - parser.xslt
a304a462926119f82ce8053d5a5f895a7628bcc9
[LesML] / parser.xslt
1 <?xml version="1.0"?>
2 <!--
3 SPDX-FileCopyrightText: 2024, 2025 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
5 -->
6 <!--
7 ⁌ 💄📝 Les·M·L ∷ parser.xslt
8
9 © 2024–2025 Lady [@ Ladys Computer]
10
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/>.
13 -->
14 <!DOCTYPE transform [
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">
20 ]>
21 <transform
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"
32 version="1.0"
33 >
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="'&#xA;'"/>
39 <choose>
40 <when test="contains($source, $separator)">
41 <html:span>
42 <value-of select="substring-before($source, $separator)"/>
43 </html:span>
44 <call-template name="LesML:split">
45 <with-param name="source" select="substring-after($source, $separator)"/>
46 <with-param name="separator" select="$separator"/>
47 </call-template>
48 </when>
49 <otherwise>
50 <html:span>
51 <value-of select="$source"/>
52 </html:span>
53 </otherwise>
54 </choose>
55 </template>
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="'&#xA;'"/>
62 </call-template>
63 </variable>
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()"/>
68 </call-template>
69 <if test="position()!=count($broken)">
70 <element name="br" namespace="&xhtml;"/>
71 </if>
72 </for-each>
73 </template>
74 <template name="LesML:unescape">
75 <param name="source"/>
76 <choose>
77 <when test="contains($source, '{U+')">
78 <variable name="after" select="substring-after($source, '{U+')"/>
79 <choose>
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="'.'"/>
86 </call-template>
87 </variable>
88 <variable name="component-nodes" select="exsl:node-set($components)/node()"/>
89 <value-of select="substring-before($source, '{U+')"/>
90 <choose>
91 <when test="$component-nodes[string(.)='' or translate(., '0123456789ABCDEF', '')!='']">
92 <text>{U+</text>
93 <value-of select="$inner"/>
94 <text>}</text>
95 <call-template name="LesML:unescape">
96 <with-param name="source" select="substring-after($after, '}')"/>
97 </call-template>
98 </when>
99 <otherwise>
100 <for-each select="$component-nodes">
101 <text disable-output-escaping="yes">&amp;#x</text>
102 <value-of select="."/>
103 <text>;</text>
104 </for-each>
105 <call-template name="LesML:unescape">
106 <with-param name="source" select="substring-after($after, '}')"/>
107 </call-template>
108 </otherwise>
109 </choose>
110 </when>
111 <otherwise>
112 <value-of select="substring-before($source, '{U+')"/>
113 <text>{U+</text>
114 <call-template name="LesML:unescape">
115 <with-param name="source" select="$after"/>
116 </call-template>
117 </otherwise>
118 </choose>
119 </when>
120 <otherwise>
121 <value-of select="$source"/>
122 </otherwise>
123 </choose>
124 </template>
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="'--'"/>
131 </call-template>
132 </variable>
133 <comment>
134 <for-each select="exsl:node-set($comment-split-fragment)/*">
135 <if test="string()='' or starts-with(., '‐')">
136 <text>&#x034F;</text>
137 </if>
138 <value-of select="."/>
139 <if test="substring(., string-length(.), 1)='‐'">
140 <text>&#x034F;</text>
141 </if>
142 <choose>
143 <when test="position()!=last()">
144 <text>-&#x034F;-</text>
145 </when>
146 </choose>
147 </for-each>
148 </comment>
149 </template>
150 <template name="LesML:id-and-contents">
151 <param name="source"/>
152 <variable name="id-and-lang">
153 <if test="starts-with($source, '¶')">
154 <choose>
155 <when test="contains($source, ' ')">
156 <value-of select="substring-before(substring-after($source, '¶'), ' ')"/>
157 </when>
158 <otherwise>
159 <value-of select="substring-after($source, '¶')"/>
160 </otherwise>
161 </choose>
162 </if>
163 </variable>
164 <variable name="restoftext">
165 <choose>
166 <when test="starts-with($source, '¶') and contains($source, ' ')">
167 <value-of select="substring-after($source, ' ')"/>
168 </when>
169 <when test="starts-with($source, '¶')"/>
170 <otherwise>
171 <value-of select="$source"/>
172 </otherwise>
173 </choose>
174 </variable>
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="'@'"/>
181 </call-template>
182 </variable>
183 <value-of select="exsl:node-set($split-tag-fragment)/*[last()]"/>
184 </if>
185 </variable>
186 <variable name="langtag">
187 <if test="translate($maybe-langtag, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-', '')=''">
188 <value-of select="$maybe-langtag"/>
189 </if>
190 </variable>
191 <variable name="id">
192 <choose>
193 <when test="string($langtag)!=''">
194 <value-of select="substring($id-and-lang, 1, string-length($id-and-lang)-(string-length($langtag)+2))"/>
195 </when>
196 <otherwise>
197 <value-of select="$id-and-lang"/>
198 </otherwise>
199 </choose>
200 </variable>
201 <if test="string($id)!=''">
202 <attribute name="id">
203 <value-of select="$id"/>
204 </attribute>
205 </if>
206 <if test="string($langtag)!=''">
207 <attribute name="lang">
208 <value-of select="$langtag"/>
209 </attribute>
210 <attribute name="xml:lang">
211 <value-of select="$langtag"/>
212 </attribute>
213 </if>
214 <value-of select="$restoftext"/>
215 </template>
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"/>
223 </if>
224 </variable>
225 <variable name="params-string">
226 <choose>
227 <when test="starts-with($shebang, '#!lesml@')">
228 <value-of select="substring-after($shebang, '$')"/>
229 </when>
230 <otherwise>
231 <value-of select="substring-after($shebang, '#!lesml')"/>
232 </otherwise>
233 </choose>
234 </variable>
235 <variable name="params-fragment">
236 <choose>
237 <when test="$shebang!=''">
238 <html:dl>
239 <if test="starts-with($shebang, '#!lesml@') and contains($shebang, '$')">
240 <html:div>
241 <html:dt>
242 <text> LANG </text>
243 </html:dt>
244 <html:dd>
245 <value-of select="substring-before(substring-after($shebang, '#!lesml@'), '$')"/>
246 </html:dd>
247 </html:div>
248 </if>
249 <for-each select="exslstr:tokenize($params-string)">
250 <choose>
251 <when test="contains(., '=')">
252 <html:div>
253 <html:dt>
254 <value-of select="substring-before(., '=')"/>
255 </html:dt>
256 <html:dd>
257 <value-of select="substring-after(., '=')"/>
258 </html:dd>
259 </html:div>
260 </when>
261 <otherwise>
262 <html:div>
263 <html:dt>
264 <value-of select="."/>
265 </html:dt>
266 <html:dd/>
267 </html:div>
268 </otherwise>
269 </choose>
270 </for-each>
271 </html:dl>
272 </when>
273 <when test="$parent-params">
274 <copy-of select="$parent-params"/>
275 </when>
276 <otherwise>
277 <html:dl/>
278 </otherwise>
279 </choose>
280 </variable>
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, '##')"/>
288 </call-template>
289 </if>
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()])"/>
295 </call-template>
296 </variable>
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="."/>
303 </if>
304 </for-each>
305 </variable>
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"/>
313 </attribute>
314 <attribute name="value">
315 <value-of select="$numero"/>
316 </attribute>
317 <copy-of select="@*|node()"/>
318 <element name="footer" namespace="&xhtml;">
319 <attribute name="class">
320 <text>backlinks</text>
321 </attribute>
322 <for-each select="$links[@id]">
323 <if test="position()>1">
324 <text> </text>
325 </if>
326 <element name="a" namespace="&xhtml;">
327 <attribute name="role">
328 <text>doc-backlink</text>
329 </attribute>
330 <attribute name="href">
331 <text>#</text>
332 <value-of select="@id"/>
333 </attribute>
334 <value-of select="position()"/>
335 </element>
336 </for-each>
337 </element>
338 </element>
339 </for-each>
340 </variable>
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"/>
346 </attribute>
347 <attribute name="xml:lang">
348 <value-of select="following-sibling::html:dd"/>
349 </attribute>
350 </for-each>
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"/>
354 </attribute>
355 </for-each>
356 <if test="$record-separators[preceding-sibling::*[normalize-space()!='']]">
357 <element name="footer" namespace="&xhtml;">
358 <attribute name="class">
359 <text>head</text>
360 </attribute>
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), .)"/>
365 <if test="$fields">
366 <element name="dl" namespace="&xhtml;">
367 <for-each select="$fields">
368 <choose>
369 <when test="starts-with(., ' ') and exslset:leading($fields, .)"/>
370 <otherwise>
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(., ':'))"/>
375 </element>
376 <element name="dd" namespace="&xhtml;">
377 <variable name="firstline">
378 <choose>
379 <when test="contains(., ':')">
380 <value-of select="normalize-space(substring-after(., ':'))"/>
381 </when>
382 <otherwise>
383 <value-of select="normalize-space(.)"/>
384 </otherwise>
385 </choose>
386 </variable>
387 <choose>
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)"/>
390 </when>
391 <otherwise>
392 <value-of select="$firstline"/>
393 </otherwise>
394 </choose>
395 <for-each select="exslset:intersection(following-sibling::*[starts-with(., ' ')], exslset:leading($fields, $next))">
396 <variable name="nextline" select="normalize-space(.)"/>
397 <choose>
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)"/>
400 </when>
401 <otherwise>
402 <value-of select="$nextline"/>
403 </otherwise>
404 </choose>
405 </for-each>
406 </element>
407 </element>
408 </otherwise>
409 </choose>
410 </for-each>
411 </element>
412 </if>
413 <if test=".!='%%'">
414 <call-template name="LesML:comment-out">
415 <with-param name="source" select="substring-after(., '%%')"/>
416 </call-template>
417 </if>
418 </for-each>
419 </element>
420 </if>
421 <element name="div" namespace="&xhtml;">
422 <attribute name="class">
423 <text>body</text>
424 </attribute>
425 <apply-templates select="$paragraphized/node()" mode="LesML:finalize">
426 <with-param name="used-footnotes" select="$used-footnote-nodes"/>
427 </apply-templates>
428 </element>
429 <if test="$used-footnote-nodes">
430 <element name="section" namespace="&xhtml;">
431 <attribute name="role">
432 <text>doc-endnotes</text>
433 </attribute>
434 <element name="ol" namespace="&xhtml;">
435 <apply-templates select="$used-footnote-nodes" mode="LesML:finalize">
436 <with-param name="used-footnotes" select="$used-footnote-nodes"/>
437 </apply-templates>
438 </element>
439 </element>
440 </if>
441 </element>
442 </if>
443 <if test="$docsep">
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"/>
447 </call-template>
448 </if>
449 </template>
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(., ' &#x9;', ''), 1, 1)"/>
458 <variable name="all-prefixed" select="not($linespans[not(starts-with(translate(., ' &#x9;', ''), $prefix))])"/>
459 <variable name="quoted" select="$all-prefixed and $prefix='»'"/>
460 <variable name="bracketed" select="$all-prefixed and $prefix=']'"/>
461 <choose>
462 <when test="count($linespans)=1 and translate(., concat($LESML_SECTION_BREAK_CHARS, ' &#x9;'), '')=''">
463 <element name="hr" namespace="&xhtml;"/>
464 </when>
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)"/>
470 </variable>
471 <copy>
472 <choose>
473 <when test="starts-with($inner, ' ') or starts-with($inner, '&#x9;')">
474 <value-of select="substring($inner, 1+count(exslstr:tokenize($inner, '')[normalize-space()='' and not(preceding-sibling::*[normalize-space()!=''])]))"/>
475 </when>
476 <otherwise>
477 <value-of select="$inner"/>
478 </otherwise>
479 </choose>
480 </copy>
481 </for-each>
482 </variable>
483 <variable name="blocked-fragment">
484 <call-template name="LesML:block">
485 <with-param name="lines" select="exsl:node-set($innerlines-fragment)/*"/>
486 </call-template>
487 </variable>
488 <variable name="innerpars" select="exsl:node-set($blocked-fragment)/node()"/>
489 <choose>
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()]"/>
494 </element>
495 <element name="figcaption" namespace="&xhtml;">
496 <copy-of select="$innerpars[last()]/node()"/>
497 </element>
498 </element>
499 </when>
500 <when test="$quoted">
501 <element name="blockquote" namespace="&xhtml;">
502 <copy-of select="$innerpars"/>
503 </element>
504 </when>
505 <when test="$bracketed">
506 <element name="footer" namespace="&xhtml;">
507 <copy-of select="$innerpars"/>
508 </element>
509 </when>
510 </choose>
511 </when>
512 <otherwise>
513 <variable name="preformatted" select="$all-prefixed and $prefix='|'"/>
514 <variable name="text">
515 <for-each select="$linespans">
516 <choose>
517 <when test="$preformatted">
518 <value-of select="substring-after(., '|')"/>
519 </when>
520 <otherwise>
521 <value-of select="normalize-space()"/>
522 </otherwise>
523 </choose>
524 <if test="position()!=count($linespans)">
525 <choose>
526 <when test="$preformatted">
527 <text>&#xA;</text>
528 </when>
529 <otherwise>
530 <text> </text>
531 </otherwise>
532 </choose>
533 </if>
534 </for-each>
535 </variable>
536 <choose>
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"/>
541 </call-template>
542 </element>
543 </when>
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;"/>
549 </call-template>
550 </element>
551 </when>
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;"/>
556 </call-template>
557 </element>
558 </when>
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;"/>
563 </call-template>
564 </element>
565 </when>
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;"/>
570 </call-template>
571 </element>
572 </when>
573 <when test="starts-with($text, '•') and &sigiled-text;">
574 <element name="li" namespace="&xhtml;">
575 <attribute name="class">
576 <text>unordered</text>
577 </attribute>
578 <attribute name="aria-level">
579 <text>1</text>
580 </attribute>
581 <element name="p" namespace="&xhtml;">
582 <call-template name="LesML:id-and-contents">
583 <with-param name="source" select="&unsigiled-text;"/>
584 </call-template>
585 </element>
586 </element>
587 </when>
588 <when test="starts-with($text, '🔢') and &sigiled-text;">
589 <element name="li" namespace="&xhtml;">
590 <attribute name="class">
591 <text>ordered</text>
592 </attribute>
593 <attribute name="aria-level">
594 <text>1</text>
595 </attribute>
596 <element name="p" namespace="&xhtml;">
597 <call-template name="LesML:id-and-contents">
598 <with-param name="source" select="&unsigiled-text;"/>
599 </call-template>
600 </element>
601 </element>
602 </when>
603 <when test="starts-with($text, '◦') and &sigiled-text;">
604 <element name="li" namespace="&xhtml;">
605 <attribute name="class">
606 <text>unordered</text>
607 </attribute>
608 <attribute name="aria-level">
609 <text>2</text>
610 </attribute>
611 <element name="p" namespace="&xhtml;">
612 <call-template name="LesML:id-and-contents">
613 <with-param name="source" select="&unsigiled-text;"/>
614 </call-template>
615 </element>
616 </element>
617 </when>
618 <when test="starts-with($text, '🔠') and &sigiled-text;">
619 <element name="li" namespace="&xhtml;">
620 <attribute name="class">
621 <text>ordered</text>
622 </attribute>
623 <attribute name="aria-level">
624 <text>2</text>
625 </attribute>
626 <element name="p" namespace="&xhtml;">
627 <call-template name="LesML:id-and-contents">
628 <with-param name="source" select="&unsigiled-text;"/>
629 </call-template>
630 </element>
631 </element>
632 </when>
633 <when test="starts-with($text, '▪') and &sigiled-text;">
634 <element name="li" namespace="&xhtml;">
635 <attribute name="class">
636 <text>unordered</text>
637 </attribute>
638 <attribute name="aria-level">
639 <text>3</text>
640 </attribute>
641 <element name="p" namespace="&xhtml;">
642 <call-template name="LesML:id-and-contents">
643 <with-param name="source" select="&unsigiled-text;"/>
644 </call-template>
645 </element>
646 </element>
647 </when>
648 <when test="starts-with($text, '🔡') and &sigiled-text;">
649 <element name="li" namespace="&xhtml;">
650 <attribute name="class">
651 <text>ordered</text>
652 </attribute>
653 <attribute name="aria-level">
654 <text>3</text>
655 </attribute>
656 <element name="p" namespace="&xhtml;">
657 <call-template name="LesML:id-and-contents">
658 <with-param name="source" select="&unsigiled-text;"/>
659 </call-template>
660 </element>
661 </element>
662 </when>
663 <when test="starts-with($text, '⁃') and &sigiled-text;">
664 <element name="li" namespace="&xhtml;">
665 <attribute name="class">
666 <text>unordered</text>
667 </attribute>
668 <attribute name="aria-level">
669 <text>4</text>
670 </attribute>
671 <element name="p" namespace="&xhtml;">
672 <call-template name="LesML:id-and-contents">
673 <with-param name="source" select="&unsigiled-text;"/>
674 </call-template>
675 </element>
676 </element>
677 </when>
678 <when test="starts-with($text, '🔣') and &sigiled-text;">
679 <element name="li" namespace="&xhtml;">
680 <attribute name="class">
681 <text>ordered</text>
682 </attribute>
683 <attribute name="aria-level">
684 <text>4</text>
685 </attribute>
686 <element name="p" namespace="&xhtml;">
687 <call-template name="LesML:id-and-contents">
688 <with-param name="source" select="&unsigiled-text;"/>
689 </call-template>
690 </element>
691 </element>
692 </when>
693 <when test="starts-with($text, '※') and &sigiled-text;">
694 <element name="section" namespace="&xhtml;">
695 <attribute name="role">
696 <text>note</text>
697 </attribute>
698 <attribute name="class">
699 <text>note</text>
700 </attribute>
701 <element name="p" namespace="&xhtml;">
702 <call-template name="LesML:id-and-contents">
703 <with-param name="source" select="&unsigiled-text;"/>
704 </call-template>
705 </element>
706 </element>
707 </when>
708 <when test="starts-with($text, '☡') and &sigiled-text;">
709 <element name="section" namespace="&xhtml;">
710 <attribute name="role">
711 <text>note</text>
712 </attribute>
713 <attribute name="class">
714 <text>caution</text>
715 </attribute>
716 <element name="p" namespace="&xhtml;">
717 <call-template name="LesML:id-and-contents">
718 <with-param name="source" select="&unsigiled-text;"/>
719 </call-template>
720 </element>
721 </element>
722 </when>
723 <when test="starts-with($text, '⯑') and &sigiled-text;">
724 <element name="section" namespace="&xhtml;">
725 <attribute name="role">
726 <text>note</text>
727 </attribute>
728 <attribute name="class">
729 <text>query</text>
730 </attribute>
731 <element name="p" namespace="&xhtml;">
732 <call-template name="LesML:id-and-contents">
733 <with-param name="source" select="&unsigiled-text;"/>
734 </call-template>
735 </element>
736 </element>
737 </when>
738 <when test="starts-with($text, '@') and &sigiled-text;">
739 <element name="section" namespace="&xhtml;">
740 <attribute name="role">
741 <text>doc-abstract</text>
742 </attribute>
743 <element name="p" namespace="&xhtml;">
744 <call-template name="LesML:id-and-contents">
745 <with-param name="source" select="&unsigiled-text;"/>
746 </call-template>
747 </element>
748 </element>
749 </when>
750 <when test="starts-with($text, '🛈') and &sigiled-text;">
751 <element name="section" namespace="&xhtml;">
752 <attribute name="role">
753 <text>doc-tip</text>
754 </attribute>
755 <element name="p" namespace="&xhtml;">
756 <call-template name="LesML:id-and-contents">
757 <with-param name="source" select="&unsigiled-text;"/>
758 </call-template>
759 </element>
760 </element>
761 </when>
762 <when test="starts-with($text, '⚠') and &sigiled-text;">
763 <element name="section" namespace="&xhtml;">
764 <attribute name="role">
765 <text>doc-notice</text>
766 </attribute>
767 <element name="p" namespace="&xhtml;">
768 <call-template name="LesML:id-and-contents">
769 <with-param name="source" select="&unsigiled-text;"/>
770 </call-template>
771 </element>
772 </element>
773 </when>
774 <when test="starts-with($text, '⋯') and &sigiled-text;">
775 <element name="div" namespace="&xhtml;">
776 <processing-instruction name="LesML-Continuation"/>
777 <element name="p" namespace="&xhtml;">
778 <call-template name="LesML:id-and-contents">
779 <with-param name="source" select="&unsigiled-text;"/>
780 </call-template>
781 </element>
782 </element>
783 </when>
784 <when test="starts-with($text, '^') and &sigiled-text;">
785 <element name="li" namespace="&xhtml;">
786 <attribute name="class">
787 <text>ordered footnote</text>
788 </attribute>
789 <attribute name="aria-level">
790 <text>1</text>
791 </attribute>
792 <processing-instruction name="LesML-Footnote"/>
793 <element name="p" namespace="&xhtml;">
794 <call-template name="LesML:id-and-contents">
795 <with-param name="source" select="&unsigiled-text;"/>
796 </call-template>
797 </element>
798 </element>
799 </when>
800 <when test="starts-with($text, '#') and &sigiled-text;">
801 <call-template name="LesML:comment-out">
802 <with-param name="source" select="&unsigiled-text;"/>
803 </call-template>
804 </when>
805 <otherwise>
806 <element name="p" namespace="&xhtml;">
807 <call-template name="LesML:id-and-contents">
808 <with-param name="source" select="$text"/>
809 </call-template>
810 </element>
811 </otherwise>
812 </choose>
813 </otherwise>
814 </choose>
815 </for-each>
816 </template>
817 <template name="LesML:paragraphize">
818 <param name="lines" select="/.."/>
819 <variable name="blocked-fragment">
820 <call-template name="LesML:block">
821 <with-param name="lines" select="$lines"/>
822 </call-template>
823 </variable>
824 <variable name="blocked" select="exsl:node-set($blocked-fragment)"/>
825 <variable name="footnote-ids" select="$blocked//html:li[processing-instruction()[local-name()='LesML-Footnote']]/html:p[1]/@id"/>
826 <variable name="inlined-fragment">
827 <apply-templates select="$blocked/node()" mode="LesML:comment">
828 <with-param name="footnote-ids" select="$footnote-ids"/>
829 </apply-templates>
830 </variable>
831 <apply-templates select="exsl:node-set($inlined-fragment)/node()" mode="LesML:finalize-tree"/>
832 </template>
833 <template match="html:script[@type='text/lesml']">
834 <variable name="lines-fragment">
835 <call-template name="LesML:split">
836 <with-param name="source">
837 <for-each select=".//text()">
838 <value-of select="."/>
839 </for-each>
840 </with-param>
841 </call-template>
842 </variable>
843 <element name="div" namespace="&xhtml;">
844 <call-template name="LesML:parse">
845 <with-param name="lines" select="exsl:node-set($lines-fragment)/*"/>
846 </call-template>
847 </element>
848 </template>
849 <template match="html:ol[processing-instruction()[local-name()='LesML-Footnote']]|processing-instruction()[local-name()='LesML-Footnote']" mode="LesML:finalize" priority="1"/>
850 <template match="html:a[@role='doc-noteref']" mode="LesML:finalize">
851 <param name="used-footnotes" select="/.."/>
852 <variable name="matching-note" select="$used-footnotes[concat('#', @id)=current()/@href]"/>
853 <copy>
854 <apply-templates select="@*" mode="LesML:finalize">
855 <with-param name="used-footnotes" select="$used-footnotes"/>
856 </apply-templates>
857 <choose>
858 <when test="$matching-note">
859 <value-of select="$matching-note/@value"/>
860 </when>
861 <otherwise>
862 <apply-templates select="node()" mode="LesML:finalize">
863 <with-param name="used-footnotes" select="$used-footnotes"/>
864 </apply-templates>
865 </otherwise>
866 </choose>
867 </copy>
868 </template>
869 <template match="html:p[position()=1 and ancestor::*]" mode="LesML:finalize">
870 <param name="used-footnotes" select="/.."/>
871 <variable name="content" select="@*[not(&pilcrow-atts;)]|node()"/>
872 <if test="$content">
873 <copy>
874 <apply-templates select="$content" mode="LesML:finalize">
875 <with-param name="used-footnotes" select="$used-footnotes"/>
876 </apply-templates>
877 </copy>
878 </if>
879 </template>
880 <template match="html:section" mode="LesML:finalize">
881 <param name="used-footnotes" select="/.."/>
882 <variable name="notinsection" select="following-sibling::node()[not(html:li/@aria-level>1)][1]"/>
883 <copy>
884 <apply-templates select="@*|html:p[1]/@*[&pilcrow-atts;]" mode="LesML:finalize"/>
885 <apply-templates select="node()" mode="LesML:finalize"/>
886 <for-each select="exslset:leading(following-sibling::node(), $notinsection)">
887 <copy>
888 <apply-templates select="@*|node()" mode="LesML:finalize">
889 <with-param name="used-footnotes" select="$used-footnotes"/>
890 </apply-templates>
891 </copy>
892 </for-each>
893 </copy>
894 </template>
895 <template match="html:*[html:li/@aria-level>1]" mode="LesML:finalize">
896 <param name="used-footnotes" select="/.."/>
897 <if test="not(preceding-sibling::node()[not(html:li/@aria-level>1)][1]/self::html:section)">
898 <copy>
899 <apply-templates select="@*|node()" mode="LesML:finalize">
900 <with-param name="used-footnotes" select="$used-footnotes"/>
901 </apply-templates>
902 </copy>
903 </if>
904 </template>
905 <template match="text()" mode="LesML:finalize">
906 <call-template name="LesML:break-and-unescape">
907 <with-param name="source" select="string()"/>
908 </call-template>
909 </template>
910 <template match="@*|node()" mode="LesML:finalize" priority="-1">
911 <param name="used-footnotes" select="/.."/>
912 <copy>
913 <apply-templates select="@*|html:p[1]/@*[&pilcrow-atts;]" mode="LesML:finalize"/>
914 <apply-templates select="node()" mode="LesML:finalize">
915 <with-param name="used-footnotes" select="$used-footnotes"/>
916 </apply-templates>
917 </copy>
918 </template>
919 <template match="node()" mode="LesML:finalize-attributes">
920 <variable name="notattr" select="following-sibling::node()[not(self::text() and translate(., ' &#x9;', '')='' or self::LesML:attribute)]"/>
921 <for-each select="(.|exslset:leading(following-sibling::node(), $notattr)[self::LesML:attribute])/@*">
922 <copy-of select="."/>
923 <if test="local-name()='lang' and namespace-uri()=''">
924 <attribute name="xml:lang">
925 <value-of select="."/>
926 </attribute>
927 </if>
928 </for-each>
929 </template>
930 <template match="html:li" mode="LesML:finalize-list">
931 <param name="parent-level" select="0"/>
932 <variable name="current-class" select="string(@class)"/>
933 <variable name="current-level" select="number(@aria-level)"/>
934 <variable name="wrapper">
935 <choose>
936 <when test="contains(concat(' ', @class, ' '), ' ordered ')">
937 <text>ol</text>
938 </when>
939 <otherwise>
940 <text>ul</text>
941 </otherwise>
942 </choose>
943 </variable>
944 <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]"/>
945 <element name="{$wrapper}" namespace="&xhtml;">
946 <if test="contains(concat(' ', @class, ' '), ' footnote ')">
947 <processing-instruction name="LesML-Footnote"/>
948 </if>
949 <for-each select=".|exslset:leading(following-sibling::node(), $notinlist)[self::html:li and @aria-level=$current-level]">
950 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
951 <copy>
952 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
953 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
954 <apply-templates select="node()" mode="LesML:finalize-tree"/>
955 </for-each>
956 <if test="$notcontinuation/self::html:li[@aria-level>$current-level]">
957 <apply-templates select="$notcontinuation" mode="LesML:finalize-list">
958 <with-param name="parent-level" select="$current-level"/>
959 </apply-templates>
960 </if>
961 </copy>
962 </for-each>
963 </element>
964 <if test="$notinlist/self::html:li[@aria-level>$parent-level]">
965 <apply-templates select="$notinlist" mode="LesML:finalize-list">
966 <with-param name="parent-level" select="$parent-level"/>
967 </apply-templates>
968 </if>
969 </template>
970 <template match="LesML:attribute[preceding-sibling::node()[position()=1 and (self::text() or self::*)]]|text()[preceding-sibling::node()[position()=1 and self::*] and following-sibling::node()[position()=1 and self::LesML:attribute] and translate(., ' &#x9;', '')='']" mode="LesML:finalize-tree" priority="2"/>
971 <template match="LesML:attribute|text()[following-sibling::node()[position()=1 and self::LesML:attribute]]" mode="LesML:finalize-tree" priority="1">
972 <element name="span" namespace="&xhtml;">
973 <apply-templates select="." mode="LesML:finalize-attributes"/>
974 <if test="self::text()">
975 <copy/>
976 </if>
977 </element>
978 </template>
979 <template match="html:div" mode="LesML:finalize-tree">
980 <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())])">
981 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
982 <choose>
983 <when test="processing-instruction()[local-name()='LesML-Continuation'] and $notcontinuation[self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
984 <variable name="notcontinuation2" select="$notcontinuation/following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
985 <element name="hgroup" namespace="&xhtml;">
986 <apply-templates select="node()" mode="LesML:finalize-tree"/>
987 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation2)">
988 <choose>
989 <when test="self::html:div">
990 <apply-templates select="node()" mode="LesML:finalize-tree"/>
991 </when>
992 <otherwise>
993 <copy>
994 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
995 </copy>
996 </otherwise>
997 </choose>
998 </for-each>
999 </element>
1000 </when>
1001 <when test="not(processing-instruction()[local-name()='LesML-Continuation'])">
1002 <copy>
1003 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
1004 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
1005 <apply-templates select="node()" mode="LesML:finalize-tree"/>
1006 </for-each>
1007 </copy>
1008 </when>
1009 <otherwise>
1010 <apply-templates select="node()" mode="LesML:finalize-tree"/>
1011 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
1012 <apply-templates select="node()" mode="LesML:finalize-tree"/>
1013 </for-each>
1014 </otherwise>
1015 </choose>
1016 </if>
1017 </template>
1018 <template match="html:h1|html:h2|html:h3|html:h4|html:h5|html:h6" mode="LesML:finalize-tree">
1019 <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())]">
1020 <choose>
1021 <when test="following-sibling::node()[position()=1 and self::html:div]/processing-instruction()[local-name()='LesML-Continuation']">
1022 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
1023 <element name="hgroup" namespace="&xhtml;">
1024 <copy>
1025 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
1026 </copy>
1027 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
1028 <apply-templates select="node()" mode="LesML:finalize-tree"/>
1029 </for-each>
1030 </element>
1031 </when>
1032 <otherwise>
1033 <copy>
1034 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
1035 </copy>
1036 </otherwise>
1037 </choose>
1038 </if>
1039 </template>
1040 <template match="html:li" mode="LesML:finalize-tree">
1041 <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)]">
1042 <apply-templates select="." mode="LesML:finalize-list"/>
1043 </if>
1044 </template>
1045 <template match="html:section" mode="LesML:finalize-tree">
1046 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
1047 <copy>
1048 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
1049 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
1050 <apply-templates select="node()" mode="LesML:finalize-tree"/>
1051 </for-each>
1052 </copy>
1053 </template>
1054 <template match="processing-instruction()[local-name()='LesML-Continuation']" mode="LesML:finalize-tree"/>
1055 <template match="processing-instruction()[local-name()='LesML-Token-Escape']" mode="LesML:finalize-tree">
1056 <value-of select="."/>
1057 </template>
1058 <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
1059 <copy>
1060 <apply-templates select="." mode="LesML:finalize-attributes"/>
1061 <apply-templates select="node()" mode="LesML:finalize-tree"/>
1062 </copy>
1063 </template>
1064 <template match="node()" mode="LesML:inline">
1065 <param name="element-name"/>
1066 <param name="element-namespace" select="'http://www.w3.org/1999/xhtml'"/>
1067 <param name="start-sigil"/>
1068 <param name="end-sigil"/>
1069 <param name="class"/>
1070 <param name="role"/>
1071 <choose>
1072 <when test="self::*">
1073 <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
1074 <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))"/>
1075 <choose>
1076 <when test="$end-node and $has-start-node">
1077 <variable name="preceding">
1078 <copy-of select="$end-node/preceding-sibling::node()"/>
1079 <value-of select="substring-before($end-node, $end-sigil)"/>
1080 </variable>
1081 <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., $start-sigil)][last()]"/>
1082 <variable name="start-tokens-fragment">
1083 <call-template name="LesML:split">
1084 <with-param name="source" select="string($start-node)"/>
1085 <with-param name="separator" select="$start-sigil"/>
1086 </call-template>
1087 </variable>
1088 <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
1089 <variable name="wrapped">
1090 <copy>
1091 <copy-of select="@*"/>
1092 <copy-of select="$start-node/preceding-sibling::node()"/>
1093 <for-each select="$start-tokens[position()!=last()]">
1094 <value-of select="."/>
1095 <if test="position()!=last()">
1096 <value-of select="$start-sigil"/>
1097 </if>
1098 </for-each>
1099 <element name="{$element-name}" namespace="{$element-namespace}">
1100 <if test="string($role)!=''">
1101 <attribute name="role">
1102 <value-of select="$role"/>
1103 </attribute>
1104 </if>
1105 <if test="string($class)!=''">
1106 <attribute name="class">
1107 <value-of select="$class"/>
1108 </attribute>
1109 </if>
1110 <value-of select="$start-tokens[last()]"/>
1111 <copy-of select="$start-node/following-sibling::node()"/>
1112 </element>
1113 <value-of select="substring-after($end-node, $end-sigil)"/>
1114 <copy-of select="$end-node/following-sibling::node()"/>
1115 </copy>
1116 </variable>
1117 <apply-templates select="exsl:node-set($wrapped)/*" mode="LesML:inline">
1118 <with-param name="element-name" select="$element-name"/>
1119 <with-param name="element-namespace" select="$element-namespace"/>
1120 <with-param name="start-sigil" select="$start-sigil"/>
1121 <with-param name="end-sigil" select="$end-sigil"/>
1122 <with-param name="role" select="$role"/>
1123 </apply-templates>
1124 </when>
1125 <otherwise>
1126 <copy>
1127 <copy-of select="@*"/>
1128 <apply-templates select="node()" mode="LesML:inline">
1129 <with-param name="element-name" select="$element-name"/>
1130 <with-param name="element-namespace" select="$element-namespace"/>
1131 <with-param name="start-sigil" select="$start-sigil"/>
1132 <with-param name="end-sigil" select="$end-sigil"/>
1133 <with-param name="role" select="$role"/>
1134 </apply-templates>
1135 </copy>
1136 </otherwise>
1137 </choose>
1138 </when>
1139 <otherwise>
1140 <copy-of select="."/>
1141 </otherwise>
1142 </choose>
1143 </template>
1144 <template match="*" mode="LesML:partition">
1145 <param name="start-sigil"/>
1146 <param name="end-sigil"/>
1147 <param name="separator"/>
1148 <param name="ncname-keys" select="false()"/>
1149 <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
1150 <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))"/>
1151 <choose>
1152 <when test="$end-node and $has-start-node">
1153 <variable name="preceding-fragment">
1154 <copy-of select="$end-node/preceding-sibling::node()"/>
1155 <value-of select="substring-before($end-node, $end-sigil)"/>
1156 </variable>
1157 <variable name="preceding" select="exsl:node-set($preceding-fragment)/node()"/>
1158 <variable name="start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()][not($ncname-keys) or not(following-sibling::* or following-sibling::comment())]"/>
1159 <variable name="start-tokens-fragment">
1160 <if test="$start-node">
1161 <call-template name="LesML:split">
1162 <with-param name="source" select="string($start-node)"/>
1163 <with-param name="separator" select="$start-sigil"/>
1164 </call-template>
1165 </if>
1166 </variable>
1167 <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
1168 <variable name="innards-fragment">
1169 <value-of select="$start-tokens[last()]"/>
1170 <copy-of select="$start-node/following-sibling::node()"/>
1171 </variable>
1172 <variable name="innards" select="exsl:node-set($innards-fragment)/node()"/>
1173 <variable name="separator-node" select="($innards[self::text() and contains(., $separator)])[not($ncname-keys)*(last()-1)+1]"/>
1174 <choose>
1175 <when test="not($start-node) or $separator-node[following-sibling::* or following-sibling::comment()]">
1176 <variable name="bad-start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()]"/>
1177 <variable name="bad-start-tokens-fragment">
1178 <call-template name="LesML:split">
1179 <with-param name="source" select="string($bad-start-node)"/>
1180 <with-param name="separator" select="$start-sigil"/>
1181 </call-template>
1182 </variable>
1183 <element name="span" namespace="&xhtml;">
1184 <copy-of select="$bad-start-node/preceding-sibling::node()"/>
1185 <for-each select="exsl:node-set($bad-start-tokens-fragment)/*">
1186 <value-of select="."/>
1187 <if test="position()!=last()">
1188 <processing-instruction name="LesML-Token-Escape">
1189 <value-of select="$start-sigil"/>
1190 </processing-instruction>
1191 </if>
1192 </for-each>
1193 <copy-of select="$bad-start-node/following-sibling::node()"/>
1194 <value-of select="$end-sigil"/>
1195 <value-of select="substring-after($end-node, $end-sigil)"/>
1196 <copy-of select="$end-node/following-sibling::node()"/>
1197 </element>
1198 </when>
1199 <when test="$separator-node">
1200 <variable name="keyval-fragment">
1201 <call-template name="LesML:split">
1202 <with-param name="source" select="$separator-node"/>
1203 <with-param name="separator" select="$separator"/>
1204 </call-template>
1205 </variable>
1206 <variable name="keyval" select="exsl:node-set($keyval-fragment)/*"/>
1207 <variable name="key-fragment">
1208 <choose>
1209 <when test="$ncname-keys">
1210 <for-each select="$separator-node/preceding-sibling::node()">
1211 <value-of select="."/>
1212 </for-each>
1213 <value-of select="$keyval[1]"/>
1214 </when>
1215 <otherwise>
1216 <copy-of select="$separator-node/preceding-sibling::node()"/>
1217 <for-each select="$keyval[position()!=last()]">
1218 <value-of select="."/>
1219 <if test="position()!=last()">
1220 <value-of select="$separator"/>
1221 </if>
1222 </for-each>
1223 </otherwise>
1224 </choose>
1225 </variable>
1226 <variable name="value">
1227 <choose>
1228 <when test="$ncname-keys">
1229 <for-each select="$keyval[position()!=1]">
1230 <value-of select="."/>
1231 <if test="position()!=last()">
1232 <value-of select="$separator"/>
1233 </if>
1234 </for-each>
1235 </when>
1236 <otherwise>
1237 <value-of select="$keyval[last()]"/>
1238 </otherwise>
1239 </choose>
1240 <for-each select="$separator-node/following-sibling::node()">
1241 <value-of select="."/>
1242 </for-each>
1243 </variable>
1244 <choose>
1245 <when test="not($ncname-keys) or /self::node()[translate(normalize-space($key-fragment), ' /([,*', '')=$key-fragment and exsldyn:evaluate(concat('not(self::html:', $key-fragment, ')'))]">
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"/>
1252 </if>
1253 </for-each>
1254 </element>
1255 <element name="span" namespace="&xhtml;">
1256 <copy-of select="$key-fragment"/>
1257 </element>
1258 <element name="span" namespace="&xhtml;">
1259 <value-of select="$value"/>
1260 </element>
1261 <element name="span" namespace="&xhtml;">
1262 <value-of select="substring-after($end-node, $end-sigil)"/>
1263 <copy-of select="$end-node/following-sibling::node()"/>
1264 </element>
1265 </when>
1266 <otherwise>
1267 <element name="span" namespace="&xhtml;">
1268 <copy-of select="$start-node/preceding-sibling::node()"/>
1269 <for-each select="$start-tokens[position()!=last()]">
1270 <value-of select="."/>
1271 <if test="position()!=last()">
1272 <value-of select="$start-sigil"/>
1273 </if>
1274 </for-each>
1275 <processing-instruction name="LesML-Token-Escape">
1276 <value-of select="$start-sigil"/>
1277 </processing-instruction>
1278 <value-of select="$start-tokens[last()]"/>
1279 <value-of select="$start-node/following-sibling::node()"/>
1280 <value-of select="$end-sigil"/>
1281 <value-of select="substring-after($end-node, $end-sigil)"/>
1282 <copy-of select="$end-node/following-sibling::node()"/>
1283 </element>
1284 </otherwise>
1285 </choose>
1286 </when>
1287 <otherwise>
1288 <element name="span" namespace="&xhtml;">
1289 <copy-of select="$start-node/preceding-sibling::node()"/>
1290 <for-each select="$start-tokens[position()!=last()]">
1291 <value-of select="."/>
1292 <if test="position()!=last()">
1293 <value-of select="$start-sigil"/>
1294 </if>
1295 </for-each>
1296 <processing-instruction name="LesML-Token-Escape">
1297 <value-of select="$start-sigil"/>
1298 </processing-instruction>
1299 <value-of select="$start-tokens[last()]"/>
1300 <copy-of select="$start-node/following-sibling::node()"/>
1301 <value-of select="$end-sigil"/>
1302 <value-of select="substring-after($end-node, $end-sigil)"/>
1303 <copy-of select="$end-node/following-sibling::node()"/>
1304 </element>
1305 </otherwise>
1306 </choose>
1307 </when>
1308 <when test="$end-node">
1309 <element name="span" namespace="&xhtml;">
1310 <copy-of select="$end-node/preceding-sibling::node()"/>
1311 <value-of select="substring-before($end-node, $end-sigil)"/>
1312 <processing-instruction name="LesML-Token-Escape">
1313 <value-of select="$end-sigil"/>
1314 </processing-instruction>
1315 <value-of select="substring-after($end-node, $end-sigil)"/>
1316 <copy-of select="$end-node/following-sibling::node()"/>
1317 </element>
1318 </when>
1319 <otherwise>
1320 <processing-instruction name="LesML-All-Done"/>
1321 </otherwise>
1322 </choose>
1323 </template>
1324 <template match="node()" mode="LesML:comment">
1325 <param name="footnote-ids" select="/.."/>
1326 <variable name="result">
1327 <choose>
1328 <when test="self::*">
1329 <variable name="start-node" select="text()[contains(., '⌦')][1]"/>
1330 <variable name="after-start">
1331 <if test="$start-node">
1332 <value-of select="substring-after($start-node, '⌦')"/>
1333 </if>
1334 </variable>
1335 <variable name="has-end-node" select="contains($after-start, '⌫') or $start-node/following-sibling::text()[contains(., '⌫')]"/>
1336 <choose>
1337 <when test="$start-node and $has-end-node">
1338 <variable name="following">
1339 <value-of select="$after-start"/>
1340 <copy-of select="$start-node/following-sibling::node()"/>
1341 </variable>
1342 <variable name="end-node" select="exsl:node-set($following)/text()[contains(., '⌫')][last()]"/>
1343 <variable name="comment">
1344 <for-each select="$end-node/preceding-sibling::node()">
1345 <value-of select="."/>
1346 </for-each>
1347 <value-of select="substring-before($end-node, '⌫')"/>
1348 </variable>
1349 <variable name="rest-fragment">
1350 <element name="span" namespace="&xhtml;">
1351 <value-of select="substring-after($end-node, '⌫')"/>
1352 <copy-of select="$end-node/following-sibling::node()"/>
1353 </element>
1354 </variable>
1355 <variable name="commented-rest-fragment">
1356 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:comment">
1357 <with-param name="footnote-ids" select="$footnote-ids"/>
1358 </apply-templates>
1359 </variable>
1360 <copy>
1361 <copy-of select="@*"/>
1362 <copy-of select="$start-node/preceding-sibling::node()"/>
1363 <copy-of select="substring-before($start-node, '⌦')"/>
1364 <call-template name="LesML:comment-out">
1365 <with-param name="source" select="string($comment)"/>
1366 </call-template>
1367 <copy-of select="exsl:node-set($commented-rest-fragment)/*/node()"/>
1368 </copy>
1369 </when>
1370 <when test="$start-node">
1371 <variable name="rest-fragment">
1372 <element name="div" namespace="&xhtml;">
1373 <value-of select="substring-after($after-start, '⌦')"/>
1374 <copy-of select="$start-node/following-sibling::node()"/>
1375 </element>
1376 </variable>
1377 <variable name="commented-rest-fragment">
1378 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:comment">
1379 <with-param name="footnote-ids" select="$footnote-ids"/>
1380 </apply-templates>
1381 </variable>
1382 <copy>
1383 <copy-of select="@*"/>
1384 <copy-of select="$start-node/preceding-sibling::node()"/>
1385 <copy-of select="substring-before($start-node, '⌦')"/>
1386 <text>^</text>
1387 <copy-of select="exsl:node-set($commented-rest-fragment)/*/node()"/>
1388 </copy>
1389 </when>
1390 <otherwise>
1391 <copy>
1392 <copy-of select="@*"/>
1393 <apply-templates select="node()" mode="LesML:comment">
1394 <with-param name="footnote-ids" select="$footnote-ids"/>
1395 </apply-templates>
1396 </copy>
1397 </otherwise>
1398 </choose>
1399 </when>
1400 <when test="self::text()[contains(., '⌧')]">
1401 <variable name="split-fragment">
1402 <call-template name="LesML:split">
1403 <with-param name="source" select="string()"/>
1404 <with-param name="separator" select="'⌧'"/>
1405 </call-template>
1406 </variable>
1407 <for-each select="exsl:node-set($split-fragment)/node()">
1408 <value-of select="."/>
1409 <if test="position()!=last()">
1410 <call-template name="LesML:comment-out"/>
1411 </if>
1412 </for-each>
1413 </when>
1414 <otherwise>
1415 <copy-of select="."/>
1416 </otherwise>
1417 </choose>
1418 </variable>
1419 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:attrify">
1420 <with-param name="footnote-ids" select="$footnote-ids"/>
1421 </apply-templates>
1422 </template>
1423 <template match="node()" mode="LesML:attrify">
1424 <param name="footnote-ids" select="/.."/>
1425 <variable name="result">
1426 <choose>
1427 <when test="self::*">
1428 <variable name="partitioned-fragment">
1429 <apply-templates mode="LesML:partition" select=".">
1430 <with-param name="start-sigil" select="'{@'"/>
1431 <with-param name="end-sigil" select="'&quot;}'"/>
1432 <with-param name="separator" select="'=&quot;'"/>
1433 <with-param name="ncname-keys" select="true()"/>
1434 </apply-templates>
1435 </variable>
1436 <variable name="partitioned" select="exsl:node-set($partitioned-fragment)/node()"/>
1437 <choose>
1438 <when test="count($partitioned)>1">
1439 <variable name="processed">
1440 <copy>
1441 <copy-of select="@*"/>
1442 <copy-of select="$partitioned[1]/node()"/>
1443 <element name="LesML:attribute" namespace="&LesML;">
1444 <attribute name="{$partitioned[2]}">
1445 <value-of select="$partitioned[3]"/>
1446 </attribute>
1447 </element>
1448 <copy-of select="$partitioned[4]/node()"/>
1449 </copy>
1450 </variable>
1451 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:attrify">
1452 <with-param name="footnote-ids" select="$footnote-ids"/>
1453 </apply-templates>
1454 </when>
1455 <when test="$partitioned[self::processing-instruction() and local-name()='LesML-All-Done']">
1456 <copy>
1457 <copy-of select="@*"/>
1458 <apply-templates select="node()" mode="LesML:attrify">
1459 <with-param name="footnote-ids" select="$footnote-ids"/>
1460 </apply-templates>
1461 </copy>
1462 </when>
1463 <otherwise>
1464 <variable name="processed">
1465 <copy>
1466 <copy-of select="@*"/>
1467 <copy-of select="$partitioned/node()"/>
1468 </copy>
1469 </variable>
1470 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:attrify">
1471 <with-param name="footnote-ids" select="$footnote-ids"/>
1472 </apply-templates>
1473 </otherwise>
1474 </choose>
1475 </when>
1476 <otherwise>
1477 <copy-of select="."/>
1478 </otherwise>
1479 </choose>
1480 </variable>
1481 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:linkify">
1482 <with-param name="footnote-ids" select="$footnote-ids"/>
1483 </apply-templates>
1484 </template>
1485 <template match="node()" mode="LesML:linkify">
1486 <param name="footnote-ids" select="/.."/>
1487 <variable name="result">
1488 <choose>
1489 <when test="processing-instruction()[local-name()='LesML-All-Done']">
1490 <copy>
1491 <copy-of select="@*|node()[not(self::processing-instruction() and local-name()='LesML-All-Done')]"/>
1492 </copy>
1493 </when>
1494 <when test="self::*">
1495 <variable name="partitioned-fragment">
1496 <apply-templates mode="LesML:partition" select=".">
1497 <with-param name="start-sigil" select="'{🔗'"/>
1498 <with-param name="end-sigil" select="'>}'"/>
1499 <with-param name="separator" select="'&lt;'"/>
1500 </apply-templates>
1501 </variable>
1502 <variable name="partitioned" select="exsl:node-set($partitioned-fragment)/node()"/>
1503 <choose>
1504 <when test="count($partitioned)>1">
1505 <variable name="processed">
1506 <copy>
1507 <copy-of select="@*"/>
1508 <copy-of select="$partitioned[1]/node()"/>
1509 <element name="a" namespace="&xhtml;">
1510 <attribute name="href">
1511 <value-of select="$partitioned[3]"/>
1512 </attribute>
1513 <processing-instruction name="LesML-All-Done"/>
1514 <choose>
1515 <when test="not($partitioned[2]/node())">
1516 <value-of select="$partitioned[3]"/>
1517 </when>
1518 <otherwise>
1519 <copy-of select="$partitioned[2]/node()"/>
1520 </otherwise>
1521 </choose>
1522 </element>
1523 <copy-of select="$partitioned[4]/node()"/>
1524 </copy>
1525 </variable>
1526 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:linkify">
1527 <with-param name="footnote-ids" select="$footnote-ids"/>
1528 </apply-templates>
1529 </when>
1530 <when test="$partitioned[self::processing-instruction() and local-name()='LesML-All-Done']">
1531 <copy>
1532 <copy-of select="@*"/>
1533 <apply-templates select="node()" mode="LesML:linkify">
1534 <with-param name="footnote-ids" select="$footnote-ids"/>
1535 </apply-templates>
1536 </copy>
1537 </when>
1538 <otherwise>
1539 <variable name="processed">
1540 <copy>
1541 <copy-of select="@*"/>
1542 <copy-of select="$partitioned/node()"/>
1543 </copy>
1544 </variable>
1545 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:linkify">
1546 <with-param name="footnote-ids" select="$footnote-ids"/>
1547 </apply-templates>
1548 </otherwise>
1549 </choose>
1550 </when>
1551 <otherwise>
1552 <copy-of select="."/>
1553 </otherwise>
1554 </choose>
1555 </variable>
1556 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:strikethrough">
1557 <with-param name="footnote-ids" select="$footnote-ids"/>
1558 </apply-templates>
1559 </template>
1560 <template match="node()" mode="LesML:strikethrough">
1561 <param name="footnote-ids" select="/.."/>
1562 <variable name="result">
1563 <apply-templates select="." mode="LesML:inline">
1564 <with-param name="element-name" select="'s'"/>
1565 <with-param name="element-namespace" select="'&xhtml;'"/>
1566 <with-param name="start-sigil" select="'⸠'"/>
1567 <with-param name="end-sigil" select="'⸡'"/>
1568 </apply-templates>
1569 </variable>
1570 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:underline">
1571 <with-param name="footnote-ids" select="$footnote-ids"/>
1572 </apply-templates>
1573 </template>
1574 <template match="node()" mode="LesML:underline">
1575 <param name="footnote-ids" select="/.."/>
1576 <variable name="result">
1577 <apply-templates select="." mode="LesML:inline">
1578 <with-param name="element-name" select="'u'"/>
1579 <with-param name="element-namespace" select="'&xhtml;'"/>
1580 <with-param name="start-sigil" select="'⸤'"/>
1581 <with-param name="end-sigil" select="'⸥'"/>
1582 </apply-templates>
1583 </variable>
1584 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:noted">
1585 <with-param name="footnote-ids" select="$footnote-ids"/>
1586 </apply-templates>
1587 </template>
1588 <template match="node()" mode="LesML:noted">
1589 <param name="footnote-ids" select="/.."/>
1590 <variable name="result">
1591 <apply-templates select="." mode="LesML:inline">
1592 <with-param name="element-name" select="'small'"/>
1593 <with-param name="element-namespace" select="'&xhtml;'"/>
1594 <with-param name="start-sigil" select="'⟦'"/>
1595 <with-param name="end-sigil" select="'⟧'"/>
1596 <with-param name="role" select="'note'"/>
1597 </apply-templates>
1598 </variable>
1599 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:parenthetical">
1600 <with-param name="footnote-ids" select="$footnote-ids"/>
1601 </apply-templates>
1602 </template>
1603 <template match="node()" mode="LesML:parenthetical">
1604 <param name="footnote-ids" select="/.."/>
1605 <variable name="result">
1606 <apply-templates select="." mode="LesML:inline">
1607 <with-param name="element-name" select="'small'"/>
1608 <with-param name="element-namespace" select="'&xhtml;'"/>
1609 <with-param name="start-sigil" select="'⸨'"/>
1610 <with-param name="end-sigil" select="'⸩'"/>
1611 </apply-templates>
1612 </variable>
1613 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:code">
1614 <with-param name="footnote-ids" select="$footnote-ids"/>
1615 </apply-templates>
1616 </template>
1617 <template match="node()" mode="LesML:code">
1618 <param name="footnote-ids" select="/.."/>
1619 <variable name="result">
1620 <apply-templates select="." mode="LesML:inline">
1621 <with-param name="element-name" select="'code'"/>
1622 <with-param name="element-namespace" select="'&xhtml;'"/>
1623 <with-param name="start-sigil" select="'`'"/>
1624 <with-param name="end-sigil" select="'´'"/>
1625 </apply-templates>
1626 </variable>
1627 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:titled">
1628 <with-param name="footnote-ids" select="$footnote-ids"/>
1629 </apply-templates>
1630 </template>
1631 <template match="node()" mode="LesML:titled">
1632 <param name="footnote-ids" select="/.."/>
1633 <variable name="result">
1634 <apply-templates select="." mode="LesML:inline">
1635 <with-param name="element-name" select="'cite'"/>
1636 <with-param name="element-namespace" select="'&xhtml;'"/>
1637 <with-param name="start-sigil" select="'⟪'"/>
1638 <with-param name="end-sigil" select="'⟫'"/>
1639 </apply-templates>
1640 </variable>
1641 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:named">
1642 <with-param name="footnote-ids" select="$footnote-ids"/>
1643 </apply-templates>
1644 </template>
1645 <template match="node()" mode="LesML:named">
1646 <param name="footnote-ids" select="/.."/>
1647 <variable name="result">
1648 <apply-templates select="." mode="LesML:inline">
1649 <with-param name="element-name" select="'u'"/>
1650 <with-param name="element-namespace" select="'&xhtml;'"/>
1651 <with-param name="start-sigil" select="'⸶'"/>
1652 <with-param name="end-sigil" select="'⸷'"/>
1653 <with-param name="class" select="'name'"/>
1654 </apply-templates>
1655 </variable>
1656 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:offset">
1657 <with-param name="footnote-ids" select="$footnote-ids"/>
1658 </apply-templates>
1659 </template>
1660 <template match="node()" mode="LesML:offset">
1661 <param name="footnote-ids" select="/.."/>
1662 <variable name="result">
1663 <apply-templates select="." mode="LesML:inline">
1664 <with-param name="element-name" select="'i'"/>
1665 <with-param name="element-namespace" select="'&xhtml;'"/>
1666 <with-param name="start-sigil" select="'⟨'"/>
1667 <with-param name="end-sigil" select="'⟩'"/>
1668 </apply-templates>
1669 </variable>
1670 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:bolded">
1671 <with-param name="footnote-ids" select="$footnote-ids"/>
1672 </apply-templates>
1673 </template>
1674 <template match="node()" mode="LesML:bolded">
1675 <param name="footnote-ids" select="/.."/>
1676 <variable name="result">
1677 <apply-templates select="." mode="LesML:inline">
1678 <with-param name="element-name" select="'b'"/>
1679 <with-param name="element-namespace" select="'&xhtml;'"/>
1680 <with-param name="start-sigil" select="'⦃'"/>
1681 <with-param name="end-sigil" select="'⦄'"/>
1682 </apply-templates>
1683 </variable>
1684 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:important">
1685 <with-param name="footnote-ids" select="$footnote-ids"/>
1686 </apply-templates>
1687 </template>
1688 <template match="node()" mode="LesML:important">
1689 <param name="footnote-ids" select="/.."/>
1690 <variable name="result">
1691 <apply-templates select="." mode="LesML:inline">
1692 <with-param name="element-name" select="'strong'"/>
1693 <with-param name="element-namespace" select="'&xhtml;'"/>
1694 <with-param name="start-sigil" select="'☞'"/>
1695 <with-param name="end-sigil" select="'☜'"/>
1696 </apply-templates>
1697 </variable>
1698 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:emphasized">
1699 <with-param name="footnote-ids" select="$footnote-ids"/>
1700 </apply-templates>
1701 </template>
1702 <template match="node()" mode="LesML:emphasized">
1703 <param name="footnote-ids" select="/.."/>
1704 <variable name="result">
1705 <apply-templates select="." mode="LesML:inline">
1706 <with-param name="element-name" select="'em'"/>
1707 <with-param name="element-namespace" select="'&xhtml;'"/>
1708 <with-param name="start-sigil" select="'⹐'"/>
1709 <with-param name="end-sigil" select="'⹑'"/>
1710 </apply-templates>
1711 </variable>
1712 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:footnoted">
1713 <with-param name="footnote-ids" select="$footnote-ids"/>
1714 </apply-templates>
1715 </template>
1716 <template match="node()" mode="LesML:footnoted">
1717 <param name="footnote-ids" select="/.."/>
1718 <choose>
1719 <when test="self::*">
1720 <variable name="start-node" select="text()[contains(., '^')][1]"/>
1721 <variable name="after-start" select="substring-after($start-node, '^')"/>
1722 <variable name="footnote-id" select="substring-before($after-start, '.')"/>
1723 <variable name="matched-footnote" select="$footnote-ids[.=$footnote-id]"/>
1724 <choose>
1725 <when test="$footnote-id!='' and $matched-footnote">
1726 <variable name="rest-fragment">
1727 <element name="div" namespace="&xhtml;">
1728 <value-of select="substring-after($after-start, '.')"/>
1729 <copy-of select="$start-node/following-sibling::node()"/>
1730 </element>
1731 </variable>
1732 <variable name="footnoted-rest-fragment">
1733 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:footnoted">
1734 <with-param name="footnote-ids" select="$footnote-ids"/>
1735 </apply-templates>
1736 </variable>
1737 <copy>
1738 <copy-of select="@*"/>
1739 <copy-of select="$start-node/preceding-sibling::node()"/>
1740 <copy-of select="substring-before($start-node, '^')"/>
1741 <element name="a" namespace="&xhtml;">
1742 <attribute name="id">
1743 <text>LesML.fnref.</text>
1744 <value-of select="generate-id($start-node)"/>
1745 </attribute>
1746 <attribute name="role">
1747 <text>doc-noteref</text>
1748 </attribute>
1749 <attribute name="href">
1750 <text>#</text>
1751 <value-of select="$footnote-id"/>
1752 </attribute>
1753 <attribute name="target">
1754 <text>_self</text>
1755 </attribute>
1756 </element>
1757 <copy-of select="exsl:node-set($footnoted-rest-fragment)/*/node()"/>
1758 </copy>
1759 </when>
1760 <when test="$start-node">
1761 <variable name="rest-fragment">
1762 <element name="div" namespace="&xhtml;">
1763 <value-of select="substring-after($after-start, '^')"/>
1764 <copy-of select="$start-node/following-sibling::node()"/>
1765 </element>
1766 </variable>
1767 <variable name="footnoted-rest-fragment">
1768 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:footnoted">
1769 <with-param name="footnote-ids" select="$footnote-ids"/>
1770 </apply-templates>
1771 </variable>
1772 <copy>
1773 <copy-of select="@*"/>
1774 <copy-of select="$start-node/preceding-sibling::node()"/>
1775 <copy-of select="substring-before($start-node, '^')"/>
1776 <text>^</text>
1777 <copy-of select="exsl:node-set($footnoted-rest-fragment)/*/node()"/>
1778 </copy>
1779 </when>
1780 <otherwise>
1781 <copy>
1782 <copy-of select="@*"/>
1783 <apply-templates select="node()" mode="LesML:footnoted">
1784 <with-param name="footnote-ids" select="$footnote-ids"/>
1785 </apply-templates>
1786 </copy>
1787 </otherwise>
1788 </choose>
1789 </when>
1790 <otherwise>
1791 <copy-of select="."/>
1792 </otherwise>
1793 </choose>
1794 </template>
1795 </transform>
This page took 0.460077 seconds and 3 git commands to generate.