Marcoil has uploaded a new change for review. https://gerrit.wikimedia.org/r/189748
Change subject: T72582: Change how LST <section>s are output ...................................................................... T72582: Change how LST <section>s are output Change-Id: Ie6f0eabdac71aed50e32e9efead5d9f00da1b570 --- M lib/ext.core.Sanitizer.js M lib/mediawiki.WikitextSerializer.js M tests/parserTests.txt 3 files changed, 46 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/48/189748/1 diff --git a/lib/ext.core.Sanitizer.js b/lib/ext.core.Sanitizer.js index 5bf9f82..6882181 100644 --- a/lib/ext.core.Sanitizer.js +++ b/lib/ext.core.Sanitizer.js @@ -736,8 +736,23 @@ // Special handling for wikisource: hide section tags for now // TODO: Properly handle this. See // https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST - token = new SelfclosingTagTk('meta', - [{k: 'typeof', v: 'mw:Placeholder'}], + var sectionType = 'mw:Extension/LabeledSectionTransclusion', + sectionAttribs = []; + origToken.attribs.forEach(function (a) { + var content; + if (a.k === 'begin') { + sectionType += '/begin'; + content = a.v; + } else if (a.k === 'end') { + sectionType += '/end'; + content = a.v; + } + if (content) { + sectionAttribs.push({k: 'content', v: content}); + } + }); + sectionAttribs = [{k: 'typeof', v: sectionType}].concat(sectionAttribs); + token = new SelfclosingTagTk('meta', sectionAttribs, { src: token, tsr: origToken.tsr diff --git a/lib/mediawiki.WikitextSerializer.js b/lib/mediawiki.WikitextSerializer.js index a4f6049..030ba6d 100644 --- a/lib/mediawiki.WikitextSerializer.js +++ b/lib/mediawiki.WikitextSerializer.js @@ -601,6 +601,19 @@ } } else if (/(?:^|\s)mw:Param(?=$|\s)/.test(typeOf)) { src = dp.src; + } else if (/(?:^|\s)mw:Extension\/LabeledSectionTransclusion/.test(typeOf)) { + // FIXME: Special case for <section> until LST is implemented + // natively in Parsoid + if (dp.src) { + src = dp.src; + } else if (typeOf.match('begin')) { + src = '<section begin="' + node.getAttribute('content') + '" />'; + } else if (typeOf.match('end')) { + src = '<section end="' + node.getAttribute('content') + '" />'; + } else { + self.env.log("error", "LST <section> without content in: " + node.outerHTML); + src = '<section />'; + } } else if (/(?:^|\s)mw:Extension\//.test(typeOf)) { dataMW = DU.getDataMw(node); if (dataMW.name) { diff --git a/tests/parserTests.txt b/tests/parserTests.txt index cbd569f..f70ba2f 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -20103,6 +20103,22 @@ foo<ol class="references" typeof="mw:Extension/references" about="#mwt2" data-mw='{"name":"references","attrs":{}}'></ol> !! end +#### ---------------------------------------------------------------- +#### Parsoid-only testing of Parsoid's impl of LST +#### Not implemented yet, see +#### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST +#### ---------------------------------------------------------------- + +!!test +LST Sections: 1. Simple section start and end +!! wikitext +<section begin="2011-05-16" /> +<section end="2014-04-10 (MW 1.23wmf22)" /> +!! html/parsoid +<p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/> +<meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p> +!! end + #--------- Test stripping of empty nodes in template content ---------- !!test Empty LI and TR nodes should be stripped from template content -- To view, visit https://gerrit.wikimedia.org/r/189748 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie6f0eabdac71aed50e32e9efead5d9f00da1b570 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Marcoil <marc...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits