]> Lady’s Gitweb - LesML/blob - parser.xslt
Switch symbols for subsection and subsubsection
[LesML] / parser.xslt
1 <?xml version="1.0"?>
2 <!--
3 SPDX-FileCopyrightText: 2024 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 Lady [@ Lady’s 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 <transform
15 xmlns="http://www.w3.org/1999/XSL/Transform"
16 xmlns:LesML="urn:fdc:ladys.computer:20240512:LesML"
17 xmlns:exsl="http://exslt.org/common"
18 xmlns:exslstr="http://exslt.org/strings"
19 xmlns:html="http://www.w3.org/1999/xhtml"
20 xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
21 exclude-result-prefixes="LesML"
22 extension-element-prefixes="exsl exslstr"
23 version="1.0"
24 >
25 <书社:id>urn:fdc:ladys.computer:20240512:LesML:parser.xslt</书社:id>
26 <template name="LesML:split">
27 <param name="source"/>
28 <param name="separator" select="'&#xA;'"/>
29 <choose>
30 <when test="contains($source, $separator)">
31 <html:span>
32 <value-of select="substring-before($source, $separator)"/>
33 </html:span>
34 <call-template name="LesML:split">
35 <with-param name="source" select="substring-after($source, $separator)"/>
36 <with-param name="separator" select="$separator"/>
37 </call-template>
38 </when>
39 <otherwise>
40 <html:span>
41 <value-of select="$source"/>
42 </html:span>
43 </otherwise>
44 </choose>
45 </template>
46 <template name="LesML:unescape">
47 <param name="source"/>
48 <choose>
49 <when test="contains($source, '&lt;U+')">
50 <variable name="after" select="substring-after($source, '&lt;U+')"/>
51 <choose>
52 <when test="contains($after, '>')">
53 <variable name="inner" select="substring-before($after, '>')"/>
54 <variable name="components">
55 <call-template name="LesML:split">
56 <with-param name="source" select="$inner"/>
57 <with-param name="separator" select="'.'"/>
58 </call-template>
59 </variable>
60 <variable name="component-nodes" select="exsl:node-set($components)/node()"/>
61 <choose>
62 <when test="$component-nodes[string(.)='' or translate(., '0123456789ABCDEF', '')!='']">
63 <value-of select="substring-before($source, '&lt;U+')"/>
64 <text>&lt;U+</text>
65 <value-of select="$inner"/>
66 <text>></text>
67 <call-template name="LesML:unescape">
68 <with-param name="source" select="substring-after($after, '>')"/>
69 </call-template>
70 </when>
71 <otherwise>
72 <for-each select="$component-nodes">
73 <text disable-output-escaping="yes">&amp;#x</text>
74 <value-of select="."/>
75 <text>;</text>
76 </for-each>
77 <call-template name="LesML:unescape">
78 <with-param name="source" select="substring-after($after, '>')"/>
79 </call-template>
80 </otherwise>
81 </choose>
82 </when>
83 <otherwise>
84 <value-of select="substring-before($source, '&lt;U+')"/>
85 <text>&lt;U+</text>
86 <call-template name="LesML:unescape">
87 <with-param name="source" select="$after"/>
88 </call-template>
89 </otherwise>
90 </choose>
91 </when>
92 <otherwise>
93 <value-of select="$source"/>
94 </otherwise>
95 </choose>
96 </template>
97 <template name="LesML:id-and-contents">
98 <param name="source"/>
99 <choose>
100 <when test="starts-with($source, '¶')">
101 <choose>
102 <when test="contains($source, ' ')">
103 <attribute name="id">
104 <value-of select="substring-before(substring-after($source, '¶'), ' ')"/>
105 </attribute>
106 <value-of select="substring-after($source, ' ')"/>
107 </when>
108 <otherwise>
109 <attribute name="id">
110 <value-of select="substring-after($source, '¶')"/>
111 </attribute>
112 </otherwise>
113 </choose>
114 </when>
115 <otherwise>
116 <value-of select="$source"/>
117 </otherwise>
118 </choose>
119 </template>
120 <template name="LesML:parse">
121 <param name="source"/>
122 <variable name="noshebang">
123 <text>&#xA;</text>
124 <choose>
125 <when test="starts-with($source, '#!')">
126 <value-of select="substring-after($source, '&#xA;')"/>
127 </when>
128 <otherwise>
129 <value-of select="$source"/>
130 </otherwise>
131 </choose>
132 </variable>
133 <variable name="records">
134 <call-template name="LesML:split">
135 <with-param name="source" select="$noshebang"/>
136 <with-param name="separator" select="'&#xA;%%'"/>
137 </call-template>
138 </variable>
139 <variable name="record-nodes" select="exsl:node-set($records)/*"/>
140 <html:article>
141 <if test="count($record-nodes)>1">
142 <html:footer class="head">
143 <for-each select="$record-nodes[not(position()=last() or normalize-space(.)='')]">
144 <variable name="fields" select="exslstr:tokenize(., '&#xA;')"/>
145 <html:dl>
146 <for-each select="$fields">
147 <choose>
148 <when test="starts-with(., ' ') and $fields[generate-id()=generate-id(current()/preceding-sibling::*[1])]"/>
149 <otherwise>
150 <variable name="next" select="following-sibling::*[not(starts-with(., ' '))]"/>
151 <html:div>
152 <html:dt>
153 <value-of select="normalize-space(substring-before(., ':'))"/>
154 </html:dt>
155 <html:dd>
156 <variable name="firstline">
157 <choose>
158 <when test="contains(., ':')">
159 <value-of select="normalize-space(substring-after(., ':'))"/>
160 </when>
161 <otherwise>
162 <value-of select="normalize-space(.)"/>
163 </otherwise>
164 </choose>
165 </variable>
166 <choose>
167 <when test="substring($firstline, string-length($firstline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
168 <value-of select="substring($firstline, 1, string-length($firstline)-1)"/>
169 </when>
170 <otherwise>
171 <value-of select="$firstline"/>
172 </otherwise>
173 </choose>
174 <for-each select="following-sibling::*[starts-with(., ' ') and not(preceding-sibling::*[generate-id()=generate-id($next)])]">
175 <variable name="nextline" select="normalize-space(.)"/>
176 <choose>
177 <when test="substring($nextline, string-length($nextline))='\' and following-sibling::*[position()=1 and starts-with(., ' ')]">
178 <value-of select="substring($nextline, 1, string-length($nextline)-1)"/>
179 </when>
180 <otherwise>
181 <value-of select="$nextline"/>
182 </otherwise>
183 </choose>
184 </for-each>
185 </html:dd>
186 </html:div>
187 </otherwise>
188 </choose>
189 </for-each>
190 </html:dl>
191 </for-each>
192 </html:footer>
193 </if>
194 <html:div class="body">
195 <call-template name="LesML:paragraphize">
196 <with-param name="source" select="string($record-nodes[last()])"/>
197 </call-template>
198 </html:div>
199 </html:article>
200 </template>
201 <template name="LesML:paragraphize">
202 <param name="source"/>
203 <variable name="paragraphs">
204 <call-template name="LesML:split">
205 <with-param name="source" select="$source"/>
206 <with-param name="separator" select="'&#xA;&#xA;'"/>
207 </call-template>
208 </variable>
209 <variable name="blocked">
210 <for-each select="exsl:node-set($paragraphs)/*">
211 <variable name="lines">
212 <call-template name="LesML:split">
213 <with-param name="source" select="string()"/>
214 </call-template>
215 </variable>
216 <variable name="linespans" select="exsl:node-set($lines)/*"/>
217 <variable name="quoted" select="not($linespans[not(starts-with(., ' ') or starts-with(., '&#x9;'))])"/>
218 <variable name="text">
219 <for-each select="$linespans">
220 <if test="normalize-space()!=''">
221 <value-of select="normalize-space()"/>
222 <if test="following-sibling::*[normalize-space()!='']">
223 <text> </text>
224 </if>
225 </if>
226 </for-each>
227 </variable>
228 <if test="string($text)!=''">
229 <variable name="par">
230 <choose>
231 <when test="starts-with($text, '⁌ ')">
232 <html:h1>
233 <call-template name="LesML:id-and-contents">
234 <with-param name="source" select="substring-after($text, '⁌ ')"/>
235 </call-template>
236 </html:h1>
237 </when>
238 <when test="starts-with($text, '§ ')">
239 <html:h2>
240 <call-template name="LesML:id-and-contents">
241 <with-param name="source" select="substring-after($text, '§ ')"/>
242 </call-template>
243 </html:h2>
244 </when>
245 <when test="starts-with($text, '❦ ')">
246 <html:h3>
247 <call-template name="LesML:id-and-contents">
248 <with-param name="source" select="substring-after($text, '❦ ')"/>
249 </call-template>
250 </html:h3>
251 </when>
252 <when test="starts-with($text, '✠ ')">
253 <html:h4>
254 <call-template name="LesML:id-and-contents">
255 <with-param name="source" select="substring-after($text, '✠ ')"/>
256 </call-template>
257 </html:h4>
258 </when>
259 <when test="starts-with($text, '• ')">
260 <html:li class="unordered" data-level="1">
261 <html:p>
262 <call-template name="LesML:id-and-contents">
263 <with-param name="source" select="substring-after($text, '• ')"/>
264 </call-template>
265 </html:p>
266 </html:li>
267 </when>
268 <when test="starts-with($text, '🔢 ')">
269 <html:li class="ordered" data-level="1">
270 <html:p>
271 <call-template name="LesML:id-and-contents">
272 <with-param name="source" select="substring-after($text, '🔢 ')"/>
273 </call-template>
274 </html:p>
275 </html:li>
276 </when>
277 <when test="starts-with($text, '◦ ')">
278 <html:li class="unordered" data-level="2">
279 <html:p>
280 <call-template name="LesML:id-and-contents">
281 <with-param name="source" select="substring-after($text, '◦ ')"/>
282 </call-template>
283 </html:p>
284 </html:li>
285 </when>
286 <when test="starts-with($text, '🔠 ')">
287 <html:li class="ordered" data-level="2">
288 <html:p>
289 <call-template name="LesML:id-and-contents">
290 <with-param name="source" select="substring-after($text, '🔠 ')"/>
291 </call-template>
292 </html:p>
293 </html:li>
294 </when>
295 <when test="starts-with($text, '▪ ')">
296 <html:li class="unordered" data-level="3">
297 <html:p>
298 <call-template name="LesML:id-and-contents">
299 <with-param name="source" select="substring-after($text, '▪ ')"/>
300 </call-template>
301 </html:p>
302 </html:li>
303 </when>
304 <when test="starts-with($text, '🔡 ')">
305 <html:li class="ordered" data-level="3">
306 <html:p>
307 <call-template name="LesML:id-and-contents">
308 <with-param name="source" select="substring-after($text, '🔡 ')"/>
309 </call-template>
310 </html:p>
311 </html:li>
312 </when>
313 <when test="starts-with($text, '⁃ ')">
314 <html:li class="unordered" data-level="4">
315 <html:p>
316 <call-template name="LesML:id-and-contents">
317 <with-param name="source" select="substring-after($text, '⁃ ')"/>
318 </call-template>
319 </html:p>
320 </html:li>
321 </when>
322 <when test="starts-with($text, '🔣 ')">
323 <html:li class="ordered" data-level="4">
324 <html:p>
325 <call-template name="LesML:id-and-contents">
326 <with-param name="source" select="substring-after($text, '🔣 ')"/>
327 </call-template>
328 </html:p>
329 </html:li>
330 </when>
331 <when test="starts-with($text, '🛈 ')">
332 <html:div role="note" class="info">
333 <html:p>
334 <call-template name="LesML:id-and-contents">
335 <with-param name="source" select="substring-after($text, '🛈 ')"/>
336 </call-template>
337 </html:p>
338 </html:div>
339 </when>
340 <when test="starts-with($text, '⯑ ')">
341 <html:div role="note" class="query">
342 <html:p>
343 <call-template name="LesML:id-and-contents">
344 <with-param name="source" select="substring-after($text, '⯑ ')"/>
345 </call-template>
346 </html:p>
347 </html:div>
348 </when>
349 <when test="starts-with($text, '⚠︎ ')">
350 <html:div role="note" class="warn">
351 <html:p>
352 <call-template name="LesML:id-and-contents">
353 <with-param name="source" select="substring-after($text, '⚠︎ ')"/>
354 </call-template>
355 </html:p>
356 </html:div>
357 </when>
358 <when test="starts-with($text, '※ ')">
359 <html:div role="note" class="note">
360 <html:p>
361 <call-template name="LesML:id-and-contents">
362 <with-param name="source" select="substring-after($text, '※ ')"/>
363 </call-template>
364 </html:p>
365 </html:div>
366 </when>
367 <when test="starts-with($text, '☡ ')">
368 <html:div role="note" class="caution">
369 <html:p>
370 <call-template name="LesML:id-and-contents">
371 <with-param name="source" select="substring-after($text, '☡ ')"/>
372 </call-template>
373 </html:p>
374 </html:div>
375 </when>
376 <when test="starts-with($text, '⋯ ')">
377 <html:div class="continuation">
378 <html:p>
379 <call-template name="LesML:id-and-contents">
380 <with-param name="source" select="substring-after($text, '⋯ ')"/>
381 </call-template>
382 </html:p>
383 </html:div>
384 </when>
385 <otherwise>
386 <html:p>
387 <call-template name="LesML:id-and-contents">
388 <with-param name="source" select="$text"/>
389 </call-template>
390 </html:p>
391 </otherwise>
392 </choose>
393 </variable>
394 <choose>
395 <when test="translate(string($text), '#*-=_~⁂─━┄┅┈┉╌╍═╴╶╸╺☙❧ ', '')=''">
396 <html:hr/>
397 </when>
398 <when test="$quoted">
399 <html:blockquote>
400 <copy-of select="$par"/>
401 </html:blockquote>
402 </when>
403 <otherwise>
404 <copy-of select="$par"/>
405 </otherwise>
406 </choose>
407 </if>
408 </for-each>
409 </variable>
410 <variable name="inlined">
411 <apply-templates select="exsl:node-set($blocked)/node()" mode="LesML:linkify"/>
412 </variable>
413 <apply-templates select="exsl:node-set($inlined)/node()" mode="LesML:finalize-tree"/>
414 </template>
415 <template match="html:script[@type='text/lesml']">
416 <variable name="source">
417 <for-each select=".//text()">
418 <value-of select="."/>
419 </for-each>
420 </variable>
421 <call-template name="LesML:parse">
422 <with-param name="source" select="string($source)"/>
423 </call-template>
424 </template>
425 <template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
426 <copy>
427 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
428 </copy>
429 </template>
430 <template match="text()" mode="LesML:finalize-tree">
431 <call-template name="LesML:unescape">
432 <with-param name="source" select="string(.)"/>
433 </call-template>
434 </template>
435 <template match="html:blockquote" mode="LesML:finalize-tree">
436 <if test="not(preceding-sibling::node()) or preceding-sibling::node()[position()=1 and not(self::html:blockquote)]">
437 <variable name="notquote" select="following-sibling::node()[not(self::html:blockquote)][1]"/>
438 <variable name="contents">
439 <copy-of select="node()"/>
440 <for-each select="following-sibling::node()[not($notquote) or following-sibling::node()[generate-id()=generate-id($notquote)]]">
441 <copy-of select="node()"/>
442 </for-each>
443 </variable>
444 <variable name="content-nodes" select="exsl:node-set($contents)/node()"/>
445 <variable name="laststarttext" select="$content-nodes[last()]/self::html:p[not(@class) and not(@role)]/node()[self::text() or self::*][position()=1 and self::text()]"/>
446 <choose>
447 <when test="starts-with($laststarttext, '— ')">
448 <variable name="caption">
449 <copy-of select="$laststarttext/preceding-sibling::node()"/>
450 <value-of select="substring-after($laststarttext, '— ')"/>
451 <copy-of select="$laststarttext/following-sibling::node()"/>
452 </variable>
453 <html:figure>
454 <copy>
455 <apply-templates select="@*|$content-nodes[position()!=last()]" mode="LesML:finalize-tree"/>
456 </copy>
457 <html:figcaption>
458 <for-each select="$content-nodes[last()]">
459 <copy>
460 <apply-templates select="@*|exsl:node-set($caption)/node()" mode="LesML:finalize-tree"/>
461 </copy>
462 </for-each>
463 </html:figcaption>
464 </html:figure>
465 </when>
466 <otherwise>
467 <copy>
468 <apply-templates select="@*|$content-nodes" mode="LesML:finalize-tree"/>
469 </copy>
470 </otherwise>
471 </choose>
472 </if>
473 </template>
474 <template match="html:div" mode="LesML:finalize-tree">
475 <if test="not(@class='continuation') or not(preceding-sibling::node()) or preceding-sibling::node()[position()=1 and not(self::html:div or self::html:li)]">
476 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div and @class='continuation')][1]"/>
477 <copy>
478 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
479 <for-each select="following-sibling::node()[not($notcontinuation) or following-sibling::node()[generate-id()=generate-id($notcontinuation)]]">
480 <apply-templates select="node()" mode="LesML:finalize-tree"/>
481 </for-each>
482 </copy>
483 </if>
484 </template>
485 <template match="html:li" mode="LesML:finalize-tree">
486 <if test="not(preceding-sibling::node()) or preceding-sibling::node()[not(preceding-sibling::* and self::html:div and @class='continuation')][position()=1 and not(self::html:li)]">
487 <apply-templates select="." mode="LesML:finalize-list"/>
488 </if>
489 </template>
490 <template match="html:li" mode="LesML:finalize-list">
491 <param name="parent-level" select="0"/>
492 <variable name="current-class" select="string(@class)"/>
493 <variable name="current-level" select="number(@data-level)"/>
494 <variable name="wrapper">
495 <choose>
496 <when test="@class='ordered'">
497 <text>ol</text>
498 </when>
499 <otherwise>
500 <text>ul</text>
501 </otherwise>
502 </choose>
503 </variable>
504 <variable name="notinlist" select="following-sibling::node()[not(self::html:div and @class='continuation' or self::html:li and (@data-level>$current-level or @data-level=$current-level and @class=$current-class))][1]"/>
505 <element name="html:{$wrapper}" namespace="http://www.w3.org/1999/xhtml">
506 <for-each select=".|following-sibling::html:li[@data-level=$current-level and (not($notinlist) or following-sibling::node()[generate-id()=generate-id($notinlist)])]">
507 <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div and @class='continuation')][1]"/>
508 <copy>
509 <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
510 <for-each select="following-sibling::node()[not($notcontinuation) or following-sibling::node()[generate-id()=generate-id($notcontinuation)]]">
511 <apply-templates select="node()" mode="LesML:finalize-tree"/>
512 </for-each>
513 <if test="$notcontinuation/self::html:li[@data-level>$current-level]">
514 <apply-templates select="$notcontinuation" mode="LesML:finalize-list">
515 <with-param name="parent-level" select="$current-level"/>
516 </apply-templates>
517 </if>
518 </copy>
519 </for-each>
520 </element>
521 <if test="$notinlist/self::html:li[@data-level>$parent-level]">
522 <apply-templates select="$notinlist" mode="LesML:finalize-list">
523 <with-param name="parent-level" select="$parent-level"/>
524 </apply-templates>
525 </if>
526 </template>
527 <template match="node()" mode="LesML:inline">
528 <param name="element-name"/>
529 <param name="element-namespace" select="'http://www.w3.org/1999/xhtml'"/>
530 <param name="start-sigil"/>
531 <param name="end-sigil"/>
532 <param name="role"/>
533 <param name="langtag-supported" select="false()"/>
534 <choose>
535 <when test="self::*">
536 <copy>
537 <copy-of select="@*"/>
538 <variable name="start-node" select="text()[contains(., $start-sigil)][1]"/>
539 <choose>
540 <when test="$start-node">
541 <variable name="remaining">
542 <value-of select="substring-after($start-node, $start-sigil)"/>
543 <copy-of select="$start-node/following-sibling::node()"/>
544 </variable>
545 <variable name="end-node" select="exsl:node-set($remaining)/node()[self::text() and contains(., $end-sigil)][1]"/>
546 <choose>
547 <when test="$end-node">
548 <variable name="restoftext" select="substring-after($end-node, $end-sigil)"/>
549 <variable name="maybe-langtag">
550 <if test="$langtag-supported and starts-with($restoftext, '@') and contains($restoftext, '$')">
551 <value-of select="substring-before(substring-after($restoftext, '@'), '$')"/>
552 </if>
553 </variable>
554 <variable name="langtag">
555 <if test="translate($maybe-langtag, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-', '')=''">
556 <value-of select="$maybe-langtag"/>
557 </if>
558 </variable>
559 <variable name="rest">
560 <html:div>
561 <choose>
562 <when test="string($langtag)!=''">
563 <value-of select="substring-after($restoftext, '$')"/>
564 </when>
565 <otherwise>
566 <value-of select="$restoftext"/>
567 </otherwise>
568 </choose>
569 <copy-of select="$end-node/following-sibling::node()"/>
570 </html:div>
571 </variable>
572 <variable name="processed-rest">
573 <apply-templates select="exsl:node-set($rest)/*" mode="LesML:inline">
574 <with-param name="element-name" select="$element-name"/>
575 <with-param name="element-namespace" select="$element-namespace"/>
576 <with-param name="start-sigil" select="$start-sigil"/>
577 <with-param name="end-sigil" select="$end-sigil"/>
578 <with-param name="role" select="$role"/>
579 <with-param name="langtag-supported" select="$langtag-supported"/>
580 </apply-templates>
581 </variable>
582 <copy-of select="$start-node/preceding-sibling::node()"/>
583 <value-of select="substring-before($start-node, $start-sigil)"/>
584 <element name="{$element-name}" namespace="{$element-namespace}">
585 <if test="string($role)!=''">
586 <attribute name="role">
587 <value-of select="$role"/>
588 </attribute>
589 </if>
590 <if test="string($langtag)!=''">
591 <if test="$element-namespace='http://www.w3.org/1999/xhtml'">
592 <attribute name="lang">
593 <value-of select="$langtag"/>
594 </attribute>
595 </if>
596 <attribute name="xml:lang">
597 <value-of select="$langtag"/>
598 </attribute>
599 </if>
600 <copy-of select="$end-node/preceding-sibling::node()"/>
601 <value-of select="substring-before($end-node, $end-sigil)"/>
602 </element>
603 <copy-of select="exsl:node-set($processed-rest)/*/node()"/>
604 </when>
605 <otherwise>
606 <apply-templates select="node()" mode="LesML:inline">
607 <with-param name="element-name" select="$element-name"/>
608 <with-param name="element-namespace" select="$element-namespace"/>
609 <with-param name="start-sigil" select="$start-sigil"/>
610 <with-param name="end-sigil" select="$end-sigil"/>
611 <with-param name="role" select="$role"/>
612 <with-param name="langtag-supported" select="$langtag-supported"/>
613 </apply-templates>
614 </otherwise>
615 </choose>
616 </when>
617 <otherwise>
618 <apply-templates select="node()" mode="LesML:inline">
619 <with-param name="element-name" select="$element-name"/>
620 <with-param name="element-namespace" select="$element-namespace"/>
621 <with-param name="start-sigil" select="$start-sigil"/>
622 <with-param name="end-sigil" select="$end-sigil"/>
623 <with-param name="role" select="$role"/>
624 <with-param name="langtag-supported" select="$langtag-supported"/>
625 </apply-templates>
626 </otherwise>
627 </choose>
628 </copy>
629 </when>
630 <otherwise>
631 <copy-of select="."/>
632 </otherwise>
633 </choose>
634 </template>
635 <template match="node()" mode="LesML:linkify">
636 <variable name="result">
637 <choose>
638 <when test="self::*">
639 <copy>
640 <copy-of select="@*"/>
641 <variable name="start-node" select="text()[contains(., '{🔗')][1]"/>
642 <choose>
643 <when test="$start-node">
644 <variable name="remaining">
645 <value-of select="substring-after($start-node, '{🔗')"/>
646 <copy-of select="$start-node/following-sibling::node()"/>
647 </variable>
648 <variable name="end-node" select="exsl:node-set($remaining)/node()[self::text() and contains(., '>}') and not(preceding-sibling::*)][1]"/>
649 <variable name="hyperlink">
650 <for-each select="$end-node/preceding-sibling::node()">
651 <value-of select="."/>
652 </for-each>
653 <value-of select="substring-before($end-node, '>}')"/>
654 </variable>
655 <choose>
656 <when test="contains($hyperlink, '&lt;')">
657 <variable name="ltcomponents">
658 <call-template name="LesML:split">
659 <with-param name="source" select="$hyperlink"/>
660 <with-param name="separator" select="'&lt;'"/>
661 </call-template>
662 </variable>
663 <variable name="ltcomponent-nodes" select="exsl:node-set($ltcomponents)/*"/>
664 <variable name="rest">
665 <html:div>
666 <value-of select="substring-after($end-node, '>}')"/>
667 <copy-of select="$end-node/following-sibling::node()"/>
668 </html:div>
669 </variable>
670 <variable name="processed-rest">
671 <apply-templates select="exsl:node-set($rest)/*" mode="LesML:linkify"/>
672 </variable>
673 <copy-of select="$start-node/preceding-sibling::node()"/>
674 <value-of select="substring-before($start-node, '{🔗')"/>
675 <html:a href="{$ltcomponent-nodes[last()]}">
676 <choose>
677 <when test="count($ltcomponent-nodes)>2 or normalize-space($ltcomponent-nodes[1])!=''">
678 <value-of select="$ltcomponent-nodes[1]"/>
679 <for-each select="$ltcomponent-nodes[position()>1 and position()!=last()]">
680 <text>&lt;</text>
681 <value-of select="."/>
682 </for-each>
683 </when>
684 <otherwise>
685 <value-of select="$ltcomponent-nodes[last()]"/>
686 </otherwise>
687 </choose>
688 </html:a>
689 <copy-of select="exsl:node-set($processed-rest)/*/node()"/>
690 </when>
691 <otherwise>
692 <variable name="rest">
693 <html:div>
694 <copy-of select="$remaining"/>
695 </html:div>
696 </variable>
697 <variable name="processed-rest">
698 <apply-templates select="exsl:node-set($rest)/*" mode="LesML:linkify"/>
699 </variable>
700 <copy-of select="$start-node/preceding-sibling::node()"/>
701 <value-of select="substring-before($start-node, '{🔗')"/>
702 <text>{🔗</text>
703 <copy-of select="exsl:node-set($processed-rest)/*/node()"/>
704 </otherwise>
705 </choose>
706 </when>
707 <otherwise>
708 <apply-templates select="node()" mode="LesML:linkify"/>
709 </otherwise>
710 </choose>
711 </copy>
712 </when>
713 <otherwise>
714 <copy-of select="."/>
715 </otherwise>
716 </choose>
717 </variable>
718 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:strikethrough"/>
719 </template>
720 <template match="node()" mode="LesML:strikethrough">
721 <variable name="result">
722 <apply-templates select="." mode="LesML:inline">
723 <with-param name="element-name" select="'html:s'"/>
724 <with-param name="start-sigil" select="'⸠'"/>
725 <with-param name="end-sigil" select="'⸡'"/>
726 </apply-templates>
727 </variable>
728 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:underline"/>
729 </template>
730 <template match="node()" mode="LesML:underline">
731 <variable name="result">
732 <apply-templates select="." mode="LesML:inline">
733 <with-param name="element-name" select="'html:u'"/>
734 <with-param name="start-sigil" select="'⸤'"/>
735 <with-param name="end-sigil" select="'⸥'"/>
736 </apply-templates>
737 </variable>
738 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:noted"/>
739 </template>
740 <template match="node()" mode="LesML:noted">
741 <variable name="result">
742 <apply-templates select="." mode="LesML:inline">
743 <with-param name="element-name" select="'html:small'"/>
744 <with-param name="start-sigil" select="'⟦'"/>
745 <with-param name="end-sigil" select="'⟧'"/>
746 <with-param name="role" select="'note'"/>
747 </apply-templates>
748 </variable>
749 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:parenthetical"/>
750 </template>
751 <template match="node()" mode="LesML:parenthetical">
752 <variable name="result">
753 <apply-templates select="." mode="LesML:inline">
754 <with-param name="element-name" select="'html:small'"/>
755 <with-param name="start-sigil" select="'⸨'"/>
756 <with-param name="end-sigil" select="'⸩'"/>
757 </apply-templates>
758 </variable>
759 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:important"/>
760 </template>
761 <template match="node()" mode="LesML:important">
762 <variable name="result">
763 <apply-templates select="." mode="LesML:inline">
764 <with-param name="element-name" select="'html:strong'"/>
765 <with-param name="start-sigil" select="'☞'"/>
766 <with-param name="end-sigil" select="'☜'"/>
767 </apply-templates>
768 </variable>
769 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:emphasized"/>
770 </template>
771 <template match="node()" mode="LesML:emphasized">
772 <variable name="result">
773 <apply-templates select="." mode="LesML:inline">
774 <with-param name="element-name" select="'html:em'"/>
775 <with-param name="start-sigil" select="'⹐'"/>
776 <with-param name="end-sigil" select="'⹑'"/>
777 </apply-templates>
778 </variable>
779 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:titled"/>
780 </template>
781 <template match="node()" mode="LesML:titled">
782 <variable name="result">
783 <apply-templates select="." mode="LesML:inline">
784 <with-param name="element-name" select="'html:cite'"/>
785 <with-param name="start-sigil" select="'⟪'"/>
786 <with-param name="end-sigil" select="'⟫'"/>
787 </apply-templates>
788 </variable>
789 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:offset"/>
790 </template>
791 <template match="node()" mode="LesML:offset">
792 <variable name="result">
793 <apply-templates select="." mode="LesML:inline">
794 <with-param name="element-name" select="'html:i'"/>
795 <with-param name="start-sigil" select="'⟨'"/>
796 <with-param name="end-sigil" select="'⟩'"/>
797 <with-param name="langtag-supported" select="true()"/>
798 </apply-templates>
799 </variable>
800 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:bolded"/>
801 </template>
802 <template match="node()" mode="LesML:bolded">
803 <variable name="result">
804 <apply-templates select="." mode="LesML:inline">
805 <with-param name="element-name" select="'html:b'"/>
806 <with-param name="start-sigil" select="'⦃'"/>
807 <with-param name="end-sigil" select="'⦄'"/>
808 </apply-templates>
809 </variable>
810 <apply-templates select="exsl:node-set($result)/node()" mode="LesML:code"/>
811 </template>
812 <template match="node()" mode="LesML:code">
813 <apply-templates select="." mode="LesML:inline">
814 <with-param name="element-name" select="'html:code'"/>
815 <with-param name="start-sigil" select="'`'"/>
816 <with-param name="end-sigil" select="'´'"/>
817 </apply-templates>
818 </template>
819 </transform>
This page took 0.219311 seconds and 5 git commands to generate.