Arlolra has uploaded a new change for review. https://gerrit.wikimedia.org/r/314595
Change subject: Stop asserting that we'll never be encapsulating a flipped range ...................................................................... Stop asserting that we'll never be encapsulating a flipped range * Follow up to 8976ab9, where the story isn't exactly right. * Avoids triggering the assertion in, /es.wikipedia.org/v3/page/html/LĂnea_B_(Subte_de_Buenos_Aires)/91283888 * The conclusion of the long comment in the patch is that we need to either, 1) Fix up encapsulateTemplates() to handle flipped ranges in the really edgy case they occur, 2) Or, emit foster boxes even in transclusion, since they may be fostering their own closing meta. Try, {{1x|<table><div>}} * Of course, this is all very broken wikitext, https://es.wikipedia.org/w/index.php?title=L%C3%ADnea_B_%28Subte_de_Buenos_Aires%29&type=revision&diff=91283888&oldid=91283810 Bug: T141905 Change-Id: Ib963191c4b47205ffda711570a38302d3140c6ca --- M lib/wt2html/pp/processors/wrapTemplates.js 1 file changed, 42 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/95/314595/1 diff --git a/lib/wt2html/pp/processors/wrapTemplates.js b/lib/wt2html/pp/processors/wrapTemplates.js index 68db119..a105ce6 100644 --- a/lib/wt2html/pp/processors/wrapTemplates.js +++ b/lib/wt2html/pp/processors/wrapTemplates.js @@ -604,12 +604,49 @@ for (var i = 0; i < numRanges; i++) { var range = tplRanges[i]; - expandRangeToAvoidSpanWrapping(range); + // We should never have flipped overlapping ranges, and indeed that's + // asserted in `findTopLevelNonOverlappingRanges`. Flipping results + // in either completely nested ranges, or non-intersecting ranges. + // + // If the table causing the fostering is not transcluded, we emit a + // foster box and wrap the whole table+fb in metas, producing nested + // ranges. For ex, + // + // <table> + // {{1x|<div>}} + // + // The tricky part is when the table *is* transcluded, and we omit the + // foster box. The common case (for some definition of common) might + // be like, + // + // {{1x|<table>}} + // {{1x|<div>}} + // + // Here, #mwt1 leaves a table open and the end meta from #mwt2 is + // fostered, since it gets closed into the div. The range for #mwt1 + // is the entire table, which thankfully contains #mwt2, so we still + // have the expected entire neseting. Any tricks to extend the range + // of #mwt2 beyond the table so that we have an overlapping range will + // ineviatbly result in the end meta not being fostered, and we avoid + // this situation altogether. + // + // The very edgy case is as follows, + // + // {{1x|<table><div>}}</div> + // {{1x|<div>}} + // + // where both end metas are fostered. Ignoring that we don't even + // roundtrip the first transclusion properly on its own, here we have + // a flipped range where, since the end meta for the first range was + // also fostered, the ranges still don't overlap. - // If transcluded content ends up in the foster box, we wrap the whole - // table+fb in metas, so `findTopLevelNonOverlappingRanges` should - // only produce non-flipped ranges. - console.assert(!range.flipped, 'Encapsulating a flipped range.'); + if (range.flipped) { + // FIXME: The code below needs to be aware of flipped ranges. + env.log('warning/template', + 'Encapsulating a flipped range: ' + range.id); + } + + expandRangeToAvoidSpanWrapping(range); var n = range.start; var e = range.end; -- To view, visit https://gerrit.wikimedia.org/r/314595 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib963191c4b47205ffda711570a38302d3140c6ca Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Arlolra <abrea...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits