Subramanya Sastry has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/382729 )
Change subject: Useless p-wrapper stripping shouldn't get tripped by tpl meta
tags
......................................................................
Useless p-wrapper stripping shouldn't get tripped by tpl meta tags
* The void tag check was too broad and was trapping tpl-meta-end
tags causing p-wrappers to be left behind around </span> tags
which caused them to get stripped and extended the open <span>
tag's range beyond its original place.
* Added a parser test to capture this expectation
Bug: T177612
Change-Id: I58dd86da1329744f069722204fcefd8e1c8f10df
---
M lib/utils/Util.js
M lib/wt2html/tt/ParagraphWrapper.js
M tests/parserTests.txt
3 files changed, 18 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/29/382729/1
diff --git a/lib/utils/Util.js b/lib/utils/Util.js
index acfa500..1de607f 100644
--- a/lib/utils/Util.js
+++ b/lib/utils/Util.js
@@ -472,6 +472,11 @@
return token && token.constructor === pd.SelfclosingTagTk &&
token.name === 'template';
},
+ isTemplateMeta: function(t) {
+ if (!DU) { DU = require('./DOMUtils.js').DOMUtils; }
+ return t.name === 'meta' &&
DU.TPL_META_TYPE_REGEXP.test(t.getAttribute('typeof'));
+ },
+
isTableTag: function(token) {
var tc = token.constructor;
return (tc === pd.TagTk || tc === pd.EndTagTk) &&
diff --git a/lib/wt2html/tt/ParagraphWrapper.js
b/lib/wt2html/tt/ParagraphWrapper.js
index 7170cdd..af24c3b 100644
--- a/lib/wt2html/tt/ParagraphWrapper.js
+++ b/lib/wt2html/tt/ParagraphWrapper.js
@@ -108,9 +108,9 @@
// Comments and inline tags by themselves don't need
them.
// NOTE: We don't check for block tags since p-tags
won't wrap block tags.
if (t.constructor === String ||
- Util.isVoidElement(t.name || '') ||
+ (Util.isVoidElement(t.name || '') &&
!Util.isTemplateMeta(t)) ||
// FIXME: do we need a more precise test?
- /\bmw:/.test(t.constructor === TagTk ?
t.getAttribute('typeof') : null)
+ Util.hasParsoidTypeOf(t.constructor === TagTk
&& t.getAttribute('typeof'))
) {
return start;
}
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index df4e9c3..7cff659 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -1928,6 +1928,17 @@
<small><em></em></small><span><s><div>x</div></s></span>
!! end
+# T177612: Parsoid-only test
+!! test
+Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping
code
+!! wikitext
+{{echo|<span><div>x</div></span>}}
+x
+!! html/parsoid
+<span about="#mwt1" typeof="mw:Transclusion"
data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}'
data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<span><div>x</div></span>"}},"i":0}}]}'><div>x</div></span>
+<p>x</p>
+!! end
+
!! test
Block tag on one line (<blockquote>)
!! wikitext
--
To view, visit https://gerrit.wikimedia.org/r/382729
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I58dd86da1329744f069722204fcefd8e1c8f10df
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