GWicke has uploaded a new change for review. https://gerrit.wikimedia.org/r/55899
Change subject: WIP/don't merge: Hack around mw:Placeholder newlines ...................................................................... WIP/don't merge: Hack around mw:Placeholder newlines This hack shifts many semantic issues in [[en:1993 NCAA Women's Division I Basketball Tournament]] to syntactic ones by using the placeholder as last source node. It is not a proper solution however. We should really get rid of mw:Placeholder for optional newlines. Change-Id: I4eba101b1b9a41529cbc87375b727fb9d2649e93 --- M js/lib/mediawiki.WikitextSerializer.js M js/lib/pegTokenizer.pegjs.txt 2 files changed, 28 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid refs/changes/99/55899/1 diff --git a/js/lib/mediawiki.WikitextSerializer.js b/js/lib/mediawiki.WikitextSerializer.js index eac066b..703fd38 100644 --- a/js/lib/mediawiki.WikitextSerializer.js +++ b/js/lib/mediawiki.WikitextSerializer.js @@ -2595,9 +2595,35 @@ } } if (prevNode && prevNode.nodeType === prevNode.TEXT_NODE) { + var nextSibling = prevNode.nextSibling; + // First check if the text node is followed by one of our + // mw:Placeholder metas that encapsulate optional newlines (so + // that the paragraph wrapper has an easier time). If such a meta + // is there and has a dsr, use it instead of the text node. + if ( nextSibling && DU.isMarkerMeta(nextSibling, "mw:Placeholder") && + !nextSibling.nextSibling && + nextSibling.data && nextSibling.data.parsoid.dsr && + nextSibling.data.parsoid.dsr[1] !== null && + nextSibling.data.parsoid.dsr[1] - nextSibling.data.parsoid.dsr[0] === 1) + { + prevNode = nextSibling; + //prevNode = { + // nodeName: '#fakeelement', + // nodeType: prevNode.ELEMENT_NODE, + // data: { + // parsoid: { + // dsr: + // [ + // nextSibling.data.parsoid.dsr[0], + // nextSibling.data.parsoid.dsr[1], + // 0, 0 + // ] + // } + // } + //}; + } else if (!prevNode.nextSibling && // Check if this is the last child of a zero-width element, and use // that for dsr purposes instead. Typical case: text in p. - if (!prevNode.nextSibling && prevNode.parentNode && prevNode.parentNode !== node && prevNode.parentNode.data.parsoid.dsr && diff --git a/js/lib/pegTokenizer.pegjs.txt b/js/lib/pegTokenizer.pegjs.txt index a45fec1..7a2851a 100644 --- a/js/lib/pegTokenizer.pegjs.txt +++ b/js/lib/pegTokenizer.pegjs.txt @@ -2151,6 +2151,7 @@ if ( spc.length ) { // Encapsulate in meta, so that these don't trigger paragraphs, but // can still be round-tripped and (potentially) edited. + //return spc.join(''); return [ new SelfclosingTagTk('meta', [new KV('typeof', 'mw:Placeholder')], { -- To view, visit https://gerrit.wikimedia.org/r/55899 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4eba101b1b9a41529cbc87375b727fb9d2649e93 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/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