]> Lady’s Gitweb - LesML/blobdiff - xslt/lesml.xslt
Support definition lists (finally!)
[LesML] / xslt / lesml.xslt
index 2100e06d787944131c9850d06fe21643561edaaf8507b564b62b1303739e7a06..61539dda4b77146b7074cf5e04f10cfc247e2be9db5625ab3d703fdf769e11ed 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-@(#)💄📝 Les·M·L xslt/lesml.xslt 2026-03-31T01:29:32Z
+@(#)💄📝 Les·M·L xslt/lesml.xslt 2026-03-31T01:31:16Z
 SPDX-FileCopyrightText: 2024, 2025, 2026 Lady <https://www.ladys.computer/about/#lady>
 SPDX-License-Identifier: MPL-2.0
 -->
@@ -290,6 +290,12 @@ If a block is nested within the wrapping `<div>´ of a paragraph, the
                                                                </attribute>
                                                        </element>
                                                </when>
+                                               <when test="$sigils[1]='℣'">
+                                                       <element name="dt" namespace="&xhtml;"/>
+                                               </when>
+                                               <when test="$sigils[1]='℟'">
+                                                       <element name="dd" namespace="&xhtml;"/>
+                                               </when>
                                                <when test="$sigils[1]='※'">
                                                        <element name="section" namespace="&xhtml;">
                                                                <attribute name="role">
@@ -625,7 +631,7 @@ This also requires processing any paragraph‐type indicators and
                                        </otherwise>
                                </choose>
                        </variable>
-                       <variable name="firstnosigil" select="substring(translate($nobullet, '•№※⯑∫☡⚠🛈💡»∎', ''), 1, 1)"/>
+                       <variable name="firstnosigil" select="substring(translate($nobullet, '•№※⯑∫☡⚠🛈💡»∎℣℟', ''), 1, 1)"/>
                        <variable name="sigilling">
                                <choose>
                                        <when test="$firstnosigil!=''">
@@ -1834,6 +1840,40 @@ These templates finalize the resulting tree.
                        </attribute>
                </if>
        </template>
+       <template match="html:dt|html:dd" mode="LesML:finalize-list">
+               <param name="used-footnotes" select="/.."/>
+               <variable name="current-level" select="number(&level-pi;)"/>
+               <variable name="notinlist" select="following-sibling::node()[not((self::html:dt or self::html:dd) and &level-pi;=$current-level)][1]"/>
+               <variable name="inlist" select=".|exslset:leading(following-sibling::node(), $notinlist)"/>
+               <variable name="lasts-in-pairing" select="$inlist[self::html:dd and not(exslset:intersection(following-sibling::node()[1]/self::html:dd, $inlist))]|$inlist[last()]"/>
+               <element name="dl" namespace="&xhtml;">
+                       <for-each select="$lasts-in-pairing">
+                               <variable name="prev-position" select="position()-1"/>
+                               <variable name="prev-last" select="$lasts-in-pairing[$prev-position]"/>
+                               <element name="div" namespace="&xhtml;">
+                                       <for-each select="exslset:leading(exslset:trailing($inlist, $prev-last), .)|.">
+                                               <if test="position()=1 and self::html:dd">
+                                                       <element name="dt" namespace="&xhtml;"/>
+                                               </if>
+                                               <copy>
+                                                       <apply-templates select="." mode="LesML:finalize-attributes"/>
+                                                       <apply-templates select="node()" mode="LesML:finalize">
+                                                               <with-param name="used-footnotes" select="$used-footnotes"/>
+                                                       </apply-templates>
+                                               </copy>
+                                               <if test="position()=last() and self::html:dt">
+                                                       <element name="dd" namespace="&xhtml;"/>
+                                               </if>
+                                       </for-each>
+                               </element>
+                       </for-each>
+               </element>
+               <if test="$notinlist/self::html:dt or $notinlist/self::html:dd">
+                       <apply-templates select="$notinlist" mode="LesML:finalize-list">
+                               <with-param name="used-footnotes" select="$used-footnotes"/>
+                       </apply-templates>
+               </if>
+       </template>
        <template match="html:li" mode="LesML:finalize-list">
                <param name="used-footnotes" select="/.."/>
                <variable name="current-class" select="string(@class)"/>
@@ -1943,6 +1983,14 @@ These templates finalize the resulting tree.
                        </apply-templates>
                </element>
        </template>
+       <template match="html:dt|html:dd" mode="LesML:finalize">
+               <param name="used-footnotes" select="/.."/>
+               <if test="not(preceding-sibling::node()) or preceding-sibling::node()[position()=1 and not(self::html:dt or self::html:dd)]">
+                       <apply-templates select="." mode="LesML:finalize-list">
+                               <with-param name="used-footnotes" select="$used-footnotes"/>
+                       </apply-templates>
+               </if>
+       </template>
        <template match="html:li" mode="LesML:finalize">
                <param name="used-footnotes" select="/.."/>
                <if test="not(preceding-sibling::node()) or preceding-sibling::node()[position()=1 and not(self::html:li)]">
This page took 0.263772 seconds and 4 git commands to generate.