X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/1e25937af74b242ba942a4784726d6b41a505ed3..bcb522c4e4b570fb42b754d8b19dd8bd6bc87f18:/redakcja/static/js/wiki/xslt.js diff --git a/redakcja/static/js/wiki/xslt.js b/redakcja/static/js/wiki/xslt.js index 2bab378d..a5093b04 100644 --- a/redakcja/static/js/wiki/xslt.js +++ b/redakcja/static/js/wiki/xslt.js @@ -288,7 +288,11 @@ HTMLSerializer.prototype.serialize = function(rootElement, stripOuter) self._serializeElement(token.node); break; case TEXT_NODE: - self.result += token.node.nodeValue; + // collapse previous element's padding + var i = 0; + while (token.node.nodeValue[i] == '\n' && self.result[self.result.length - 1] == '\n') + i ++; + self.result += token.node.nodeValue.substr(i); break; }; }; @@ -372,7 +376,9 @@ HTMLSerializer.prototype._serializeElement = function(node) { }; /* print out */ - if (getPadding(tagName)) + + // at least one newline before padded elements + if (getPadding(tagName) && self.result[self.result.length - 1] != '\n') self.result += '\n'; self.result += '<' + tagName;