Remove br magic.
authorRadek Czajka <rczajka@rczajka.pl>
Mon, 5 May 2025 11:02:31 +0000 (13:02 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Mon, 5 May 2025 11:02:31 +0000 (13:02 +0200)
src/redakcja/static/js/wiki/xslt.js
src/wlxml/templates/wlxml/wl2html.xsl

index 99af3c3..922a3ba 100644 (file)
@@ -36,7 +36,7 @@ function withStylesheets(code_block, onError)
 
 function xml2html(options) {
     withStylesheets(function() {
-        var xml = options.xml.replace(/\/(\s+)/g, '<br />$1');
+        var xml = options.xml.replace(/\/(\s+)/g, '<_n />$1');
         xml = xml.replace(/([^a-zA-Z0-9ąćęłńóśźżĄĆĘŁŃÓŚŹŻ\s<>«»\\*_!,:;?&%."'=#()\/-]+)/g, '<alien>$1</alien>');
         var parser = new DOMParser();
         var serializer = new XMLSerializer();
index 9716e19..c70286a 100644 (file)
             <xsl:call-template name="standard-attributes" />
          
             <xsl:choose>
-                <xsl:when test="count(br) > 0">
-                    <xsl:variable name="first-verse" select="br[1]/preceding-sibling::node()" />                    
+                <xsl:when test="count(_n) > 0">
+                    <xsl:variable name="first-verse" select="_n[1]/preceding-sibling::node()" />
                     <xsl:call-template name="verse">
                         <xsl:with-param name="verse-content" select="$first-verse" />                        
                     </xsl:call-template>
-                    <xsl:for-each select="br">
-                        <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
-                        <!-- select all nodes up to the next br or end of stanza -->
+                    <xsl:for-each select="_n">
+                        <xsl:variable name="lnum" select="count(preceding-sibling::_n)" />
+                        <!-- select all nodes up to the next _n or end of stanza -->
                         <xsl:variable name="current-verse"
-                            select="following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />                        
+                            select="following-sibling::node()[count(preceding-sibling::_n) = $lnum+1]" />
                         <xsl:call-template name="verse">
                             <xsl:with-param name="verse-content" select="$current-verse" />                            
                         </xsl:call-template>
     </xsl:template>
 
     <xsl:template name="verse">
-        <!-- the verse contents including the last br (if any) -->
+        <!-- the verse contents including the last _n (if any) -->
         <xsl:param name="verse-content" />
         <xsl:variable name="first-tag-name" select="name($verse-content/self::*)" />
         <!-- name of text nodes is '' == false -->
         <!-- THIS IS A HORROR!!! -->
         <!-- Possible variants: -->
         <xsl:choose>
-            <!-- Simple verse == not wers_ tags anywhere until the ending br -->
+            <!-- Simple verse == not wers_ tags anywhere until the ending _n -->
             <xsl:when test="not($verse-content[starts-with(name(), 'wers')])">
                 <div class="wers" x-node="wers" x-verse="true" x-auto-node="true">
-                <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
+                <xsl:apply-templates select="$verse-content[local-name(.) != '_n']">
                     <xsl:with-param name="mixed" select="true()" />
                 </xsl:apply-templates>
                 </div>
             </xsl:when>
 
             <xsl:otherwise>
-            <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
+            <xsl:apply-templates select="$verse-content[local-name(.) != '_n']">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             </xsl:otherwise>
     </xsl:template>
     {% endif %}
 
-    <xsl:template match="br"><xsl:text>/</xsl:text></xsl:template>
+    <xsl:template match="_n"><xsl:text>/</xsl:text></xsl:template>
 
     {% if tags.span %}
     <!-- Style znakowe         span -->