]> Lady’s Gitweb - LesML/blobdiff - parser.xslt
Support attributes inside of links
[LesML] / parser.xslt
index 99ee7434f534aec464594df038b17656e7ccf157..bcc8a23d4dbaaa662ef8bb329d7a387c06b46123 100644 (file)
@@ -658,7 +658,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                </element>
                                                        </element>
                                                </when>
                                                                </element>
                                                        </element>
                                                </when>
-                                               <when test="starts-with($text, '⚠') and &sigiled-text;">
+                                               <when test="starts-with($text, '⚠') and &sigiled-text;">
                                                        <element name="div" namespace="&xhtml;">
                                                                <attribute name="role">
                                                                        <text>note</text>
                                                        <element name="div" namespace="&xhtml;">
                                                                <attribute name="role">
                                                                        <text>note</text>
@@ -705,9 +705,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                </when>
                                                <when test="starts-with($text, '⋯') and &sigiled-text;">
                                                        <element name="div" namespace="&xhtml;">
                                                </when>
                                                <when test="starts-with($text, '⋯') and &sigiled-text;">
                                                        <element name="div" namespace="&xhtml;">
-                                                               <attribute name="class">
-                                                                       <text>continuation</text>
-                                                               </attribute>
+                                                               <processing-instruction name="LesML-Continuation"/>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
                                                                <element name="p" namespace="&xhtml;">
                                                                        <call-template name="LesML:id-and-contents">
                                                                                <with-param name="source" select="&unsigiled-text;"/>
@@ -783,18 +781,68 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                </element>
        </template>
        <template match="html:div" mode="LesML:finalize-tree">
                </element>
        </template>
        <template match="html:div" mode="LesML:finalize-tree">
-               <if test="not(@class='continuation') or not(preceding-sibling::node()) or preceding-sibling::node()[position()=1 and not(self::html:div or self::html:li)]">
-                       <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div and @class='continuation')][1]"/>
-                       <copy>
-                               <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
-                               <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
+               <if test="not(processing-instruction()[local-name()='LesML-Continuation']) or not(preceding-sibling::node()[position()=1 and self::html:* and contains(' div li h1 h2 h3 h4 h5 h6 ', local-name())])">
+                       <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
+                       <choose>
+                               <when test="processing-instruction()[local-name()='LesML-Continuation'] and $notcontinuation[self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
+                                       <variable name="notcontinuation2" select="$notcontinuation/following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
+                                       <element name="hgroup" namespace="&xhtml;">
+                                               <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                               <for-each select="exslset:leading(following-sibling::node(), $notcontinuation2)">
+                                                       <choose>
+                                                               <when test="self::html:div">
+                                                                       <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                                               </when>
+                                                               <otherwise>
+                                                                       <copy>
+                                                                               <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+                                                                       </copy>
+                                                               </otherwise>
+                                                       </choose>
+                                               </for-each>
+                                       </element>
+                               </when>
+                               <when test="not(processing-instruction()[local-name()='LesML-Continuation'])">
+                                       <copy>
+                                               <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+                                               <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
+                                                       <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                               </for-each>
+                                       </copy>
+                               </when>
+                               <otherwise>
                                        <apply-templates select="node()" mode="LesML:finalize-tree"/>
                                        <apply-templates select="node()" mode="LesML:finalize-tree"/>
-                               </for-each>
-                       </copy>
+                                       <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
+                                               <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                       </for-each>
+                               </otherwise>
+                       </choose>
+               </if>
+       </template>
+       <template match="html:h1|html:h2|html:h3|html:h4|html:h5|html:h6" mode="LesML:finalize-tree">
+               <if test="not(preceding-sibling::node()[position()=1 and self::html:div/processing-instruction()[local-name()='LesML-Continuation']]) or preceding-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][position()=1 and self::html:* and contains(' h1 h2 h3 h4 h5 h6 ', local-name())]">
+                       <choose>
+                               <when test="following-sibling::node()[position()=1 and self::html:div]/processing-instruction()[local-name()='LesML-Continuation']">
+                                       <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
+                                       <element name="hgroup" namespace="&xhtml;">
+                                               <copy>
+                                                       <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+                                               </copy>
+                                               <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
+                                                       <apply-templates select="node()" mode="LesML:finalize-tree"/>
+                                               </for-each>
+                                       </element>
+                               </when>
+                               <otherwise>
+                                       <copy>
+                                               <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
+                                       </copy>
+                               </otherwise>
+                       </choose>
                </if>
        </template>
        <template match="html:li" mode="LesML:finalize-tree">
                </if>
        </template>
        <template match="html:li" mode="LesML:finalize-tree">
-               <if test="not(preceding-sibling::node()) or preceding-sibling::node()[not(preceding-sibling::* and self::html:div and @class='continuation')][position()=1 and not(self::html:li)]">
+               <if test="not(preceding-sibling::node()) or preceding-sibling::node()[not(preceding-sibling::* and self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][position()=1 and not(self::html:li)]">
                        <apply-templates select="." mode="LesML:finalize-list"/>
                </if>
        </template>
                        <apply-templates select="." mode="LesML:finalize-list"/>
                </if>
        </template>
@@ -812,10 +860,10 @@ 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="notinlist" select="following-sibling::node()[not(self::html:div and @class='continuation' or self::html:li and (@data-level>$current-level or @data-level=$current-level and @class=$current-class))][1]"/>
+               <variable name="notinlist" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'] or self::html:li and (@data-level>$current-level or @data-level=$current-level and @class=$current-class))][1]"/>
                <element name="{$wrapper}" namespace="&xhtml;">
                        <for-each select=".|exslset:leading(following-sibling::node(), $notinlist)[self::html:li and @data-level=$current-level]">
                <element name="{$wrapper}" namespace="&xhtml;">
                        <for-each select=".|exslset:leading(following-sibling::node(), $notinlist)[self::html:li and @data-level=$current-level]">
-                               <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div and @class='continuation')][1]"/>
+                               <variable name="notcontinuation" select="following-sibling::node()[not(self::html:div/processing-instruction()[local-name()='LesML-Continuation'])][1]"/>
                                <copy>
                                        <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
                                        <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
                                <copy>
                                        <apply-templates select="@*|node()" mode="LesML:finalize-tree"/>
                                        <for-each select="exslset:leading(following-sibling::node(), $notcontinuation)">
@@ -835,6 +883,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                        </apply-templates>
                </if>
        </template>
                        </apply-templates>
                </if>
        </template>
+       <template match="processing-instruction()[local-name()='LesML-Continuation']" mode="LesML:finalize-tree"/>
        <template match="processing-instruction()[local-name()='LesML-Token-Escape']" mode="LesML:finalize-tree">
                <value-of select="."/>
        </template>
        <template match="processing-instruction()[local-name()='LesML-Token-Escape']" mode="LesML:finalize-tree">
                <value-of select="."/>
        </template>
@@ -1007,42 +1056,73 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                <param name="separator"/>
                <param name="ncname-keys" select="false()"/>
                <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
                <param name="separator"/>
                <param name="ncname-keys" select="false()"/>
                <variable name="end-node" select="text()[contains(., $end-sigil)][1]"/>
-               <variable name="has-start-node" select="$end-node/preceding-sibling::text()[contains(., $start-sigil) and not(following-sibling::* or following-sibling::comment())] or string-length(substring-after($end-node, $start-sigil))>string-length(substring-after($end-node, $end-sigil))"/>
+               <variable name="has-start-node" select="$end-node/preceding-sibling::text()[contains(., $start-sigil)] or string-length(substring-after($end-node, $start-sigil))>string-length(substring-after($end-node, $end-sigil))"/>
                <choose>
                        <when test="$end-node and $has-start-node">
                <choose>
                        <when test="$end-node and $has-start-node">
-                               <variable name="preceding">
+                               <variable name="preceding-fragment">
                                        <copy-of select="$end-node/preceding-sibling::node()"/>
                                        <value-of select="substring-before($end-node, $end-sigil)"/>
                                </variable>
                                        <copy-of select="$end-node/preceding-sibling::node()"/>
                                        <value-of select="substring-before($end-node, $end-sigil)"/>
                                </variable>
-                               <variable name="start-node" select="exsl:node-set($preceding)/text()[contains(., $start-sigil) and not(following-sibling::*)][last()]"/>
+                               <variable name="preceding" select="exsl:node-set($preceding-fragment)/node()"/>
+                               <variable name="start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()][not($ncname-keys) or not(following-sibling::* or following-sibling::comment())]"/>
                                <variable name="start-tokens-fragment">
                                <variable name="start-tokens-fragment">
-                                       <call-template name="LesML:split">
-                                               <with-param name="source" select="string($start-node)"/>
-                                               <with-param name="separator" select="$start-sigil"/>
-                                       </call-template>
+                                       <if test="$start-node">
+                                               <call-template name="LesML:split">
+                                                       <with-param name="source" select="string($start-node)"/>
+                                                       <with-param name="separator" select="$start-sigil"/>
+                                               </call-template>
+                                       </if>
                                </variable>
                                <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
                                </variable>
                                <variable name="start-tokens" select="exsl:node-set($start-tokens-fragment)/*"/>
-                               <variable name="innards">
+                               <variable name="innards-fragment">
                                        <value-of select="$start-tokens[last()]"/>
                                        <value-of select="$start-tokens[last()]"/>
-                                       <for-each select="$start-node/following-sibling::node()">
-                                               <value-of select="."/>
-                                       </for-each>
+                                       <copy-of select="$start-node/following-sibling::node()"/>
                                </variable>
                                </variable>
+                               <variable name="innards" select="exsl:node-set($innards-fragment)/node()"/>
+                               <variable name="separator-node" select="($innards[self::text() and contains(., $separator)])[not($ncname-keys)*(last()-1)+1]"/>
                                <choose>
                                <choose>
-                                       <when test="contains($innards, $separator)">
+                                       <when test="not($start-node) or $separator-node[following-sibling::* or following-sibling::comment()]">
+                                               <variable name="bad-start-node" select="($preceding[self::text() and contains(., $start-sigil)])[last()]"/>
+                                               <variable name="bad-start-tokens-fragment">
+                                                       <call-template name="LesML:split">
+                                                               <with-param name="source" select="string($bad-start-node)"/>
+                                                               <with-param name="separator" select="$start-sigil"/>
+                                                       </call-template>
+                                               </variable>
+                                               <element name="span" namespace="&xhtml;">
+                                                       <copy-of select="$bad-start-node/preceding-sibling::node()"/>
+                                                       <for-each select="exsl:node-set($bad-start-tokens-fragment)/*">
+                                                               <value-of select="."/>
+                                                               <if test="position()!=last()">
+                                                                       <processing-instruction name="LesML-Token-Escape">
+                                                                               <value-of select="$start-sigil"/>
+                                                                       </processing-instruction>
+                                                               </if>
+                                                       </for-each>
+                                                       <copy-of select="$bad-start-node/following-sibling::node()"/>
+                                                       <value-of select="$end-sigil"/>
+                                                       <value-of select="substring-after($end-node, $end-sigil)"/>
+                                                       <copy-of select="$end-node/following-sibling::node()"/>
+                                               </element>
+                                       </when>
+                                       <when test="$separator-node">
                                                <variable name="keyval-fragment">
                                                        <call-template name="LesML:split">
                                                <variable name="keyval-fragment">
                                                        <call-template name="LesML:split">
-                                                               <with-param name="source" select="$innards"/>
+                                                               <with-param name="source" select="$separator-node"/>
                                                                <with-param name="separator" select="$separator"/>
                                                        </call-template>
                                                </variable>
                                                <variable name="keyval" select="exsl:node-set($keyval-fragment)/*"/>
                                                                <with-param name="separator" select="$separator"/>
                                                        </call-template>
                                                </variable>
                                                <variable name="keyval" select="exsl:node-set($keyval-fragment)/*"/>
-                                               <variable name="key">
+                                               <variable name="key-fragment">
                                                        <choose>
                                                                <when test="$ncname-keys">
                                                        <choose>
                                                                <when test="$ncname-keys">
+                                                                       <for-each select="$separator-node/preceding-sibling::node()">
+                                                                               <value-of select="."/>
+                                                                       </for-each>
                                                                        <value-of select="$keyval[1]"/>
                                                                </when>
                                                                <otherwise>
                                                                        <value-of select="$keyval[1]"/>
                                                                </when>
                                                                <otherwise>
+                                                                       <copy-of select="$separator-node/preceding-sibling::node()"/>
                                                                        <for-each select="$keyval[position()!=last()]">
                                                                                <value-of select="."/>
                                                                                <if test="position()!=last()">
                                                                        <for-each select="$keyval[position()!=last()]">
                                                                                <value-of select="."/>
                                                                                <if test="position()!=last()">
@@ -1066,9 +1146,12 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                        <value-of select="$keyval[last()]"/>
                                                                </otherwise>
                                                        </choose>
                                                                        <value-of select="$keyval[last()]"/>
                                                                </otherwise>
                                                        </choose>
+                                                       <for-each select="$separator-node/following-sibling::node()">
+                                                               <value-of select="."/>
+                                                       </for-each>
                                                </variable>
                                                <choose>
                                                </variable>
                                                <choose>
-                                                       <when test="not($ncname-keys) or /self::node()[translate(normalize-space($key), ' /([,*', '')=string($key) and exsldyn:evaluate(concat('not(self::html:', $key, ')'))]">
+                                                       <when test="not($ncname-keys) or /self::node()[translate(normalize-space($key-fragment), ' /([,*', '')=$key-fragment and exsldyn:evaluate(concat('not(self::html:', $key-fragment, ')'))]">
                                                                <element name="span" namespace="&xhtml;">
                                                                        <copy-of select="$start-node/preceding-sibling::node()"/>
                                                                        <for-each select="$start-tokens[position()!=last()]">
                                                                <element name="span" namespace="&xhtml;">
                                                                        <copy-of select="$start-node/preceding-sibling::node()"/>
                                                                        <for-each select="$start-tokens[position()!=last()]">
@@ -1079,7 +1162,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                        </for-each>
                                                                </element>
                                                                <element name="span" namespace="&xhtml;">
                                                                        </for-each>
                                                                </element>
                                                                <element name="span" namespace="&xhtml;">
-                                                                       <value-of select="$key"/>
+                                                                       <copy-of select="$key-fragment"/>
                                                                </element>
                                                                <element name="span" namespace="&xhtml;">
                                                                        <value-of select="$value"/>
                                                                </element>
                                                                <element name="span" namespace="&xhtml;">
                                                                        <value-of select="$value"/>
@@ -1123,7 +1206,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                <value-of select="$start-sigil"/>
                                                        </processing-instruction>
                                                        <value-of select="$start-tokens[last()]"/>
                                                                <value-of select="$start-sigil"/>
                                                        </processing-instruction>
                                                        <value-of select="$start-tokens[last()]"/>
-                                                       <value-of select="$start-node/following-sibling::node()"/>
+                                                       <copy-of select="$start-node/following-sibling::node()"/>
                                                        <value-of select="$end-sigil"/>
                                                        <value-of select="substring-after($end-node, $end-sigil)"/>
                                                        <copy-of select="$end-node/following-sibling::node()"/>
                                                        <value-of select="$end-sigil"/>
                                                        <value-of select="substring-after($end-node, $end-sigil)"/>
                                                        <copy-of select="$end-node/following-sibling::node()"/>
@@ -1229,11 +1312,11 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                                                                </attribute>
                                                                                <processing-instruction name="LesML-All-Done"/>
                                                                                <choose>
                                                                                </attribute>
                                                                                <processing-instruction name="LesML-All-Done"/>
                                                                                <choose>
-                                                                                       <when test="string($partitioned[2])=''">
+                                                                                       <when test="not($partitioned[2]/node())">
                                                                                                <value-of select="$partitioned[3]"/>
                                                                                        </when>
                                                                                        <otherwise>
                                                                                                <value-of select="$partitioned[3]"/>
                                                                                        </when>
                                                                                        <otherwise>
-                                                                                               <value-of select="$partitioned[2]"/>
+                                                                                               <copy-of select="$partitioned[2]/node()"/>
                                                                                        </otherwise>
                                                                                </choose>
                                                                        </element>
                                                                                        </otherwise>
                                                                                </choose>
                                                                        </element>
This page took 0.227813 seconds and 4 git commands to generate.