]> Lady’s Gitweb - LesML/commitdiff
Drop langtags on offset text but support on paras
authorLady <redacted>
Sun, 27 Apr 2025 05:21:13 +0000 (01:21 -0400)
committerLady <redacted>
Sun, 27 Apr 2025 05:21:13 +0000 (01:21 -0400)
Now that language attributes can be arbitrarily added to any inline,
a special syntax for them doesn’t make much sense. However, that syntax
would be useful on block‐level elements.

There isn’t a real technical reason for the explicit `$` end of the
language tag, since the following white·space could have been used to
end it also, but it makes the syntax a bit more obvious, matches the
existing format with the shebangs, and is less likely to conflict with
id syntaxes (which might include `@` but probably won’t also end in a
`$`).

You can still make id’s like `@es$` if you need by explicitly
language‐tagging: `¶@es$@en$`.

This commit also allows block sigils to not be followed by a space if
they are immediately followed by a pilcrow.

README.markdown
parser.xslt

index 11c8c3723b7ca80497e6bff3ac194d8bc663e0ad..1979cd30517bf5bec7b8b027ed9a493c543038c8 100644 (file)
@@ -179,10 +179,12 @@ After this classification, each quoted or unquoted paragraph is further
 
 - Otherwise, it is an ordinary paragraph.
 
 
 - Otherwise, it is an ordinary paragraph.
 
-Following this sigil (if any, including trailing white·space) there may
-  be a `¶` followed by zero or more non·white·space characters.
+Following this sigil (if any) there may be a `¶` followed by zero or
+  more non·white·space characters.
 The characters following the `¶` give the identifier for the paragraph,
   which is expected to be unique within a document.
 The characters following the `¶` give the identifier for the paragraph,
   which is expected to be unique within a document.
+This may be suffixed with a language tag beginning with `@` and
+  terminated with `$`.
 
 The remaining characters in a paragraph form its contents.
 Markup within paragraphs is delimited with·out exception by pairs of
 
 The remaining characters in a paragraph form its contents.
 Markup within paragraphs is delimited with·out exception by pairs of
@@ -227,8 +229,6 @@ Markup within paragraphs is delimited with·out exception by pairs of
 - The characters `⸶` and `⸷` indicate names (`<html:u class="name">`).
 
 - The characters `⟨` and `⟩` indicate offset text (`<html:i>`).
 - The characters `⸶` and `⸷` indicate names (`<html:u class="name">`).
 
 - The characters `⟨` and `⟩` indicate offset text (`<html:i>`).
-  This may be followed by a `@`, a language tag, and a `$` to provide
-    the language of the text.
 
 - The characters `⦃` and `⦄` indicate keyword highlighting
     (`<html:b>`).
 
 - The characters `⦃` and `⦄` indicate keyword highlighting
     (`<html:b>`).
index f6b38231a9d7d7f0aac4e5739595ed2342fb3aa1..8f80c393e9ffefabfb2ee42991439ee830e9d6e6 100644 (file)
@@ -14,8 +14,8 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
 <!DOCTYPE transform [
        <!ENTITY LesML "urn:fdc:ladys.computer:20240512:LesML">
        <!ENTITY section-break "*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~">
 <!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
        <!ENTITY xhtml "http://www.w3.org/1999/xhtml">
 ]>
 <transform
@@ -123,29 +123,69 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        </template>
        <template name="LesML:id-and-contents">
                <param name="source"/>
        </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, ' ')">
                                <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>
                                        </when>
                                        <otherwise>
-                                               <attribute name="id">
-                                                       <value-of select="substring-after($source, '¶')"/>
-                                               </attribute>
+                                               <value-of select="substring-after($source, '¶')"/>
                                        </otherwise>
                                </choose>
                                        </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="/.."/>
        </template>
        <template name="LesML:parse">
                <param name="lines" select="/.."/>
@@ -875,7 +915,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                <param name="end-sigil"/>
                <param name="class"/>
                <param name="role"/>
                <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]"/>
                <choose>
                        <when test="self::*">
                                <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
@@ -887,17 +926,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                        <value-of select="substring-before($end-node, $end-sigil)"/>
                                                </variable>
                                                <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., $start-sigil)][last()]"/>
                                                        <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)"/>
                                                <variable name="start-tokens-fragment">
                                                        <call-template name="LesML:split">
                                                                <with-param name="source" select="string($start-node)"/>
@@ -926,27 +954,10 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                                        <value-of select="$class"/>
                                                                                </attribute>
                                                                        </if>
                                                                                        <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>
                                                                        <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>
                                                                <copy-of select="$end-node/following-sibling::node()"/>
                                                        </copy>
                                                </variable>
@@ -956,7 +967,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                        <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="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>
                                                </apply-templates>
                                        </when>
                                        <otherwise>
@@ -968,7 +978,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                <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="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>
                                                        </apply-templates>
                                                </copy>
                                        </otherwise>
@@ -1330,7 +1339,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                <with-param name="element-namespace" select="'&xhtml;'"/>
                                <with-param name="start-sigil" select="'⟨'"/>
                                <with-param name="end-sigil" select="'⟩'"/>
                                <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"/>
                        </apply-templates>
                </variable>
                <apply-templates select="exsl:node-set($result)/node()" mode="LesML:bolded"/>
This page took 0.241318 seconds and 4 git commands to generate.