]> Lady’s Gitweb - LesML/commitdiff
Support language tag and profile 0.2.2
authorLady <redacted>
Sat, 19 Oct 2024 16:43:33 +0000 (12:43 -0400)
committerLady <redacted>
Sat, 19 Oct 2024 16:43:33 +0000 (12:43 -0400)
This commit provides initial support for language‐tagged Les·M·L
documents and additional document properties. Only one property is
supported: `profile`. Language tags are themselves internally treated
as properties whose key contains spaces; property keys cannot
ordinarily contain spaces so there is no concern for confusion.

README.markdown
parser.xslt

index adb7e26afc8587ca66e5f5a9566664345a4ed32c..7df7fdecb1a948fff11ff43c224747226f330884 100644 (file)
@@ -28,9 +28,18 @@ It is implemented as an X·S·L·T transformation from a
 
 The first line of any 💄📝 Les·M·L document should be the string
   `#!lesml`.
-
-Following the shebang, document metadata may be provided in the [Record
-  Jar][draft-phillips-record-jar-01] format.
+A language tag may follow this, beginning with `@` and terminated with
+  `$`, like so:
+`#!lesml@en$`.
+Regardless of whether a language tag is present, the shebang line may
+  be terminated by a space‐separated list of properties of the form
+  `key=value`.
+Only one property is currently permitted: `profile`, whose value should
+  be a U·R·I and is translated to the `@data-lesml-profile` attribute
+  on the resulting `<html:article>` element.
+
+Following the shebang line, document metadata may be provided in the
+  [Record Jar][draft-phillips-record-jar-01] format.
 The body of the document begins after the last line which begins with
   the string `%%`, or after the shebang line if none exists.
 
index f2279d877cbdc5ac58e7491c80e2fa409bbd9fe8..86c28ea1a31bade3aeefb20e4cd3c9779c3e1dba 100644 (file)
@@ -122,6 +122,12 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        </template>
        <template name="LesML:parse">
                <param name="source"/>
+               <param name="parent-params" select="/.."/>
+               <variable name="shebang">
+                       <if test="starts-with($source, '#!lesml')">
+                               <value-of select="substring-before($source, '&#xA;')"/>
+                       </if>
+               </variable>
                <variable name="noshebang">
                        <text>&#xA;</text>
                        <choose>
@@ -133,6 +139,53 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                </otherwise>
                        </choose>
                </variable>
+               <variable name="params-string">
+                       <choose>
+                               <when test="starts-with($shebang, '#!lesml@')">
+                                       <value-of select="substring-after($shebang, '$')"/>
+                               </when>
+                               <otherwise>
+                                       <value-of select="substring-after($shebang, '#!lesml')"/>
+                               </otherwise>
+                       </choose>
+               </variable>
+               <variable name="params-fragment">
+                       <html:dl>
+                               <if test="starts-with($shebang, '#!lesml@') and contains($shebang, '$')">
+                                       <html:div>
+                                               <html:dt>
+                                                       <text> LANG </text>
+                                               </html:dt>
+                                               <html:dd>
+                                                       <value-of select="substring-before(substring-after($shebang, '#!lesml@'), '$')"/>
+                                               </html:dd>
+                                       </html:div>
+                               </if>
+                               <for-each select="exslstr:tokenize($params-string)">
+                                       <choose>
+                                               <when test="contains(., '=')">
+                                                       <html:div>
+                                                               <html:dt>
+                                                                       <value-of select="substring-before(., '=')"/>
+                                                               </html:dt>
+                                                               <html:dd>
+                                                                       <value-of select="substring-after(., '=')"/>
+                                                               </html:dd>
+                                                       </html:div>
+                                               </when>
+                                               <otherwise>
+                                                       <html:div>
+                                                               <html:dt>
+                                                                       <value-of select="."/>
+                                                               </html:dt>
+                                                               <html:dd/>
+                                                       </html:div>
+                                               </otherwise>
+                                       </choose>
+                               </for-each>
+                       </html:dl>
+               </variable>
+               <variable name="params" select="exsl:node-set($params-fragment)/*"/>
                <variable name="records">
                        <call-template name="LesML:split">
                                <with-param name="source" select="$noshebang"/>
@@ -141,6 +194,19 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                </variable>
                <variable name="record-nodes" select="exsl:node-set($records)/*"/>
                <html:article>
+                       <for-each select="$params/html:div/html:dt[string()=' LANG ']">
+                               <attribute name="lang">
+                                       <value-of select="following-sibling::html:dd"/>
+                               </attribute>
+                               <attribute name="xml:lang">
+                                       <value-of select="following-sibling::html:dd"/>
+                               </attribute>
+                       </for-each>
+                       <for-each select="$params/html:div/html:dt[string()='profile']">
+                               <attribute name="data-lesml-profile">
+                                       <value-of select="following-sibling::html:dd"/>
+                               </attribute>
+                       </for-each>
                        <if test="count($record-nodes)>1">
                                <html:footer class="head">
                                        <for-each select="$record-nodes[not(position()=last() or normalize-space(.)='')]">
This page took 0.025365 seconds and 4 git commands to generate.