]> Lady’s Gitweb - LesML/blobdiff - parser.xslt
Support language tag and profile
[LesML] / parser.xslt
index 6f312626aad1d7edf57e35c8d22cf2260b42d288..86c28ea1a31bade3aeefb20e4cd3c9779c3e1dba 100644 (file)
@@ -11,6 +11,9 @@ SPDX-License-Identifier: MPL-2.0
 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 -->
 This Source Code Form is subject to the terms of the Mozilla Public License, v 2.0.
 If a copy of the M·P·L was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 -->
+<!DOCTYPE transform [
+       <!ENTITY section-break '#*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~'>
+]>
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
        xmlns:LesML="urn:fdc:ladys.computer:20240512:LesML"
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
        xmlns:LesML="urn:fdc:ladys.computer:20240512:LesML"
@@ -119,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"/>
        </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>
                <variable name="noshebang">
                        <text>&#xA;</text>
                        <choose>
@@ -130,6 +139,53 @@ 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="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"/>
                <variable name="records">
                        <call-template name="LesML:split">
                                <with-param name="source" select="$noshebang"/>
@@ -138,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>
                </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(.)='')]">
                        <if test="count($record-nodes)>1">
                                <html:footer class="head">
                                        <for-each select="$record-nodes[not(position()=last() or normalize-space(.)='')]">
@@ -392,7 +461,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                </choose>
                                        </variable>
                                        <choose>
                                                </choose>
                                        </variable>
                                        <choose>
-                                               <when test="translate(string($text), '#*-=_~⁂─━┄┅┈┉╌╍═╴╶╸╺☙❧ ', '')=''">
+                                               <when test="translate(string($text), '&section-break; ', '')=''">
                                                        <html:hr/>
                                                </when>
                                                <when test="$quoted">
                                                        <html:hr/>
                                                </when>
                                                <when test="$quoted">
This page took 0.051473 seconds and 4 git commands to generate.