]> Lady’s Gitweb - LesML/blob - parser.xslt
Support attributes inside of links
[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 section-break "">
17 <!ENTITY sigiled-text "(string-length($text)=1 or substring($text, 2, 1)=' ' or substring($text, 2, 1)='¶')">
18 <!ENTITY unsigiled-text "concat(translate(substring($text, 2, 1), ' ', ''), substring($text, 3, string-length($text)-2))">
19 <!ENTITY xhtml "http://www.w3.org/1999/xhtml">
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 <element name="article" namespace="&xhtml;">
293 <for-each select="$params/html:div/html:dt[string()=' LANG ']">
294 <attribute name="lang">
295 <value-of select="following-sibling::html:dd"/>
296 </attribute>
297 <attribute name="xml:lang">
298 <value-of select="following-sibling::html:dd"/>
299 </attribute>
300 </for-each>
301 <for-each select="$params/html:div/html:dt[string()='profile']">
302 <attribute name="data-lesml-profile">
303 <value-of select="following-sibling::html:dd"/>
304 </attribute>
305 </for-each>
306 <if test="$record-separators[preceding-sibling::*[normalize-space()!='']]">
307 <element name="footer" namespace="&xhtml;">
308 <attribute name="class">
309 <text>head</text>
310 </attribute>
311 <for-each select="$record-separators">
312 <variable name="position" select="position()"/>
313 <variable name="prev-separator" select="$record-separators[($position)-1]"/>
314 <variable name="fields" select="exslset:leading(exslset:trailing($doclines, $prev-separator), .)"/>
315 <if test="$fields">
316 <element name="dl" namespace="&xhtml;">
317 <for-each select="$fields">
318 <choose>
319 <when test="starts-with(., ' ') and exslset:leading($fields, .)"/>
320 <otherwise>
321 <variable name="next" select="exslset:intersection(following-sibling::*[not(starts-with(., ' '))][1], $fields)"/>
322 <element name="div" namespace="&xhtml;">
323 <element name="dt" namespace="&xhtml;">
324 <value-of select="normalize-space(substring-before(., ':'))"/>
325 </element>
326 <element name="dd" namespace="&xhtml;">
327 <variable name="firstline">
328 <choose>
329 <when test="contains(., ':')">
330 <value-of select="normalize-space(substring-after(., ':'))"/>
331 </when>
332 <otherwise>
333 <value-of select="normalize-space(.)"/>
334 </otherwise>
335 </choose>
336 </variable>
337 <choose>
338 <when test="substring($firstline, string-length($firstline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
339 <value-of select="substring($firstline, 1, string-length($firstline)-1)"/>
340 </when>
341 <otherwise>
342 <value-of select="$firstline"/>
343 </otherwise>
344 </choose>
345 <for-each select="exslset:intersection(following-sibling::*[starts-with(., ' ')], exslset:leading($fields, $next))">
346 <variable name="nextline" select="normalize-space(.)"/>
347 <choose>
348 <when test="substring($nextline, string-length($nextline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
349 <value-of select="substring($nextline, 1, string-length($nextline)-1)"/>
350 </when>
351 <otherwise>
352 <value-of select="$nextline"/>
353 </otherwise>
354 </choose>
355 </for-each>
356 </element>
357 </element>
358 </otherwise>
359 </choose>
360 </for-each>
361 </element>
362 </if>
363 <if test=".!='%%'">
364 <call-template name="LesML:comment-out">
365 <with-param name="source" select="substring-after(., '%%')"/>
366 </call-template>
367 </if>
368 </for-each>
369 </element>
370 </if>
371 <element name="div" namespace="&xhtml;">
372 <attribute name="class">
373 <text>body</text>
374 </attribute>
375 <call-template name="LesML:paragraphize">
376 <with-param name="lines" select="exslset:trailing($doclines, $record-separators[last()])"/>
377 </call-template>
378 </element>
379 </element>
380 </if>
381 <if test="$docsep">
382 <call-template name="LesML:parse">
383 <with-param name="lines" select="$docsep|exslset:trailing($lines, $docsep)"/>
384 <with-param name="parent-params" select="$params"/>
385 </call-template>
386 </if>
387 </template>
388 <template name="LesML:block">
389 <param name="lines" select="/.."/>
390 <variable name="last-lines" select="$lines[normalize-space()!='' and (normalize-space(following-sibling::*[1])='' or position()=last())]"/>
391 <for-each select="$last-lines">
392 <variable name="position" select="position()"/>
393 <variable name="prev-last" select="$last-lines[($position)-1]"/>
394 <variable name="linespans" select="(exslset:intersection(exslset:trailing($lines, $prev-last), exslset:leading($lines, .))|.)[normalize-space()!='']"/>
395 <variable name="prefix" select="substring(translate(., ' &#x9;', ''), 1, 1)"/>
396 <variable name="all-prefixed" select="not($linespans[not(starts-with(translate(., ' &#x9;', ''), $prefix))])"/>
397 <variable name="quoted" select="$all-prefixed and $prefix='»'"/>
398 <variable name="bracketed" select="$all-prefixed and $prefix=']'"/>
399 <choose>
400 <when test="count($linespans)=1 and translate(., concat($LESML_SECTION_BREAK_CHARS, ' &#x9;'), '')=''">
401 <element name="hr" namespace="&xhtml;"/>
402 </when>
403 <when test="$quoted or $bracketed">
404 <variable name="innerlines-fragment">
405 <for-each select="$linespans">
406 <variable name="inner">
407 <value-of select="substring-after(., $prefix)"/>
408 </variable>
409 <copy>
410 <choose>
411 <when test="starts-with($inner, ' ') or starts-with($inner, '&#x9;')">
412 <value-of select="substring($inner, 1+count(exslstr:tokenize($inner, '')[normalize-space()='' and not(preceding-sibling::*[normalize-space()!=''])]))"/>
413 </when>
414 <otherwise>
415 <value-of select="$inner"/>
416 </otherwise>
417 </choose>
418 </copy>
419 </for-each>
420 </variable>
421 <variable name="blocked-fragment">
422 <call-template name="LesML:block">
423 <with-param name="lines" select="exsl:node-set($innerlines-fragment)/*"/>
424 </call-template>
425 </variable>
426 <variable name="innerpars" select="exsl:node-set($blocked-fragment)/node()"/>
427 <choose>
428 <when test="$quoted and $innerpars[position()=last() and self::html:footer]">
429 <element name="figure" namespace="&xhtml;">
430 <element name="blockquote" namespace="&xhtml;">
431 <copy-of select="$innerpars[position()!=last()]"/>
432 </element>
433 <element name="figcaption" namespace="&xhtml;">
434 <copy-of select="$innerpars[last()]/node()"/>
435 </element>
436 </element>
437 </when>
438 <when test="$quoted">
439 <element name="blockquote" namespace="&xhtml;">
440 <copy-of select="$innerpars"/>
441 </element>
442 </when>
443 <when test="$bracketed">
444 <element name="footer" namespace="&xhtml;">
445 <copy-of select="$innerpars"/>
446 </element>
447 </when>
448 </choose>
449 </when>
450 <otherwise>
451 <variable name="preformatted" select="$all-prefixed and $prefix='|'"/>
452 <variable name="text">
453 <for-each select="$linespans">
454 <choose>
455 <when test="$preformatted">
456 <value-of select="substring-after(., '|')"/>
457 </when>
458 <otherwise>
459 <value-of select="normalize-space()"/>
460 </otherwise>
461 </choose>
462 <if test="position()!=count($linespans)">
463 <choose>
464 <when test="$preformatted">
465 <text>&#xA;</text>
466 </when>
467 <otherwise>
468 <text> </text>
469 </otherwise>
470 </choose>
471 </if>
472 </for-each>
473 </variable>
474 <choose>
475 <when test="$preformatted">
476 <element name="pre" namespace="&xhtml;">
477 <call-template name="LesML:id-and-contents">
478 <with-param name="source" select="$text"/>
479 </call-template>
480 </element>
481 </when>
482 <when test="string($text)=''"/>
483 <when test="starts-with($text, '⁌') and &sigiled-text;">
484 <element name="h1" namespace="&xhtml;">
485 <call-template name="LesML:id-and-contents">
486 <with-param name="source" select="&unsigiled-text;"/>
487 </call-template>
488 </element>
489 </when>
490 <when test="starts-with($text, '§') and &sigiled-text;">
491 <element name="h2" namespace="&xhtml;">
492 <call-template name="LesML:id-and-contents">
493 <with-param name="source" select="&unsigiled-text;"/>
494 </call-template>
495 </element>
496 </when>
497 <when test="starts-with($text, '❦') and &sigiled-text;">
498 <element name="h3" namespace="&xhtml;">
499 <call-template name="LesML:id-and-contents">
500 <with-param name="source" select="&unsigiled-text;"/>
501 </call-template>
502 </element>
503 </when>
504 <when test="starts-with($text, '✠') and &sigiled-text;">
505 <element name="h4" namespace="&xhtml;">
506 <call-template name="LesML:id-and-contents">
507 <with-param name="source" select="&unsigiled-text;"/>
508 </call-template>
509 </element>
510 </when>
511 <when test="starts-with($text, '•') and &sigiled-text;">
512 <element name="li" namespace="&xhtml;">
513 <attribute name="class">
514 <text>unordered</text>
515 </attribute>
516 <attribute name="data-level">
517 <text>1</text>
518 </attribute>
519 <element name="p" namespace="&xhtml;">
520 <call-template name="LesML:id-and-contents">
521 <with-param name="source" select="&unsigiled-text;"/>
522 </call-template>
523 </element>
524 </element>
525 </when>
526 <when test="starts-with($text, '🔢') and &sigiled-text;">
527 <element name="li" namespace="&xhtml;">
528 <attribute name="class">
529 <text>ordered</text>
530 </attribute>
531 <attribute name="data-level">
532 <text>1</text>
533 </attribute>
534 <element name="p" namespace="&xhtml;">
535 <call-template name="LesML:id-and-contents">
536 <with-param name="source" select="&unsigiled-text;"/>
537 </call-template>
538 </element>
539 </element>
540 </when>
541 <when test="starts-with($text, '◦') and &sigiled-text;">
542 <element name="li" namespace="&xhtml;">
543 <attribute name="class">
544 <text>unordered</text>
545 </attribute>
546 <attribute name="data-level">
547 <text>2</text>
548 </attribute>
549 <element name="p" namespace="&xhtml;">
550 <call-template name="LesML:id-and-contents">
551 <with-param name="source" select="&unsigiled-text;"/>
552 </call-template>
553 </element>
554 </element>
555 </when>
556 <when test="starts-with($text, '🔠') and &sigiled-text;">
557 <element name="li" namespace="&xhtml;">
558 <attribute name="class">
559 <text>ordered</text>
560 </attribute>
561 <attribute name="data-level">
562 <text>2</text>
563 </attribute>
564 <element name="p" namespace="&xhtml;">
565 <call-template name="LesML:id-and-contents">
566 <with-param name="source" select="&unsigiled-text;"/>
567 </call-template>
568 </element>
569 </element>
570 </when>
571 <when test="starts-with($text, '▪') and &sigiled-text;">
572 <element name="li" namespace="&xhtml;">
573 <attribute name="class">
574 <text>unordered</text>
575 </attribute>
576 <attribute name="data-level">
577 <text>3</text>
578 </attribute>
579 <element name="p" namespace="&xhtml;">
580 <call-template name="LesML:id-and-contents">
581 <with-param name="source" select="&unsigiled-text;"/>
582 </call-template>
583 </element>
584 </element>
585 </when>
586 <when test="starts-with($text, '🔡') and &sigiled-text;">
587 <element name="li" namespace="&xhtml;">
588 <attribute name="class">
589 <text>ordered</text>
590 </attribute>
591 <attribute name="data-level">
592 <text>3</text>
593 </attribute>
594 <element name="p" namespace="&xhtml;">
595 <call-template name="LesML:id-and-contents">
596 <with-param name="source" select="&unsigiled-text;"/>
597 </call-template>
598 </element>
599 </element>
600 </when>
601 <when test="starts-with($text, '⁃') and &sigiled-text;">
602 <element name="li" namespace="&xhtml;">
603 <attribute name="class">
604 <text>unordered</text>
605 </attribute>
606 <attribute name="data-level">
607 <text>4</text>
608 </attribute>
609 <element name="p" namespace="&xhtml;">
610 <call-template name="LesML:id-and-contents">
611 <with-param name="source" select="&unsigiled-text;"/>
612 </call-template>
613 </element>
614 </element>
615 </when>
616 <when test="starts-with($text, '🔣') and &sigiled-text;">
617 <element name="li" namespace="&xhtml;">
618 <attribute name="class">
619 <text>ordered</text>
620 </attribute>
621 <attribute name="data-level">
622 <text>4</text>
623 </attribute>
624 <element name="p" namespace="&xhtml;">
625 <call-template name="LesML:id-and-contents">
626 <with-param name="source" select="&unsigiled-text;"/>
627 </call-template>
628 </element>
629 </element>
630 </when>
631 <when test="starts-with($text, '🛈') and &sigiled-text;">
632 <element name="div" namespace="&xhtml;">
633 <attribute name="role">
634 <text>note</text>
635 </attribute>
636 <attribute name="class">
637 <text>info</text>
638 </attribute>
639 <element name="p" namespace="&xhtml;">
640 <call-template name="LesML:id-and-contents">
641 <with-param name="source" select="&unsigiled-text;"/>
642 </call-template>
643 </element>
644 </element>
645 </when>
646 <when test="starts-with($text, '⯑') and &sigiled-text;">
647 <element name="div" namespace="&xhtml;">
648 <attribute name="role">
649 <text>note</text>
650 </attribute>
651 <attribute name="class">
652 <text>query</text>
653 </attribute>
654 <element name="p" namespace="&xhtml;">
655 <call-template name="LesML:id-and-contents">
656 <with-param name="source" select="&unsigiled-text;"/>
657 </call-template>
658 </element>
659 </element>
660 </when>
661 <when test="starts-with($text, '⚠') and &sigiled-text;">
662 <element name="div" namespace="&xhtml;">
663 <attribute name="role">
664 <text>note</text>
665 </attribute>
666 <attribute name="class">
667 <text>warn</text>
668 </attribute>
669 <element name="p" namespace="&xhtml;">
670 <call-template name="LesML:id-and-contents">
671 <with-param name="source" select="&unsigiled-text;"/>
672 </call-template>
673 </element>
674 </element>
675 </when>
676 <when test="starts-with($text, '※') and &sigiled-text;">
677 <element name="div" namespace="&xhtml;">
678 <attribute name="role">
679 <text>note</text>
680 </attribute>
681 <attribute name="class">
682 <text>note</text>
683 </attribute>
684 <element name="p" namespace="&xhtml;">
685 <call-template name="LesML:id-and-contents">
686 <with-param name="source" select="&unsigiled-text;"/>
687 </call-template>
688 </element>
689 </element>
690 </when>
691 <when test="starts-with($text, '☡') and &sigiled-text;">
692 <element name="div" namespace="&xhtml;">
693 <attribute name="role">
694 <text>note</text>
695 </attribute>
696 <attribute name="class">
697 <text>caution</text>
698 </attribute>
699 <element name="p" namespace="&xhtml;">
700 <call-template name="LesML:id-and-contents">
701 <with-param name="source" select="&unsigiled-text;"/>
702 </call-template>
703 </element>
704 </element>
705 </when>
706 <when test="starts-with($text, '⋯') and &sigiled-text;">
707 <element name="div" namespace="&xhtml;">
708 <processing-instruction name="LesML-Continuation"/>
709 <element name="p" namespace="&xhtml;">
710 <call-template name="LesML:id-and-contents">
711 <with-param name="source" select="&unsigiled-text;"/>
712 </call-template>
713 </element>
714 </element>
715 </when>
716 <when test="starts-with($text, '#') and &sigiled-text;">
717 <call-template name="LesML:comment-out">
718 <with-param name="source" select="&unsigiled-text;"/>
719 </call-template>
720 </when>
721 <otherwise>
722 <element name="p" namespace="&xhtml;">
723 <call-template name="LesML:id-and-contents">
724 <with-param name="source" select="$text"/>
725 </call-template>
726 </element>
727 </otherwise>
728 </choose>
729 </otherwise>
730 </choose>
731 </for-each>
732 </template>
733 <template name="LesML:paragraphize">
734 <param name="lines" select="/.."/>
735 <variable name="blocked-fragment">
736 <call-template name="LesML:block">
737 <with-param name="lines" select="$lines"/>
738 </call-template>
739 </variable>
740 <variable name="inlined-fragment">
741 <apply-templates select="exsl:node-set($blocked-fragment)/node()" mode="LesML:comment"/>
742 </variable>
743 <apply-templates select="exsl:node-set($inlined-fragment)/node()" mode="LesML:finalize-tree"/>
744 </template>
745 <template match="html:script[@type='text/lesml']">
746 <variable name="lines-fragment">
747 <call-template name="LesML:split">
748 <with-param name="source">
749 <for-each select=".//text()">
750 <value-of select="."/>
751 </for-each>
752 </with-param>
753 </call-template>
754 </variable>
755 <element name="div" namespace="&xhtml;">
756 <call-template name="LesML:parse">
757 <with-param name="lines" select="exsl:node-set($lines-fragment)/*"/>
758 </call-template>
759 </element>
760 </template>
761 <template match="node()" mode="LesML:finalize-attributes">
762 <variable name="notattr" select="following-sibling::node()[not(self::text() and translate(., ' &#x9;', '')='' or self::LesML:attribute)]"/>
763 <for-each select="(.|exslset:leading(following-sibling::node(), $notattr)[self::LesML:attribute])/@*">
764 <copy-of select="."/>
765 <if test="local-name()='lang' and namespace-uri()=''">
766 <attribute name="xml:lang">
767 <value-of select="."/>
768 </attribute>
769 </if>
770 </for-each>
771 </template>
772 <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"/>
773 <template match="LesML:attribute|text()[following-sibling::node()[position()=1 and self::LesML:attribute]]" mode="LesML:finalize-tree" priority="1">
774 <element name="span" namespace="&xhtml;">
775 <apply-templates select="." mode="LesML:finalize-attributes"/>
776 <if test="self::text()">
777 <call-template name="LesML:break-and-unescape">
778 <with-param name="source" select="string(.)"/>
779 </call-template>
780 </if>
781 </element>
782 </template>
783 <template match="html:div" mode="LesML:finalize-tree">
784 <if test="not(processing-instruction()[local-name()='LesML-Continuation']) or not(preceding-sibling::node()[position()=1 and self::html:* and contains(' div li h1 h2 h3 h4 h5 h6 ', local-name())])">
785 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
786 <choose>
787 <when test="processing-instruction()[local-name()='LesML-Continuation'] and $notcontinuation[self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
788 <variable name="notcontinuation2" select="$notcontinuation/following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
789 <element name="hgroup" namespace="&xhtml;">
790 <apply-templates select="node()" mode="LesML:finalize-tree"/>
791 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation2)">
792 <choose>
793 <when test="self::html:div">
794 <apply-templates select="node()" mode="LesML:finalize-tree"/>
795 </when>
796 <otherwise>
797 <copy>
798 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
799 </copy>
800 </otherwise>
801 </choose>
802 </for-each>
803 </element>
804 </when>
805 <when test="not(processing-instruction()[local-name()='LesML-Continuation'])">
806 <copy>
807 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
808 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
809 <apply-templates select="node()" mode="LesML:finalize-tree"/>
810 </for-each>
811 </copy>
812 </when>
813 <otherwise>
814 <apply-templates select="node()" mode="LesML:finalize-tree"/>
815 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
816 <apply-templates select="node()" mode="LesML:finalize-tree"/>
817 </for-each>
818 </otherwise>
819 </choose>
820 </if>
821 </template>
822 <template match="html:h1|html:h2|html:h3|html:h4|html:h5|html:h6" mode="LesML:finalize-tree">
823 <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())]">
824 <choose>
825 <when test="following-sibling::node()[position()=1 and self::html:div]/processing-instruction()[local-name()='LesML-Continuation']">
826 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
827 <element name="hgroup" namespace="&xhtml;">
828 <copy>
829 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
830 </copy>
831 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
832 <apply-templates select="node()" mode="LesML:finalize-tree"/>
833 </for-each>
834 </element>
835 </when>
836 <otherwise>
837 <copy>
838 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
839 </copy>
840 </otherwise>
841 </choose>
842 </if>
843 </template>
844 <template match="html:li" mode="LesML:finalize-tree">
845 <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)]">
846 <apply-templates select="." mode="LesML:finalize-list"/>
847 </if>
848 </template>
849 <template match="html:li" mode="LesML:finalize-list">
850 <param name="parent-level" select="0"/>
851 <variable name="current-class" select="string(@class)"/>
852 <variable name="current-level" select="number(@data-level)"/>
853 <variable name="wrapper">
854 <choose>
855 <when test="@class='ordered'">
856 <text>ol</text>
857 </when>
858 <otherwise>
859 <text>ul</text>
860 </otherwise>
861 </choose>
862 </variable>
863 <variable name="notinlist" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'] or self::html:li and (@data-level>$current-level or @data-level=$current-level and @class=$current-class))][1]"/>
864 <element name="{$wrapper}" namespace="&xhtml;">
865 <for-each select=".|exslset:leading(following-sibling::node(), $notinlist)[self::html:li and @data-level=$current-level]">
866 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
867 <copy>
868 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
869 <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
870 <apply-templates select="node()" mode="LesML:finalize-tree"/>
871 </for-each>
872 <if test="$notcontinuation/self::html:li[@data-level>$current-level]">
873 <apply-templates select="$notcontinuation" mode="LesML:finalize-list">
874 <with-param name="parent-level" select="$current-level"/>
875 </apply-templates>
876 </if>
877 </copy>
878 </for-each>
879 </element>
880 <if test="$notinlist/self::html:li[@data-level>$parent-level]">
881 <apply-templates select="$notinlist" mode="LesML:finalize-list">
882 <with-param name="parent-level" select="$parent-level"/>
883 </apply-templates>
884 </if>
885 </template>
886 <template match="processing-instruction()[local-name()='LesML-Continuation']" mode="LesML:finalize-tree"/>
887 <template match="processing-instruction()[local-name()='LesML-Token-Escape']" mode="LesML:finalize-tree">
888 <value-of select="."/>
889 </template>
890 <template match="text()" mode="LesML:finalize-tree">
891 <call-template name="LesML:break-and-unescape">
892 <with-param name="source" select="string(.)"/>
893 </call-template>
894 </template>
895 <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
896 <copy>
897 <apply-templates select="." mode="LesML:finalize-attributes"/>
898 <apply-templates select="node()" mode="LesML:finalize-tree"/>
899 </copy>
900 </template>
901 <template match="node()" mode="LesML:comment">
902 <variable name="result">
903 <choose>
904 <when test="self::*">
905 <variable name="start-node" select="text()[contains(., '⌦')][1]"/>
906 <variable name="after-start">
907 <if test="$start-node">
908 <value-of select="substring-after($start-node, '⌦')"/>
909 </if>
910 </variable>
911 <variable name="has-end-node" select="contains($after-start, '⌫') or $start-node/following-sibling::text()[contains(., '⌫')]"/>
912 <choose>
913 <when test="$start-node and $has-end-node">
914 <variable name="following">
915 <value-of select="$after-start"/>
916 <copy-of select="$start-node/following-sibling::node()"/>
917 </variable>
918 <variable name="end-node" select="exsl:node-set($following)/text()[contains(., '⌫')][last()]"/>
919 <variable name="comment">
920 <for-each select="$end-node/preceding-sibling::node()">
921 <value-of select="."/>
922 </for-each>
923 <value-of select="substring-before($end-node, '⌫')"/>
924 </variable>
925 <variable name="rest-fragment">
926 <element name="span" namespace="&xhtml;">
927 <value-of select="substring-after($end-node, '⌫')"/>
928 <copy-of select="$end-node/following-sibling::node()"/>
929 </element>
930 </variable>
931 <variable name="commented-rest-fragment">
932 <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:comment"/>
933 </variable>
934 <copy>
935 <copy-of select="@*"/>
936 <copy-of select="$start-node/preceding-sibling::node()"/>
937 <copy-of select="substring-before($start-node, '⌦')"/>
938 <call-template name="LesML:comment-out">
939 <with-param name="source" select="string($comment)"/>
940 </call-template>
941 <copy-of select="exsl:node-set($commented-rest-fragment)/*/node()"/>
942 </copy>
943 </when>
944 <otherwise>
945 <copy>
946 <copy-of select="@*"/>
947 <apply-templates select="node()" mode="LesML:comment"/>
948 </copy>
949 </otherwise>
950 </choose>
951 </when>
952 <when test="self::text()[contains(., '⌧')]">
953 <variable name="split-fragment">
954 <call-template name="LesML:split">
955 <with-param name="source" select="string()"/>
956 <with-param name="separator" select="'⌧'"/>
957 </call-template>
958 </variable>
959 <for-each select="exsl:node-set($split-fragment)/node()">
960 <value-of select="."/>
961 <if test="position()!=last()">
962 <call-template name="LesML:comment-out"/>
963 </if>
964 </for-each>
965 </when>
966 <otherwise>
967 <copy-of select="."/>
968 </otherwise>
969 </choose>
970 </variable>
971 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:attrify"/>
972 </template>
973 <template match="node()" mode="LesML:inline">
974 <param name="element-name"/>
975 <param name="element-namespace" select="'http://www.w3.org/1999/xhtml'"/>
976 <param name="start-sigil"/>
977 <param name="end-sigil"/>
978 <param name="class"/>
979 <param name="role"/>
980 <choose>
981 <when test="self::*">
982 <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
983 <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))"/>
984 <choose>
985 <when test="$end-node and $has-start-node">
986 <variable name="preceding">
987 <copy-of select="$end-node/preceding-sibling::node()"/>
988 <value-of select="substring-before($end-node, $end-sigil)"/>
989 </variable>
990 <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., $start-sigil)][last()]"/>
991 <variable name="start-tokens-fragment">
992 <call-template name="LesML:split">
993 <with-param name="source" select="string($start-node)"/>
994 <with-param name="separator" select="$start-sigil"/>
995 </call-template>
996 </variable>
997 <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
998 <variable name="wrapped">
999 <copy>
1000 <copy-of select="@*"/>
1001 <copy-of select="$start-node/preceding-sibling::node()"/>
1002 <for-each select="$start-tokens[position()!=last()]">
1003 <value-of select="."/>
1004 <if test="position()!=last()">
1005 <value-of select="$start-sigil"/>
1006 </if>
1007 </for-each>
1008 <element name="{$element-name}" namespace="{$element-namespace}">
1009 <if test="string($role)!=''">
1010 <attribute name="role">
1011 <value-of select="$role"/>
1012 </attribute>
1013 </if>
1014 <if test="string($class)!=''">
1015 <attribute name="class">
1016 <value-of select="$class"/>
1017 </attribute>
1018 </if>
1019 <value-of select="$start-tokens[last()]"/>
1020 <copy-of select="$start-node/following-sibling::node()"/>
1021 </element>
1022 <value-of select="substring-after($end-node, $end-sigil)"/>
1023 <copy-of select="$end-node/following-sibling::node()"/>
1024 </copy>
1025 </variable>
1026 <apply-templates select="exsl:node-set($wrapped)/*" mode="LesML:inline">
1027 <with-param name="element-name" select="$element-name"/>
1028 <with-param name="element-namespace" select="$element-namespace"/>
1029 <with-param name="start-sigil" select="$start-sigil"/>
1030 <with-param name="end-sigil" select="$end-sigil"/>
1031 <with-param name="role" select="$role"/>
1032 </apply-templates>
1033 </when>
1034 <otherwise>
1035 <copy>
1036 <copy-of select="@*"/>
1037 <apply-templates select="node()" mode="LesML:inline">
1038 <with-param name="element-name" select="$element-name"/>
1039 <with-param name="element-namespace" select="$element-namespace"/>
1040 <with-param name="start-sigil" select="$start-sigil"/>
1041 <with-param name="end-sigil" select="$end-sigil"/>
1042 <with-param name="role" select="$role"/>
1043 </apply-templates>
1044 </copy>
1045 </otherwise>
1046 </choose>
1047 </when>
1048 <otherwise>
1049 <copy-of select="."/>
1050 </otherwise>
1051 </choose>
1052 </template>
1053 <template match="*" mode="LesML:partition">
1054 <param name="start-sigil"/>
1055 <param name="end-sigil"/>
1056 <param name="separator"/>
1057 <param name="ncname-keys" select="false()"/>
1058 <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
1059 <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))"/>
1060 <choose>
1061 <when test="$end-node and $has-start-node">
1062 <variable name="preceding-fragment">
1063 <copy-of select="$end-node/preceding-sibling::node()"/>
1064 <value-of select="substring-before($end-node, $end-sigil)"/>
1065 </variable>
1066 <variable name="preceding" select="exsl:node-set($preceding-fragment)/node()"/>
1067 <variable name="start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()][not($ncname-keys) or not(following-sibling::* or following-sibling::comment())]"/>
1068 <variable name="start-tokens-fragment">
1069 <if test="$start-node">
1070 <call-template name="LesML:split">
1071 <with-param name="source" select="string($start-node)"/>
1072 <with-param name="separator" select="$start-sigil"/>
1073 </call-template>
1074 </if>
1075 </variable>
1076 <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
1077 <variable name="innards-fragment">
1078 <value-of select="$start-tokens[last()]"/>
1079 <copy-of select="$start-node/following-sibling::node()"/>
1080 </variable>
1081 <variable name="innards" select="exsl:node-set($innards-fragment)/node()"/>
1082 <variable name="separator-node" select="($innards[self::text() and contains(., $separator)])[not($ncname-keys)*(last()-1)+1]"/>
1083 <choose>
1084 <when test="not($start-node) or $separator-node[following-sibling::* or following-sibling::comment()]">
1085 <variable name="bad-start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()]"/>
1086 <variable name="bad-start-tokens-fragment">
1087 <call-template name="LesML:split">
1088 <with-param name="source" select="string($bad-start-node)"/>
1089 <with-param name="separator" select="$start-sigil"/>
1090 </call-template>
1091 </variable>
1092 <element name="span" namespace="&xhtml;">
1093 <copy-of select="$bad-start-node/preceding-sibling::node()"/>
1094 <for-each select="exsl:node-set($bad-start-tokens-fragment)/*">
1095 <value-of select="."/>
1096 <if test="position()!=last()">
1097 <processing-instruction name="LesML-Token-Escape">
1098 <value-of select="$start-sigil"/>
1099 </processing-instruction>
1100 </if>
1101 </for-each>
1102 <copy-of select="$bad-start-node/following-sibling::node()"/>
1103 <value-of select="$end-sigil"/>
1104 <value-of select="substring-after($end-node, $end-sigil)"/>
1105 <copy-of select="$end-node/following-sibling::node()"/>
1106 </element>
1107 </when>
1108 <when test="$separator-node">
1109 <variable name="keyval-fragment">
1110 <call-template name="LesML:split">
1111 <with-param name="source" select="$separator-node"/>
1112 <with-param name="separator" select="$separator"/>
1113 </call-template>
1114 </variable>
1115 <variable name="keyval" select="exsl:node-set($keyval-fragment)/*"/>
1116 <variable name="key-fragment">
1117 <choose>
1118 <when test="$ncname-keys">
1119 <for-each select="$separator-node/preceding-sibling::node()">
1120 <value-of select="."/>
1121 </for-each>
1122 <value-of select="$keyval[1]"/>
1123 </when>
1124 <otherwise>
1125 <copy-of select="$separator-node/preceding-sibling::node()"/>
1126 <for-each select="$keyval[position()!=last()]">
1127 <value-of select="."/>
1128 <if test="position()!=last()">
1129 <value-of select="$separator"/>
1130 </if>
1131 </for-each>
1132 </otherwise>
1133 </choose>
1134 </variable>
1135 <variable name="value">
1136 <choose>
1137 <when test="$ncname-keys">
1138 <for-each select="$keyval[position()!=1]">
1139 <value-of select="."/>
1140 <if test="position()!=last()">
1141 <value-of select="$separator"/>
1142 </if>
1143 </for-each>
1144 </when>
1145 <otherwise>
1146 <value-of select="$keyval[last()]"/>
1147 </otherwise>
1148 </choose>
1149 <for-each select="$separator-node/following-sibling::node()">
1150 <value-of select="."/>
1151 </for-each>
1152 </variable>
1153 <choose>
1154 <when test="not($ncname-keys) or /self::node()[translate(normalize-space($key-fragment), ' /([,*', '')=$key-fragment and exsldyn:evaluate(concat('not(self::html:', $key-fragment, ')'))]">
1155 <element name="span" namespace="&xhtml;">
1156 <copy-of select="$start-node/preceding-sibling::node()"/>
1157 <for-each select="$start-tokens[position()!=last()]">
1158 <value-of select="."/>
1159 <if test="position()!=last()">
1160 <value-of select="$start-sigil"/>
1161 </if>
1162 </for-each>
1163 </element>
1164 <element name="span" namespace="&xhtml;">
1165 <copy-of select="$key-fragment"/>
1166 </element>
1167 <element name="span" namespace="&xhtml;">
1168 <value-of select="$value"/>
1169 </element>
1170 <element name="span" namespace="&xhtml;">
1171 <value-of select="substring-after($end-node, $end-sigil)"/>
1172 <copy-of select="$end-node/following-sibling::node()"/>
1173 </element>
1174 </when>
1175 <otherwise>
1176 <element name="span" namespace="&xhtml;">
1177 <copy-of select="$start-node/preceding-sibling::node()"/>
1178 <for-each select="$start-tokens[position()!=last()]">
1179 <value-of select="."/>
1180 <if test="position()!=last()">
1181 <value-of select="$start-sigil"/>
1182 </if>
1183 </for-each>
1184 <processing-instruction name="LesML-Token-Escape">
1185 <value-of select="$start-sigil"/>
1186 </processing-instruction>
1187 <value-of select="$start-tokens[last()]"/>
1188 <value-of select="$start-node/following-sibling::node()"/>
1189 <value-of select="$end-sigil"/>
1190 <value-of select="substring-after($end-node, $end-sigil)"/>
1191 <copy-of select="$end-node/following-sibling::node()"/>
1192 </element>
1193 </otherwise>
1194 </choose>
1195 </when>
1196 <otherwise>
1197 <element name="span" namespace="&xhtml;">
1198 <copy-of select="$start-node/preceding-sibling::node()"/>
1199 <for-each select="$start-tokens[position()!=last()]">
1200 <value-of select="."/>
1201 <if test="position()!=last()">
1202 <value-of select="$start-sigil"/>
1203 </if>
1204 </for-each>
1205 <processing-instruction name="LesML-Token-Escape">
1206 <value-of select="$start-sigil"/>
1207 </processing-instruction>
1208 <value-of select="$start-tokens[last()]"/>
1209 <copy-of select="$start-node/following-sibling::node()"/>
1210 <value-of select="$end-sigil"/>
1211 <value-of select="substring-after($end-node, $end-sigil)"/>
1212 <copy-of select="$end-node/following-sibling::node()"/>
1213 </element>
1214 </otherwise>
1215 </choose>
1216 </when>
1217 <when test="$end-node">
1218 <element name="span" namespace="&xhtml;">
1219 <copy-of select="$end-node/preceding-sibling::node()"/>
1220 <value-of select="substring-before($end-node, $end-sigil)"/>
1221 <processing-instruction name="LesML-Token-Escape">
1222 <value-of select="$end-sigil"/>
1223 </processing-instruction>
1224 <value-of select="substring-after($end-node, $end-sigil)"/>
1225 <copy-of select="$end-node/following-sibling::node()"/>
1226 </element>
1227 </when>
1228 <otherwise>
1229 <processing-instruction name="LesML-All-Done"/>
1230 </otherwise>
1231 </choose>
1232 </template>
1233 <template match="node()" mode="LesML:attrify">
1234 <variable name="result">
1235 <choose>
1236 <when test="self::*">
1237 <variable name="partitioned-fragment">
1238 <apply-templates mode="LesML:partition" select=".">
1239 <with-param name="start-sigil" select="'{@'"/>
1240 <with-param name="end-sigil" select="'&quot;}'"/>
1241 <with-param name="separator" select="'=&quot;'"/>
1242 <with-param name="ncname-keys" select="true()"/>
1243 </apply-templates>
1244 </variable>
1245 <variable name="partitioned" select="exsl:node-set($partitioned-fragment)/node()"/>
1246 <choose>
1247 <when test="count($partitioned)>1">
1248 <variable name="processed">
1249 <copy>
1250 <copy-of select="@*"/>
1251 <copy-of select="$partitioned[1]/node()"/>
1252 <element name="LesML:attribute" namespace="&LesML;">
1253 <attribute name="{$partitioned[2]}">
1254 <value-of select="$partitioned[3]"/>
1255 </attribute>
1256 </element>
1257 <copy-of select="$partitioned[4]/node()"/>
1258 </copy>
1259 </variable>
1260 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:attrify"/>
1261 </when>
1262 <when test="$partitioned[self::processing-instruction() and local-name()='LesML-All-Done']">
1263 <copy>
1264 <copy-of select="@*"/>
1265 <apply-templates select="node()" mode="LesML:attrify"/>
1266 </copy>
1267 </when>
1268 <otherwise>
1269 <variable name="processed">
1270 <copy>
1271 <copy-of select="@*"/>
1272 <copy-of select="$partitioned/node()"/>
1273 </copy>
1274 </variable>
1275 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:attrify"/>
1276 </otherwise>
1277 </choose>
1278 </when>
1279 <otherwise>
1280 <copy-of select="."/>
1281 </otherwise>
1282 </choose>
1283 </variable>
1284 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:linkify"/>
1285 </template>
1286 <template match="node()" mode="LesML:linkify">
1287 <variable name="result">
1288 <choose>
1289 <when test="processing-instruction()[local-name()='LesML-All-Done']">
1290 <copy>
1291 <copy-of select="@*|node()[not(self::processing-instruction() and local-name()='LesML-All-Done')]"/>
1292 </copy>
1293 </when>
1294 <when test="self::*">
1295 <variable name="partitioned-fragment">
1296 <apply-templates mode="LesML:partition" select=".">
1297 <with-param name="start-sigil" select="'{🔗'"/>
1298 <with-param name="end-sigil" select="'>}'"/>
1299 <with-param name="separator" select="'&lt;'"/>
1300 </apply-templates>
1301 </variable>
1302 <variable name="partitioned" select="exsl:node-set($partitioned-fragment)/node()"/>
1303 <choose>
1304 <when test="count($partitioned)>1">
1305 <variable name="processed">
1306 <copy>
1307 <copy-of select="@*"/>
1308 <copy-of select="$partitioned[1]/node()"/>
1309 <element name="a" namespace="&xhtml;">
1310 <attribute name="href">
1311 <value-of select="$partitioned[3]"/>
1312 </attribute>
1313 <processing-instruction name="LesML-All-Done"/>
1314 <choose>
1315 <when test="not($partitioned[2]/node())">
1316 <value-of select="$partitioned[3]"/>
1317 </when>
1318 <otherwise>
1319 <copy-of select="$partitioned[2]/node()"/>
1320 </otherwise>
1321 </choose>
1322 </element>
1323 <copy-of select="$partitioned[4]/node()"/>
1324 </copy>
1325 </variable>
1326 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:linkify"/>
1327 </when>
1328 <when test="$partitioned[self::processing-instruction() and local-name()='LesML-All-Done']">
1329 <copy>
1330 <copy-of select="@*"/>
1331 <apply-templates select="node()" mode="LesML:linkify"/>
1332 </copy>
1333 </when>
1334 <otherwise>
1335 <variable name="processed">
1336 <copy>
1337 <copy-of select="@*"/>
1338 <copy-of select="$partitioned/node()"/>
1339 </copy>
1340 </variable>
1341 <apply-templates select="exsl:node-set($processed)/node()" mode="LesML:linkify"/>
1342 </otherwise>
1343 </choose>
1344 </when>
1345 <otherwise>
1346 <copy-of select="."/>
1347 </otherwise>
1348 </choose>
1349 </variable>
1350 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:strikethrough"/>
1351 </template>
1352 <template match="node()" mode="LesML:strikethrough">
1353 <variable name="result">
1354 <apply-templates select="." mode="LesML:inline">
1355 <with-param name="element-name" select="'s'"/>
1356 <with-param name="element-namespace" select="'&xhtml;'"/>
1357 <with-param name="start-sigil" select="'⸠'"/>
1358 <with-param name="end-sigil" select="'⸡'"/>
1359 </apply-templates>
1360 </variable>
1361 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:underline"/>
1362 </template>
1363 <template match="node()" mode="LesML:underline">
1364 <variable name="result">
1365 <apply-templates select="." mode="LesML:inline">
1366 <with-param name="element-name" select="'u'"/>
1367 <with-param name="element-namespace" select="'&xhtml;'"/>
1368 <with-param name="start-sigil" select="'⸤'"/>
1369 <with-param name="end-sigil" select="'⸥'"/>
1370 </apply-templates>
1371 </variable>
1372 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:noted"/>
1373 </template>
1374 <template match="node()" mode="LesML:noted">
1375 <variable name="result">
1376 <apply-templates select="." mode="LesML:inline">
1377 <with-param name="element-name" select="'small'"/>
1378 <with-param name="element-namespace" select="'&xhtml;'"/>
1379 <with-param name="start-sigil" select="'⟦'"/>
1380 <with-param name="end-sigil" select="'⟧'"/>
1381 <with-param name="role" select="'note'"/>
1382 </apply-templates>
1383 </variable>
1384 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:parenthetical"/>
1385 </template>
1386 <template match="node()" mode="LesML:parenthetical">
1387 <variable name="result">
1388 <apply-templates select="." mode="LesML:inline">
1389 <with-param name="element-name" select="'small'"/>
1390 <with-param name="element-namespace" select="'&xhtml;'"/>
1391 <with-param name="start-sigil" select="'⸨'"/>
1392 <with-param name="end-sigil" select="'⸩'"/>
1393 </apply-templates>
1394 </variable>
1395 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:code"/>
1396 </template>
1397 <template match="node()" mode="LesML:code">
1398 <variable name="result">
1399 <apply-templates select="." mode="LesML:inline">
1400 <with-param name="element-name" select="'code'"/>
1401 <with-param name="element-namespace" select="'&xhtml;'"/>
1402 <with-param name="start-sigil" select="'`'"/>
1403 <with-param name="end-sigil" select="'´'"/>
1404 </apply-templates>
1405 </variable>
1406 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:titled"/>
1407 </template>
1408 <template match="node()" mode="LesML:titled">
1409 <variable name="result">
1410 <apply-templates select="." mode="LesML:inline">
1411 <with-param name="element-name" select="'cite'"/>
1412 <with-param name="element-namespace" select="'&xhtml;'"/>
1413 <with-param name="start-sigil" select="'⟪'"/>
1414 <with-param name="end-sigil" select="'⟫'"/>
1415 </apply-templates>
1416 </variable>
1417 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:named"/>
1418 </template>
1419 <template match="node()" mode="LesML:named">
1420 <variable name="result">
1421 <apply-templates select="." mode="LesML:inline">
1422 <with-param name="element-name" select="'u'"/>
1423 <with-param name="element-namespace" select="'&xhtml;'"/>
1424 <with-param name="start-sigil" select="'⸶'"/>
1425 <with-param name="end-sigil" select="'⸷'"/>
1426 <with-param name="class" select="'name'"/>
1427 </apply-templates>
1428 </variable>
1429 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:offset"/>
1430 </template>
1431 <template match="node()" mode="LesML:offset">
1432 <variable name="result">
1433 <apply-templates select="." mode="LesML:inline">
1434 <with-param name="element-name" select="'i'"/>
1435 <with-param name="element-namespace" select="'&xhtml;'"/>
1436 <with-param name="start-sigil" select="'⟨'"/>
1437 <with-param name="end-sigil" select="'⟩'"/>
1438 </apply-templates>
1439 </variable>
1440 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:bolded"/>
1441 </template>
1442 <template match="node()" mode="LesML:bolded">
1443 <variable name="result">
1444 <apply-templates select="." mode="LesML:inline">
1445 <with-param name="element-name" select="'b'"/>
1446 <with-param name="element-namespace" select="'&xhtml;'"/>
1447 <with-param name="start-sigil" select="'⦃'"/>
1448 <with-param name="end-sigil" select="'⦄'"/>
1449 </apply-templates>
1450 </variable>
1451 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:important"/>
1452 </template>
1453 <template match="node()" mode="LesML:important">
1454 <variable name="result">
1455 <apply-templates select="." mode="LesML:inline">
1456 <with-param name="element-name" select="'strong'"/>
1457 <with-param name="element-namespace" select="'&xhtml;'"/>
1458 <with-param name="start-sigil" select="'☞'"/>
1459 <with-param name="end-sigil" select="'☜'"/>
1460 </apply-templates>
1461 </variable>
1462 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:emphasized"/>
1463 </template>
1464 <template match="node()" mode="LesML:emphasized">
1465 <apply-templates select="." mode="LesML:inline">
1466 <with-param name="element-name" select="'em'"/>
1467 <with-param name="element-namespace" select="'&xhtml;'"/>
1468 <with-param name="start-sigil" select="'⹐'"/>
1469 <with-param name="end-sigil" select="'⹑'"/>
1470 </apply-templates>
1471 </template>
1472 </transform>
This page took 0.195768 seconds and 5 git commands to generate.