+ <template match="node()" mode="LesML:comment">
+ <param name="footnote-ids" select="/.."/>
+ <variable name="result">
+ <choose>
+ <when test="self::*">
+ <variable name="start-node" select="text()[contains(., '⌦')][1]"/>
+ <variable name="after-start">
+ <if test="$start-node">
+ <value-of select="substring-after($start-node, '⌦')"/>
+ </if>
+ </variable>
+ <variable name="has-end-node" select="contains($after-start, '⌫') or $start-node/following-sibling::text()[contains(., '⌫')]"/>
+ <choose>
+ <when test="$start-node and $has-end-node">
+ <variable name="following">
+ <value-of select="$after-start"/>
+ <copy-of select="$start-node/following-sibling::node()"/>
+ </variable>
+ <variable name="end-node" select="exsl:node-set($following)/text()[contains(., '⌫')][last()]"/>
+ <variable name="comment">
+ <for-each select="$end-node/preceding-sibling::node()">
+ <value-of select="."/>
+ </for-each>
+ <value-of select="substring-before($end-node, '⌫')"/>
+ </variable>
+ <variable name="rest-fragment">
+ <element name="span" namespace="&xhtml;">
+ <value-of select="substring-after($end-node, '⌫')"/>
+ <copy-of select="$end-node/following-sibling::node()"/>
+ </element>
+ </variable>
+ <variable name="commented-rest-fragment">
+ <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:comment">
+ <with-param name="footnote-ids" select="$footnote-ids"/>
+ </apply-templates>
+ </variable>
+ <copy>
+ <copy-of select="@*"/>
+ <copy-of select="$start-node/preceding-sibling::node()"/>
+ <copy-of select="substring-before($start-node, '⌦')"/>
+ <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>
+ <when test="$start-node">
+ <variable name="rest-fragment">
+ <element name="div" namespace="&xhtml;">
+ <value-of select="substring-after($after-start, '⌦')"/>
+ <copy-of select="$start-node/following-sibling::node()"/>
+ </element>
+ </variable>
+ <variable name="commented-rest-fragment">
+ <apply-templates select="exsl:node-set($rest-fragment)/node()" mode="LesML:comment">
+ <with-param name="footnote-ids" select="$footnote-ids"/>
+ </apply-templates>
+ </variable>
+ <copy>
+ <copy-of select="@*"/>
+ <copy-of select="$start-node/preceding-sibling::node()"/>
+ <copy-of select="substring-before($start-node, '⌦')"/>
+ <text>^</text>
+ <copy-of select="exsl:node-set($commented-rest-fragment)/*/node()"/>
+ </copy>
+ </when>
+ <otherwise>
+ <copy>
+ <copy-of select="@*"/>
+ <apply-templates select="node()" mode="LesML:comment">
+ <with-param name="footnote-ids" select="$footnote-ids"/>
+ </apply-templates>
+ </copy>
+ </otherwise>
+ </choose>
+ </when>
+ <when test="self::text()[contains(., '⌧')]">
+ <for-each select="LesML:split(., '⌧')">
+ <value-of select="."/>
+ <if test="position()!=last()">
+ <call-template name="LesML:comment-out"/>
+ </if>
+ </for-each>
+ </when>
+ <otherwise>
+ <copy-of select="."/>
+ </otherwise>
+ </choose>
+ </variable>
+ <apply-templates select="exsl:node-set($result)/node()" mode="LesML:attrify">
+ <with-param name="footnote-ids" select="$footnote-ids"/>
+ </apply-templates>
+ </template>