GWicke has uploaded a new change for review. https://gerrit.wikimedia.org/r/134953
Change subject: WIP: Insert newlines in pre serialization ...................................................................... WIP: Insert newlines in pre serialization This implements http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#html-fragment-serialization-algorithm It breaks a bunch of parser tests by duplicating newlines. Need to investigate why. Change-Id: Idd28ea56bf63ec1aa70b1dc1396197d41de50c70 --- M lib/XMLSerializer.js 1 file changed, 17 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/53/134953/1 diff --git a/lib/XMLSerializer.js b/lib/XMLSerializer.js index 803f460..a7d2fab 100644 --- a/lib/XMLSerializer.js +++ b/lib/XMLSerializer.js @@ -56,6 +56,14 @@ plaintext: true, noscript: true }; +// Elements that strip leading newlines +// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#html-fragment-serialization-algorithm +var newlineStrippingElements = { + pre: true, + textarea: true, + listing: true +}; + /** * Use only very few entities, encode everything else as numeric entity @@ -113,6 +121,15 @@ cb(child.data); } } else { + if (child && newlineStrippingElements[localName] + && child.nodeType === TEXT_NODE && /^\n/.test(child.data)) { + /* If current node is a pre, textarea, or listing element, + * and the first child node of the element, if any, is a + * Text node whose character data has as its first + * character a U+000A LINE FEED (LF) character, then + * append a U+000A LINE FEED (LF) character. */ + cb('\n'); + } while(child) { serializeToString(child, options, cb); child = child.nextSibling; -- To view, visit https://gerrit.wikimedia.org/r/134953 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idd28ea56bf63ec1aa70b1dc1396197d41de50c70 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: GWicke <gwi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits