-->
<!DOCTYPE transform [
<!ENTITY LesML "urn:fdc:ladys.computer:20240512:LesML">
- <!ENTITY section-break "">
+ <!ENTITY pilcrow-atts "(local-name()='id' or local-name()='lang') and namespace-uri()='' or local-name()='lang' and namespace-uri()='http://www.w3.org/XML/1998/namespace'">
<!ENTITY sigiled-text "(string-length($text)=1 or substring($text, 2, 1)=' ' or substring($text, 2, 1)='¶')">
<!ENTITY unsigiled-text "concat(translate(substring($text, 2, 1), ' ', ''), substring($text, 3, string-length($text)-2))">
<!ENTITY xhtml "http://www.w3.org/1999/xhtml">
<attribute name="class">
<text>body</text>
</attribute>
- <apply-templates select="$paragraphized/node()" mode="LesML:finalize-footnotes">
+ <apply-templates select="$paragraphized/node()" mode="LesML:finalize">
<with-param name="used-footnotes" select="$used-footnote-nodes"/>
</apply-templates>
</element>
<text>doc-endnotes</text>
</attribute>
<element name="ol" namespace="&xhtml;">
- <apply-templates select="$used-footnote-nodes" mode="LesML:finalize-footnotes">
+ <apply-templates select="$used-footnote-nodes" mode="LesML:finalize">
<with-param name="used-footnotes" select="$used-footnote-nodes"/>
</apply-templates>
</element>
</element>
</element>
</when>
- <when test="starts-with($text, '🛈') and &sigiled-text;">
- <element name="div" namespace="&xhtml;">
+ <when test="starts-with($text, '※') and &sigiled-text;">
+ <element name="section" namespace="&xhtml;">
<attribute name="role">
<text>note</text>
</attribute>
<attribute name="class">
- <text>info</text>
+ <text>note</text>
</attribute>
<element name="p" namespace="&xhtml;">
<call-template name="LesML:id-and-contents">
</element>
</element>
</when>
- <when test="starts-with($text, '⯑') and &sigiled-text;">
- <element name="div" namespace="&xhtml;">
+ <when test="starts-with($text, '☡') and &sigiled-text;">
+ <element name="section" namespace="&xhtml;">
<attribute name="role">
<text>note</text>
</attribute>
<attribute name="class">
- <text>query</text>
+ <text>caution</text>
</attribute>
<element name="p" namespace="&xhtml;">
<call-template name="LesML:id-and-contents">
</element>
</element>
</when>
- <when test="starts-with($text, '⚠') and &sigiled-text;">
- <element name="div" namespace="&xhtml;">
+ <when test="starts-with($text, '⯑') and &sigiled-text;">
+ <element name="section" namespace="&xhtml;">
<attribute name="role">
<text>note</text>
</attribute>
<attribute name="class">
- <text>warn</text>
+ <text>query</text>
</attribute>
<element name="p" namespace="&xhtml;">
<call-template name="LesML:id-and-contents">
</element>
</element>
</when>
- <when test="starts-with($text, '※') and &sigiled-text;">
- <element name="div" namespace="&xhtml;">
+ <when test="starts-with($text, '@') and &sigiled-text;">
+ <element name="section" namespace="&xhtml;">
<attribute name="role">
- <text>note</text>
- </attribute>
- <attribute name="class">
- <text>note</text>
+ <text>doc-abstract</text>
</attribute>
<element name="p" namespace="&xhtml;">
<call-template name="LesML:id-and-contents">
</element>
</element>
</when>
- <when test="starts-with($text, '☡') and &sigiled-text;">
- <element name="div" namespace="&xhtml;">
+ <when test="starts-with($text, '🛈') and &sigiled-text;">
+ <element name="section" namespace="&xhtml;">
<attribute name="role">
- <text>note</text>
+ <text>doc-tip</text>
</attribute>
- <attribute name="class">
- <text>caution</text>
+ <element name="p" namespace="&xhtml;">
+ <call-template name="LesML:id-and-contents">
+ <with-param name="source" select="&unsigiled-text;"/>
+ </call-template>
+ </element>
+ </element>
+ </when>
+ <when test="starts-with($text, '⚠') and &sigiled-text;">
+ <element name="section" namespace="&xhtml;">
+ <attribute name="role">
+ <text>doc-notice</text>
</attribute>
<element name="p" namespace="&xhtml;">
<call-template name="LesML:id-and-contents">
</call-template>
</element>
</template>
- <template match="node()" mode="LesML:finalize-attributes">
- <variable name="notattr" select="following-sibling::node()[not(self::text() and translate(., ' 	', '')='' or self::LesML:attribute)]"/>
- <for-each select="(.|exslset:leading(following-sibling::node(), $notattr)[self::LesML:attribute])/@*">
- <copy-of select="."/>
- <if test="local-name()='lang' and namespace-uri()=''">
- <attribute name="xml:lang">
- <value-of select="."/>
- </attribute>
- </if>
- </for-each>
- </template>
- <template match="html:a[@role='doc-noteref']" mode="LesML:finalize-footnotes">
+ <template match="html:ol[processing-instruction()[local-name()='LesML-Footnote']]|processing-instruction()[local-name()='LesML-Footnote']" mode="LesML:finalize" priority="1"/>
+ <template match="html:a[@role='doc-noteref']" mode="LesML:finalize">
<param name="used-footnotes" select="/.."/>
<variable name="matching-note" select="$used-footnotes[concat('#', @id)=current()/@href]"/>
<copy>
- <apply-templates select="@*" mode="LesML:finalize-footnotes">
+ <apply-templates select="@*" mode="LesML:finalize">
<with-param name="used-footnotes" select="$used-footnotes"/>
</apply-templates>
<choose>
<value-of select="$matching-note/@value"/>
</when>
<otherwise>
- <apply-templates select="node()" mode="LesML:finalize-footnotes">
+ <apply-templates select="node()" mode="LesML:finalize">
<with-param name="used-footnotes" select="$used-footnotes"/>
</apply-templates>
</otherwise>
</choose>
</copy>
</template>
- <template match="html:p[preceding-sibling::*[1]=processing-instruction()[local-name()='LesML-Footnote']]" mode="LesML:finalize-footnotes">
- <variable name="content" select="@*[not(local-name()='@id' and namespace-uri()='')]|node()"/>
+ <template match="html:p[position()=1 and ancestor::*]" mode="LesML:finalize">
+ <param name="used-footnotes" select="/.."/>
+ <variable name="content" select="@*[not(&pilcrow-atts;)]|node()"/>
<if test="$content">
<copy>
- <apply-templates select="$content" mode="LesML:finalize-footnotes"/>
+ <apply-templates select="$content" mode="LesML:finalize">
+ <with-param name="used-footnotes" select="$used-footnotes"/>
+ </apply-templates>
</copy>
</if>
</template>
- <template match="html:ol[processing-instruction()[local-name()='LesML-Footnote']]|processing-instruction()[local-name()='LesML-Footnote']" mode="LesML:finalize-footnotes"/>
- <template match="@*|node()" mode="LesML:finalize-footnotes" priority="-1">
+ <template match="html:section" mode="LesML:finalize">
<param name="used-footnotes" select="/.."/>
+ <variable name="notinsection" select="following-sibling::node()[not(html:li/@aria-level>1)][1]"/>
<copy>
- <apply-templates select="@*|node()" mode="LesML:finalize-footnotes">
+ <apply-templates select="@*|html:p[1]/@*[&pilcrow-atts;]" mode="LesML:finalize"/>
+ <apply-templates select="node()" mode="LesML:finalize"/>
+ <for-each select="exslset:leading(following-sibling::node(), $notinsection)">
+ <copy>
+ <apply-templates select="@*|node()" mode="LesML:finalize">
+ <with-param name="used-footnotes" select="$used-footnotes"/>
+ </apply-templates>
+ </copy>
+ </for-each>
+ </copy>
+ </template>
+ <template match="html:*[html:li/@aria-level>1]" mode="LesML:finalize">
+ <param name="used-footnotes" select="/.."/>
+ <if test="not(preceding-sibling::node()[not(html:li/@aria-level>1)][1]/self::html:section)">
+ <copy>
+ <apply-templates select="@*|node()" mode="LesML:finalize">
+ <with-param name="used-footnotes" select="$used-footnotes"/>
+ </apply-templates>
+ </copy>
+ </if>
+ </template>
+ <template match="text()" mode="LesML:finalize">
+ <call-template name="LesML:break-and-unescape">
+ <with-param name="source" select="string()"/>
+ </call-template>
+ </template>
+ <template match="@*|node()" mode="LesML:finalize" priority="-1">
+ <param name="used-footnotes" select="/.."/>
+ <copy>
+ <apply-templates select="@*|html:p[1]/@*[&pilcrow-atts;]" mode="LesML:finalize"/>
+ <apply-templates select="node()" mode="LesML:finalize">
<with-param name="used-footnotes" select="$used-footnotes"/>
</apply-templates>
</copy>
</template>
+ <template match="node()" mode="LesML:finalize-attributes">
+ <variable name="notattr" select="following-sibling::node()[not(self::text() and translate(., ' 	', '')='' or self::LesML:attribute)]"/>
+ <for-each select="(.|exslset:leading(following-sibling::node(), $notattr)[self::LesML:attribute])/@*">
+ <copy-of select="."/>
+ <if test="local-name()='lang' and namespace-uri()=''">
+ <attribute name="xml:lang">
+ <value-of select="."/>
+ </attribute>
+ </if>
+ </for-each>
+ </template>
<template match="html:li" mode="LesML:finalize-list">
<param name="parent-level" select="0"/>
<variable name="current-class" select="string(@class)"/>
<element name="span" namespace="&xhtml;">
<apply-templates select="." mode="LesML:finalize-attributes"/>
<if test="self::text()">
- <call-template name="LesML:break-and-unescape">
- <with-param name="source" select="string(.)"/>
- </call-template>
+ <copy/>
</if>
</element>
</template>
<template match="html:div" mode="LesML:finalize-tree">
- <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())])">
+ <if test="not(processing-instruction()[local-name()='LesML-Continuation']) or not(preceding-sibling::node()[position()=1 and self::html:* and contains(' div h1 h2 h3 h4 h5 h6 li section ', local-name())])">
<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())]">
<apply-templates select="." mode="LesML:finalize-list"/>
</if>
</template>
+ <template match="html:section" mode="LesML:finalize-tree">
+ <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)">
+ <apply-templates select="node()" mode="LesML:finalize-tree"/>
+ </for-each>
+ </copy>
+ </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="text()" mode="LesML:finalize-tree">
- <call-template name="LesML:break-and-unescape">
- <with-param name="source" select="string(.)"/>
- </call-template>
- </template>
<template match="@*|node()" mode="LesML:finalize-tree" priority="-1">
<copy>
<apply-templates select="." mode="LesML:finalize-attributes"/>