]> Lady’s Gitweb - LesML/blobdiff - parser.xslt
Better handle id‐less pilcrows
[LesML] / parser.xslt
index de60b8fd0422dd68ad67227fd73ba718456d5d05..2f028c2036f24f1dea89455a7fed05185663c4b5 100644 (file)
@@ -12,7 +12,9 @@ This Source Code Form is subject to the terms of the Mozilla Public License, v 2
 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 '*-.=_~·․‥…⁂⋯─━┄┅┈┉╌╍═╴╶╸╺☙❧ ・*-.=_~'>
+       <!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)">
 ]>
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
@@ -103,9 +105,12 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        <when test="starts-with($source, '¶')">
                                <choose>
                                        <when test="contains($source, ' ')">
-                                               <attribute name="id">
-                                                       <value-of select="substring-before(substring-after($source, '¶'), ' ')"/>
-                                               </attribute>
+                                               <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, ' ')"/>
                                        </when>
                                        <otherwise>
@@ -306,160 +311,165 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                <if test="string($text)!=''">
                                        <variable name="par">
                                                <choose>
-                                                       <when test="starts-with($text, '⁌ ')">
+                                                       <when test="starts-with($text, '⁌') and &sigiled-text;">
                                                                <html:h1>
                                                                        <call-template name="LesML:id-and-contents">
-                                                                               <with-param name="source" select="substring-after($text, '⁌ ')"/>
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </html:h1>
                                                        </when>
-                                                       <when test="starts-with($text, '§ ')">
+                                                       <when test="starts-with($text, '§') and &sigiled-text;">
                                                                <html:h2>
                                                                        <call-template name="LesML:id-and-contents">
-                                                                               <with-param name="source" select="substring-after($text, '§ ')"/>
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </html:h2>
                                                        </when>
-                                                       <when test="starts-with($text, '❦ ')">
+                                                       <when test="starts-with($text, '❦') and &sigiled-text;">
                                                                <html:h3>
                                                                        <call-template name="LesML:id-and-contents">
-                                                                               <with-param name="source" select="substring-after($text, '❦ ')"/>
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </html:h3>
                                                        </when>
-                                                       <when test="starts-with($text, '✠ ')">
+                                                       <when test="starts-with($text, '✠') and &sigiled-text;">
                                                                <html:h4>
                                                                        <call-template name="LesML:id-and-contents">
-                                                                               <with-param name="source" select="substring-after($text, '✠ ')"/>
+                                                                               <with-param name="source" select="&unsigiled-text;"/>
                                                                        </call-template>
                                                                </html:h4>
                                                        </when>
-                                                       <when test="starts-with($text, '• ')">
+                                                       <when test="starts-with($text, '•') and &sigiled-text;">
                                                                <html:li class="unordered" data-level="1">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '• ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:li>
                                                        </when>
-                                                       <when test="starts-with($text, '🔢 ')">
+                                                       <when test="starts-with($text, '🔢') and &sigiled-text;">
                                                                <html:li class="ordered" data-level="1">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '🔢 ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:li>
                                                        </when>
-                                                       <when test="starts-with($text, '◦ ')">
+                                                       <when test="starts-with($text, '◦') and &sigiled-text;">
                                                                <html:li class="unordered" data-level="2">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '◦ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:li>
                                                        </when>
-                                                       <when test="starts-with($text, '🔠 ')">
+                                                       <when test="starts-with($text, '🔠') and &sigiled-text;">
                                                                <html:li class="ordered" data-level="2">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '🔠 ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:li>
                                                        </when>
-                                                       <when test="starts-with($text, '▪ ')">
+                                                       <when test="starts-with($text, '▪') and &sigiled-text;">
                                                                <html:li class="unordered" data-level="3">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '▪ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:li>
                                                        </when>
-                                                       <when test="starts-with($text, '🔡 ')">
+                                                       <when test="starts-with($text, '🔡') and &sigiled-text;">
                                                                <html:li class="ordered" data-level="3">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '🔡 ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:li>
                                                        </when>
-                                                       <when test="starts-with($text, '⁃ ')">
+                                                       <when test="starts-with($text, '⁃') and &sigiled-text;">
                                                                <html:li class="unordered" data-level="4">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '⁃ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:li>
                                                        </when>
-                                                       <when test="starts-with($text, '🔣 ')">
+                                                       <when test="starts-with($text, '🔣') and &sigiled-text;">
                                                                <html:li class="ordered" data-level="4">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '🔣 ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:li>
                                                        </when>
-                                                       <when test="starts-with($text, '🛈 ')">
+                                                       <when test="starts-with($text, '🛈') and &sigiled-text;">
                                                                <html:div role="note" class="info">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '🛈 ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:div>
                                                        </when>
-                                                       <when test="starts-with($text, '⯑ ')">
+                                                       <when test="starts-with($text, '⯑') and &sigiled-text;">
                                                                <html:div role="note" class="query">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '⯑ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:div>
                                                        </when>
-                                                       <when test="starts-with($text, '⚠︎ ')">
+                                                       <when test="starts-with($text, '⚠︎') and &sigiled-text;">
                                                                <html:div role="note" class="warn">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '⚠︎ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:div>
                                                        </when>
-                                                       <when test="starts-with($text, '※ ')">
+                                                       <when test="starts-with($text, '※') and &sigiled-text;">
                                                                <html:div role="note" class="note">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '※ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:div>
                                                        </when>
-                                                       <when test="starts-with($text, '☡ ')">
+                                                       <when test="starts-with($text, '☡') and &sigiled-text;">
                                                                <html:div role="note" class="caution">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '☡ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:div>
                                                        </when>
-                                                       <when test="starts-with($text, '⋯ ')">
+                                                       <when test="starts-with($text, '⋯') and &sigiled-text;">
                                                                <html:div class="continuation">
                                                                        <html:p>
                                                                                <call-template name="LesML:id-and-contents">
-                                                                                       <with-param name="source" select="substring-after($text, '⋯ ')"/>
+                                                                                       <with-param name="source" select="&unsigiled-text;"/>
                                                                                </call-template>
                                                                        </html:p>
                                                                </html:div>
                                                        </when>
+                                                       <when test="starts-with($text, '#') and &sigiled-text;">
+                                                               <comment>
+                                                                       <value-of select="&unsigiled-text;"/>
+                                                               </comment>
+                                                       </when>
                                                        <otherwise>
                                                                <html:p>
                                                                        <call-template name="LesML:id-and-contents">
This page took 0.079482 seconds and 4 git commands to generate.