]> Lady’s Gitweb - LesML/commitdiff
Support hgroups with heading continuations 0.5.0
authorLady <redacted>
Mon, 28 Apr 2025 01:55:06 +0000 (21:55 -0400)
committerLady <redacted>
Tue, 31 Mar 2026 02:07:33 +0000 (22:07 -0400)
These are a bit interesting because continuation paragraphs can be
  placed ⹐before⹑ the heading they “continue” (not just after).
A block comment can be used to separate them from a preceding list or
  similar.

README.markdown
parser.xslt

index 32a54ec4617a260bb017e61bf7bb512491361881218bc6f92d933935d41a0378..ff264502726fae8e5a174dfed22a6531ab1fe4d2cb85152103ae565f882008d2 100644 (file)
@@ -173,10 +173,12 @@ After this classification, each ordinary paragraph is further
   Comments produce X·M·L comment nodes and can be used to break up list
     items into separate lists.
 
   Comments produce X·M·L comment nodes and can be used to break up list
     items into separate lists.
 
-- If the paragraph begins with `⋯`, it is a continuation paragraph
-    (`<html:div class="continuation">`).
+- If the paragraph begins with `⋯`, it is a continuation paragraph.
   Continuation paragraphs may be used to continue a preceding div or
     list item.
   Continuation paragraphs may be used to continue a preceding div or
     list item.
+  If there is no such preceding div or list item, they will attach to
+    adjacent heading elements to form heading groups (`<html:hgroup>`).
+  Otherwise, they will be treated as ordinary paragraphs.
 
 - Otherwise, it is an ordinary paragraph.
 
 
 - Otherwise, it is an ordinary paragraph.
 
index 5e2b54f4a7622bacf3868b5adb5929361977f5c4ba7acf8a0f75866e01aa2264..734b3c03fdc1726a0cf0bb8618f3f1eda4e29eef314bcb91c8bde5dd7b10ef52 100644 (file)
@@ -705,9 +705,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                </when>
                                                <when test="starts-with($text, '⋯') and &sigiled-text;">
                                                        <element name="div" namespace="&xhtml;">
                                                </when>
                                                <when test="starts-with($text, '⋯') and &sigiled-text;">
                                                        <element name="div" namespace="&xhtml;">
-                                                               <attribute name="class">
-                                                                       <text>continuation</text>
-                                                               </attribute>
+                                                               <processing-instruction name="LesML-Continuation"/>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
@@ -783,18 +781,60 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                </element>
        </template>
        <template match="html:div" mode="LesML:finalize-tree">
                </element>
        </template>
        <template match="html:div" mode="LesML:finalize-tree">
-               <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)]">
-                       <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div and @class='continuation')][1]"/>
-                       <copy>
-                               <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
-                               <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
+               <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())])">
+                       <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
+                       <choose>
+                               <when test="processing-instruction()[local-name()='LesML-Continuation'] and $notcontinuation[self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
+                                       <variable name="notcontinuation2" select="$notcontinuation/following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
+                                       <element name="hgroup" namespace="&xhtml;">
+                                               <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                               <for-each select="exslset:leading(following-sibling::node(), $notcontinuation2)">
+                                                       <choose>
+                                                               <when test="self::html:div">
+                                                                       <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                                               </when>
+                                                               <otherwise>
+                                                                       <copy>
+                                                                               <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+                                                                       </copy>
+                                                               </otherwise>
+                                                       </choose>
+                                               </for-each>
+                                       </element>
+                               </when>
+                               <otherwise>
                                        <apply-templates select="node()" mode="LesML:finalize-tree"/>
                                        <apply-templates select="node()" mode="LesML:finalize-tree"/>
-                               </for-each>
-                       </copy>
+                                       <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
+                                               <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                       </for-each>
+                               </otherwise>
+                       </choose>
+               </if>
+       </template>
+       <template match="html:h1|html:h2|html:h3|html:h4|html:h5|html:h6" mode="LesML:finalize-tree">
+               <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())]">
+                       <choose>
+                               <when test="following-sibling::node()[position()=1 and self::html:div]/processing-instruction()[local-name()='LesML-Continuation']">
+                                       <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
+                                       <element name="hgroup" namespace="&xhtml;">
+                                               <copy>
+                                                       <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+                                               </copy>
+                                               <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
+                                                       <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                               </for-each>
+                                       </element>
+                               </when>
+                               <otherwise>
+                                       <copy>
+                                               <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+                                       </copy>
+                               </otherwise>
+                       </choose>
                </if>
        </template>
        <template match="html:li" mode="LesML:finalize-tree">
                </if>
        </template>
        <template match="html:li" mode="LesML:finalize-tree">
-               <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)]">
+               <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)]">
                        <apply-templates select="." mode="LesML:finalize-list"/>
                </if>
        </template>
                        <apply-templates select="." mode="LesML:finalize-list"/>
                </if>
        </template>
@@ -812,10 +852,10 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                </otherwise>
                        </choose>
                </variable>
                                </otherwise>
                        </choose>
                </variable>
-               <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]"/>
+               <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]"/>
                <element name="{$wrapper}" namespace="&xhtml;">
                        <for-each select=".|exslset:leading(following-sibling::node(), $notinlist)[self::html:li and @data-level=$current-level]">
                <element name="{$wrapper}" namespace="&xhtml;">
                        <for-each select=".|exslset:leading(following-sibling::node(), $notinlist)[self::html:li and @data-level=$current-level]">
-                               <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div and @class='continuation')][1]"/>
+                               <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
                                <copy>
                                        <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
                                        <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
                                <copy>
                                        <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
                                        <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
@@ -835,6 +875,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        </apply-templates>
                </if>
        </template>
                        </apply-templates>
                </if>
        </template>
+       <template match="processing-instruction()[local-name()='LesML-Continuation']" mode="LesML:finalize-tree"/>
        <template match="processing-instruction()[local-name()='LesML-Token-Escape']" mode="LesML:finalize-tree">
                <value-of select="."/>
        </template>
        <template match="processing-instruction()[local-name()='LesML-Token-Escape']" mode="LesML:finalize-tree">
                <value-of select="."/>
        </template>
This page took 0.180744 seconds and 4 git commands to generate.