<!DOCTYPE transform [
<!ENTITY LesML "urn:fdc:ladys.computer:20240512:LesML">
<!ENTITY section-break "*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~">
- <!ENTITY sigiled-text "(string-length($text)=1 or substring($text, 2, 1)=' ')">
- <!ENTITY unsigiled-text "substring($text, 3, string-length($text)-2)">
+ <!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">
]>
<transform
</otherwise>
</choose>
</template>
+ <template name="LesML:comment-out">
+ <param name="source"/>
+ <variable name="comment-split-fragment">
+ <call-template name="LesML:split">
+ <with-param name="source" select="$source"/>
+ <with-param name="separator" select="'--'"/>
+ </call-template>
+ </variable>
+ <comment>
+ <for-each select="exsl:node-set($comment-split-fragment)/*">
+ <if test="string()='' or starts-with(., '‐')">
+ <text>͏</text>
+ </if>
+ <value-of select="."/>
+ <if test="substring(., string-length(.), 1)='‐'">
+ <text>͏</text>
+ </if>
+ <choose>
+ <when test="position()!=last()">
+ <text>-͏-</text>
+ </when>
+ </choose>
+ </for-each>
+ </comment>
+ </template>
<template name="LesML:id-and-contents">
<param name="source"/>
- <choose>
- <when test="starts-with($source, '¶')">
+ <variable name="id-and-lang">
+ <if test="starts-with($source, '¶')">
<choose>
<when test="contains($source, ' ')">
- <variable name="id" select="substring-before(substring-after($source, '¶'), ' ')"/>
- <if test="$id!=''">
- <attribute name="id">
- <value-of select="$id"/>
- </attribute>
- </if>
- <value-of select="substring-after($source, ' ')"/>
+ <value-of select="substring-before(substring-after($source, '¶'), ' ')"/>
</when>
<otherwise>
- <attribute name="id">
- <value-of select="substring-after($source, '¶')"/>
- </attribute>
+ <value-of select="substring-after($source, '¶')"/>
</otherwise>
</choose>
- </when>
- <otherwise>
- <value-of select="$source"/>
- </otherwise>
- </choose>
+ </if>
+ </variable>
+ <variable name="restoftext">
+ <choose>
+ <when test="starts-with($source, '¶') and contains($source, ' ')">
+ <value-of select="substring-after($source, ' ')"/>
+ </when>
+ <when test="starts-with($source, '¶')"/>
+ <otherwise>
+ <value-of select="$source"/>
+ </otherwise>
+ </choose>
+ </variable>
+ <variable name="maybe-langtag">
+ <if test="substring($id-and-lang, string-length($id-and-lang), 1)='$' and contains($id-and-lang, '@')">
+ <variable name="split-tag-fragment">
+ <call-template name="LesML:split">
+ <with-param name="source" select="substring($id-and-lang, 2, string-length($id-and-lang)-2)"/>
+ <with-param name="separator" select="'@'"/>
+ </call-template>
+ </variable>
+ <value-of select="exsl:node-set($split-tag-fragment)/*[last()]"/>
+ </if>
+ </variable>
+ <variable name="langtag">
+ <if test="translate($maybe-langtag, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-', '')=''">
+ <value-of select="$maybe-langtag"/>
+ </if>
+ </variable>
+ <variable name="id">
+ <choose>
+ <when test="string($langtag)!=''">
+ <value-of select="substring($id-and-lang, 1, string-length($id-and-lang)-(string-length($langtag)+2))"/>
+ </when>
+ <otherwise>
+ <value-of select="$id-and-lang"/>
+ </otherwise>
+ </choose>
+ </variable>
+ <if test="string($id)!=''">
+ <attribute name="id">
+ <value-of select="$id"/>
+ </attribute>
+ </if>
+ <if test="string($langtag)!=''">
+ <attribute name="lang">
+ <value-of select="$langtag"/>
+ </attribute>
+ <attribute name="xml:lang">
+ <value-of select="$langtag"/>
+ </attribute>
+ </if>
+ <value-of select="$restoftext"/>
</template>
<template name="LesML:parse">
<param name="lines" select="/.."/>
<variable name="docsep" select="$noshebang[starts-with(., '#!lesml') or starts-with(., '##')][1]"/>
<variable name="doclines" select="exslset:leading($noshebang, $docsep)"/>
<if test="starts-with($first-line, '##') and $first-line!='##'">
- <comment>
- <value-of select="substring-after($first-line, '##')"/>
- </comment>
+ <call-template name="LesML:comment-out">
+ <with-param name="source" select="substring-after($first-line, '##')"/>
+ </call-template>
</if>
<if test="$doclines[normalize-space()!='']">
<variable name="record-separators" select="$doclines[starts-with(., '%%')]"/>
</element>
</if>
<if test=".!='%%'">
- <comment>
- <value-of select="substring-after(., '%%')"/>
- </comment>
+ <call-template name="LesML:comment-out">
+ <with-param name="source" select="substring-after(., '%%')"/>
+ </call-template>
</if>
</for-each>
</element>
</element>
</when>
<when test="starts-with($text, '#') and &sigiled-text;">
- <comment>
- <value-of select="&unsigiled-text;"/>
- </comment>
+ <call-template name="LesML:comment-out">
+ <with-param name="source" select="&unsigiled-text;"/>
+ </call-template>
</when>
<otherwise>
<element name="p" namespace="&xhtml;">
</for-each>
<value-of select="substring-before($end-node, '⌫')"/>
</variable>
- <variable name="comment-split-fragment">
- <call-template name="LesML:split">
- <with-param name="source" select="string($comment)"/>
- <with-param name="separator" select="'--'"/>
- </call-template>
- </variable>
<variable name="rest-fragment">
<element name="span" namespace="&xhtml;">
<value-of select="substring-after($end-node, '⌫')"/>
<copy-of select="@*"/>
<copy-of select="$start-node/preceding-sibling::node()"/>
<copy-of select="substring-before($start-node, '⌦')"/>
- <comment>
- <for-each select="exsl:node-set($comment-split-fragment)/*">
- <if test="string()='' or starts-with(., '‐')">
- <text>͏</text>
- </if>
- <value-of select="."/>
- <if test="substring(., string-length(.), 1)='‐'">
- <text>͏</text>
- </if>
- <choose>
- <when test="position()!=last()">
- <text>-͏-</text>
- </when>
- </choose>
- </for-each>
- </comment>
+ <call-template name="LesML:comment-out">
+ <with-param name="source" select="string($comment)"/>
+ </call-template>
<copy-of select="exsl:node-set($commented-rest-fragment)/*/node()"/>
</copy>
</when>
<for-each select="exsl:node-set($split-fragment)/node()">
<value-of select="."/>
<if test="position()!=last()">
- <comment>
- <text>͏</text>
- </comment>
+ <call-template name="LesML:comment-out"/>
</if>
</for-each>
</when>
<param name="end-sigil"/>
<param name="class"/>
<param name="role"/>
- <param name="langtag-supported" select="false()"/>
<choose>
<when test="self::*">
<variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
<value-of select="substring-before($end-node, $end-sigil)"/>
</variable>
<variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., $start-sigil)][last()]"/>
- <variable name="restoftext" select="substring-after($end-node, $end-sigil)"/>
- <variable name="maybe-langtag">
- <if test="$langtag-supported and starts-with($restoftext, '@') and contains($restoftext, '$')">
- <value-of select="substring-before(substring-after($restoftext, '@'), '$')"/>
- </if>
- </variable>
- <variable name="langtag">
- <if test="translate($maybe-langtag, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-', '')=''">
- <value-of select="$maybe-langtag"/>
- </if>
- </variable>
<variable name="start-tokens-fragment">
<call-template name="LesML:split">
<with-param name="source" select="string($start-node)"/>
<value-of select="$class"/>
</attribute>
</if>
- <if test="string($langtag)!=''">
- <if test="$element-namespace='http://www.w3.org/1999/xhtml'">
- <attribute name="lang">
- <value-of select="$langtag"/>
- </attribute>
- </if>
- <attribute name="xml:lang">
- <value-of select="$langtag"/>
- </attribute>
- </if>
<value-of select="$start-tokens[last()]"/>
<copy-of select="$start-node/following-sibling::node()"/>
</element>
- <choose>
- <when test="string($langtag)!=''">
- <value-of select="substring-after($restoftext, '$')"/>
- </when>
- <otherwise>
- <value-of select="$restoftext"/>
- </otherwise>
- </choose>
+ <value-of select="substring-after($end-node, $end-sigil)"/>
<copy-of select="$end-node/following-sibling::node()"/>
</copy>
</variable>
<with-param name="start-sigil" select="$start-sigil"/>
<with-param name="end-sigil" select="$end-sigil"/>
<with-param name="role" select="$role"/>
- <with-param name="langtag-supported" select="$langtag-supported"/>
</apply-templates>
</when>
<otherwise>
<with-param name="start-sigil" select="$start-sigil"/>
<with-param name="end-sigil" select="$end-sigil"/>
<with-param name="role" select="$role"/>
- <with-param name="langtag-supported" select="$langtag-supported"/>
</apply-templates>
</copy>
</otherwise>
<with-param name="element-namespace" select="'&xhtml;'"/>
<with-param name="start-sigil" select="'⟨'"/>
<with-param name="end-sigil" select="'⟩'"/>
- <with-param name="langtag-supported" select="true()"/>
</apply-templates>
</variable>
<apply-templates select="exsl:node-set($result)/node()" mode="LesML:bolded"/>