From: Radek Czajka Date: Thu, 18 Nov 2010 14:54:48 +0000 (+0100) Subject: #951: verse-out-of-stanza issue X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/452e9a06fe01f0501893df257366689024b54492?ds=inline #951: verse-out-of-stanza issue --- diff --git a/redakcja/static/js/wiki/xslt.js b/redakcja/static/js/wiki/xslt.js index 67216eb9..af8cb564 100644 --- a/redakcja/static/js/wiki/xslt.js +++ b/redakcja/static/js/wiki/xslt.js @@ -221,6 +221,11 @@ HTMLSerializer.prototype._pushTagEnd = function(tagName) { } 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)) { @@ -283,9 +288,12 @@ HTMLSerializer.prototype.serialize = function(rootElement, stripOuter) 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;