Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/189525
Change subject: Fix + cleanup stripping of marker metas
......................................................................
Fix + cleanup stripping of marker metas
* No change in parser test results and the following tests
are good as well.
% echo "{{CinteMurarieProvinciaGrosseto}}" | node parse --wt2wt --prefix itwiki
{{CinteMurarieProvinciaGrosseto}}
% echo "{{compactTOC8|side=yes|seealso=yes}}" | node parse --wt2wt
{{compactTOC8|side=yes|seealso=yes}}
Change-Id: I9ab5fb37a988d63def8bf9ba24c05a79e27308a9
---
M lib/dom.cleanup.js
1 file changed, 12 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/25/189525/1
diff --git a/lib/dom.cleanup.js b/lib/dom.cleanup.js
index e22fe0e..5efee16 100644
--- a/lib/dom.cleanup.js
+++ b/lib/dom.cleanup.js
@@ -9,22 +9,20 @@
var nonTopLevelRE =
/(?:^|\s)mw:(StartTag|EndTag|TSRMarker|Transclusion)\/?[^\s]*/;
function stripMarkerMetas(rtTestMode, node, atTopLevel) {
- // Sometimes a non-tpl meta node might get the mw:Transclusion typeof
- // element attached to it. So, check the property to make sure it is not
- // of those metas before deleting it. Also check if the node has
data-mw, in
- // which case we also have to keep it, except if it's also a
mw:extension/ref/Marker
- // in which case it'll have data-mw but we have to remove the node.
- //
- // Ex: {{compactTOC8|side=yes|seealso=yes}} generates a
mw:PageProp/notoc meta
- // that gets the mw:Transclusion typeof attached to it. It is not okay
to
- // delete it!
var metaType = node.getAttribute("typeof");
+ if (!metaType) {
+ return true;
+ }
+
+ // Sometimes a non-tpl meta node might get the mw:Transclusion typeof
+ // element attached to it. So, check if the node has data-mw,
+ // in which case we also have to keep it, except if it's also a
mw:extension/ref/Marker
+ // in which case it'll have data-mw but we have to remove the node.
var metaTestRE = atTopLevel ? topLevelRE : nonTopLevelRE;
- if (metaType
- && ((metaTestRE.test(metaType) && !node.getAttribute("property")
- && (!DU.getNodeData(node).mw ||
metaType.match(/mw:Extension\/ref\/Marker/)))
- || (!rtTestMode && metaType ===
"mw:Placeholder/StrippedTag"))
- )
+ if ((!rtTestMode && metaType === "mw:Placeholder/StrippedTag")
+ || (metaTestRE.test(metaType) &&
+ (Object.keys(DU.getDataMw(node) || {}).length === 0 ||
+ metaType.match(/mw:Extension\/ref\/Marker/))))
{
var nextNode = node.nextSibling;
DU.deleteNode(node);
--
To view, visit https://gerrit.wikimedia.org/r/189525
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ab5fb37a988d63def8bf9ba24c05a79e27308a9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits