#951: verse-out-of-stanza issue
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 18 Nov 2010 14:54:48 +0000 (15:54 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 18 Nov 2010 14:54:48 +0000 (15:54 +0100)
redakcja/static/js/wiki/xslt.js

index 67216eb..af8cb56 100644 (file)
@@ -221,6 +221,11 @@ HTMLSerializer.prototype._pushTagEnd = function(tagName) {
 }
 
 HTMLSerializer.prototype._verseBefore = function(node) {
 }
 
 HTMLSerializer.prototype._verseBefore = function(node) {
+    /* true if previous element is a previous verse of a stanza */
+    var parent = node.parentNode;
+    if (!parent || !parent.hasAttribute('x-node') || parent.getAttribute('x-node') != 'strofa')
+        return false;
+
        var prev = node.previousSibling;
 
        while((prev !== null) && (prev.nodeType != ELEMENT_NODE)) {
        var prev = node.previousSibling;
 
        while((prev !== null) && (prev.nodeType != ELEMENT_NODE)) {
@@ -283,9 +288,12 @@ HTMLSerializer.prototype.serialize = function(rootElement, stripOuter)
                                        break;
                                }
 
                                        break;
                                }
 
-                               if(token.node.hasAttribute('x-verse') && self._verseBefore(token.node)) {
-                                       self.result += '/\n';
-                               };
+                if(token.node.hasAttribute('x-verse')) {
+                    if(self._verseBefore(token.node)) {
+                        self.result += '/';
+                    }
+                    self.result += '\n';
+                };
 
                                self._serializeElement(token.node);
                                break;
 
                                self._serializeElement(token.node);
                                break;