]> Lady’s Gitweb - LesML/commitdiff
Properly escape all comments
authorLady <redacted>
Sun, 27 Apr 2025 22:00:37 +0000 (18:00 -0400)
committerLady <redacted>
Sun, 27 Apr 2025 22:00:37 +0000 (18:00 -0400)
parser.xslt

index 8f80c393e9ffefabfb2ee42991439ee830e9d6e6..186e3896328a4d76f7259bb1a2f60815a1df3234 100644 (file)
@@ -121,6 +121,31 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        </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>&#x034F;</text>
+                               </if>
+                               <value-of select="."/>
+                               <if test="substring(., string-length(.), 1)='‐'">
+                                       <text>&#x034F;</text>
+                               </if>
+                               <choose>
+                                       <when test="position()!=last()">
+                                               <text>-&#x034F;-</text>
+                                       </when>
+                               </choose>
+                       </for-each>
+               </comment>
+       </template>
        <template name="LesML:id-and-contents">
                <param name="source"/>
                <variable name="id-and-lang">
@@ -257,9 +282,9 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                <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(., '%%')]"/>
@@ -335,9 +360,9 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </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>
@@ -637,9 +662,9 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </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;">
@@ -839,12 +864,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </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, '⌫')"/>
@@ -858,22 +877,9 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                <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>&#x034F;</text>
-                                                                               </if>
-                                                                               <value-of select="."/>
-                                                                               <if test="substring(., string-length(.), 1)='‐'">
-                                                                                       <text>&#x034F;</text>
-                                                                               </if>
-                                                                               <choose>
-                                                                                       <when test="position()!=last()">
-                                                                                               <text>-&#x034F;-</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>
@@ -895,9 +901,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                        <for-each select="exsl:node-set($split-fragment)/node()">
                                                <value-of select="."/>
                                                <if test="position()!=last()">
-                                                       <comment>
-                                                               <text>&#x034F;</text>
-                                                       </comment>
+                                                       <call-template name="LesML:comment-out"/>
                                                </if>
                                        </for-each>
                                </when>
This page took 0.089602 seconds and 4 git commands to generate.