Marcoil has uploaded a new change for review.
https://gerrit.wikimedia.org/r/191585
Change subject: Don't remove data-parsoid from inside <references /> text
......................................................................
Don't remove data-parsoid from inside <references /> text
In preparation of T88290. This patch fixes removing data-parsoid
from inside transcluded nodes with stx set. Previously, we only
checked if a node had stx itself, but that should also apply to
its children. This patch marks text coming from a <ref> with stx so
that data-parsoid for it and its children don't disappear inside
<references />. This will be more necessary when T88290 removes all
other <ref> HTML but the one inside <references />.
Change blacklist to reflect the new output.
Change-Id: I682316b53dba90d2e86bc1669407d058fdd6edc2
---
M lib/dom.cleanUpTemplates.js
M lib/ext.Cite.js
M lib/mediawiki.DOMUtils.js
M tests/parserTests-blacklist.js
4 files changed, 27 insertions(+), 17 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/85/191585/1
diff --git a/lib/dom.cleanUpTemplates.js b/lib/dom.cleanUpTemplates.js
index 26bdbd2..82469c7 100644
--- a/lib/dom.cleanUpTemplates.js
+++ b/lib/dom.cleanUpTemplates.js
@@ -23,8 +23,12 @@
// content model the text came from to emit the right newline
separators.
// For example, both "a\n\nb" and "<p>a</p><p>b/p>" both
generate
// identical html but serialize to different wikitext.
- var dp = DU.getDataParsoid(node);
- if (!dp.stx) {
+ var dp = DU.getJSONAttribute(node, 'data-parsoid', {});
+ if (dp.stx) {
+ tplInfo.inStx = true;
+ }
+ // Even when in stx, we can remove dp if it's completely empty
+ if (!tplInfo.inStx || Object.keys(dp).length === 0) {
node.removeAttribute('data-parsoid');
}
}
diff --git a/lib/ext.Cite.js b/lib/ext.Cite.js
index 2eaee36..2584a56 100644
--- a/lib/ext.Cite.js
+++ b/lib/ext.Cite.js
@@ -218,6 +218,10 @@
'id': ref.target
});
li.innerHTML = ref.content;
+ // Mark as coming from a ref so it doesn't get stripped
+ // TODO: Instead of marking the <li>, mark just the HTML that comes
from the
+ // ref.
+ DU.getDataParsoid(li).stx = 'ref';
var contentNode = li.firstChild;
diff --git a/lib/mediawiki.DOMUtils.js b/lib/mediawiki.DOMUtils.js
index 81985fc..cb6ecd1 100644
--- a/lib/mediawiki.DOMUtils.js
+++ b/lib/mediawiki.DOMUtils.js
@@ -850,16 +850,18 @@
};
}
- // Process subtree first
- this.traverseTplOrExtNodes(cb, c, env, options,
atTopLevel, tplInfo);
-
if (tplInfo) {
cb(c, tplInfo, options);
+ }
- // Clear tpl info
- if (c === tplInfo.last || tplInfo.done)
{
- tplInfo = null;
- }
+ if (!(tplInfo && (tplInfo.done ||
tplInfo.next))) {
+ // If not done, process subtree
+ this.traverseTplOrExtNodes(cb, c, env,
options, atTopLevel, tplInfo);
+ }
+
+ if (tplInfo && (tplInfo.last === c ||
tplInfo.done)) {
+ // Clear tplInfo
+ tplInfo = null;
}
}
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index 2814a77..ff4cee3 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -121,7 +121,7 @@
add("wt2html", "Templates: HTML Tag: 3. Generation of HTML attr key and
value", "<div style=\"'color:red;'\" about=\"#mwt3\"
typeof=\"mw:ExpandedAttrs\"
data-parsoid='{\"stx\":\"html\",\"a\":{\"style\":\"'color:red;'\"},\"sa\":{\"style\":\"{{echo|'color:red;'}}\"},\"dsr\":[0,51,42,6]}'
data-mw='{\"attribs\":[[{\"txt\":\"style\",\"html\":\"<span
about=\\\"#mwt2\\\" typeof=\\\"mw:Transclusion\\\"
data-parsoid=\\\"{&quot;pi&quot;:[[{&quot;k&quot;:&quot;1&quot;,&quot;spc&quot;:[&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]}]],&quot;dsr&quot;:[5,19,null,null]}\\\"
data-mw=\\\"{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;style&quot;}},&quot;i&quot;:0}}]}\\\">style</span>\"},{\"html\":\"<span
about=\\\"#mwt1\\\" typeof=\\\"mw:Transclusion\\\"
data-parsoid=\\\"{&quot;pi&quot;:[[{&quot;k&quot;:&quot;1&quot;,&quot;spc&quot;:[&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]}]],&quot;dsr&quot;:[20,41,null,null]}\\\"
data-mw=\\\"{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;'color:red;'&quot;}},&quot;i&quot;:0}}]}\\\">'color:red;'</span>\"}]]}'>foo</div>");
add("wt2html", "Templates: Wiki Tables: 1a. Fostering of entire template
content", "<p about=\"#mwt2\" typeof=\"mw:Transclusion\"
data-parsoid='{\"fostered\":true,\"autoInsertedEnd\":true,\"dsr\":[0,16,null,null],\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]]}'
data-mw='{\"parts\":[\"{|\\n\",{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"a\"}},\"i\":0}},\"\\n|}\"]}'>a</p><table
about=\"#mwt2\">\n\n</table>");
add("wt2html", "Templates: Wiki Tables: 1b. Fostering of entire template
content", "<div about=\"#mwt3\" typeof=\"mw:Transclusion\"
data-parsoid='{\"stx\":\"html\",\"fostered\":true,\"autoInsertedEnd\":true,\"dsr\":[0,40,null,null],\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}],[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]]}'
data-mw='{\"parts\":[\"{|\\n\",{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"<div>\"}},\"i\":0}},\"\\nfoo\\n\",{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"</div>\"}},\"i\":1}},\"\\n|}\"]}'>\n<p>foo</p>\n</div><table
about=\"#mwt3\">\n\n</table>");
-add("wt2html", "Templates: Wiki Tables: 2. Fostering of partial template
content", "<p about=\"#mwt2\" typeof=\"mw:Transclusion\"
data-parsoid='{\"fostered\":true,\"autoInsertedEnd\":true,\"dsr\":[0,29,null,null],\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]]}'
data-mw='{\"parts\":[\"{|\\n\",{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"a\\n<div>b</div>\"}},\"i\":0}},\"\\n|}\"]}'>a</p><div
about=\"#mwt2\"
data-parsoid='{\"stx\":\"html\",\"fostered\":true,\"autoInsertedEnd\":true,\"dsr\":[0,0]}'>b</div><table
about=\"#mwt2\">\n\n\n</table>");
+add("wt2html", "Templates: Wiki Tables: 2. Fostering of partial template
content", "<p about=\"#mwt2\" typeof=\"mw:Transclusion\"
data-parsoid='{\"fostered\":true,\"autoInsertedEnd\":true,\"dsr\":[0,29,null,null],\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]]}'
data-mw='{\"parts\":[\"{|\\n\",{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"a\\n<div>b</div>\"}},\"i\":0}},\"\\n|}\"]}'>a</p><div
about=\"#mwt2\"
data-parsoid='{\"stx\":\"html\",\"fostered\":true,\"autoInsertedEnd\":true,\"dsr\":[0,0]}'>b</div><table
about=\"#mwt2\" data-parsoid='{\"dsr\":[0,29,2,2]}'>\n\n\n</table>");
add("wt2html", "Templates: Wiki Tables: 4. Templated tags, no content",
"<table about=\"#mwt1\" typeof=\"mw:Transclusion\"
data-parsoid='{\"dsr\":[0,25,null,null],\"pi\":[[],[]]}'
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"tbl-start\",\"href\":\"./Template:Tbl-start\"},\"params\":{},\"i\":0}},\"\\n\",{\"template\":{\"target\":{\"wt\":\"tbl-end\",\"href\":\"./Template:Tbl-end\"},\"params\":{},\"i\":1}}]}'>\n</table>");
add("wt2html", "Templates: Lists: Multi-line list-items via templates", "<ul
data-parsoid='{\"dsr\":[0,71,0,0]}'><li
data-parsoid='{\"dsr\":[0,35,1,0]}'><span about=\"#mwt1\"
typeof=\"mw:Transclusion\"
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[1,35,null,null]}'
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"a
{{nonexistent|\\nunused}}\"}},\"i\":0}}]}'>a </span><span
typeof=\"mw:Placeholder\" about=\"#mwt1\" id=\"mwt2\">Warning: Page/template
fetching disabled, and no cache for Template:Nonexistent</span></li>\n<li
data-parsoid='{\"dsr\":[36,71,1,0]}'><span about=\"#mwt3\"
typeof=\"mw:Transclusion\"
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[37,71,null,null]}'
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"b
{{nonexistent|\\nunused}}\"}},\"i\":0}}]}'>b </span><span
typeof=\"mw:Placeholder\" about=\"#mwt3\" id=\"mwt4\">Warning: Page/template
fetching disabled, and no cache for Template:Nonexistent</span></li></ul>");
add("wt2html", "Templates: Ugly nesting: 1. Quotes opened/closed across
templates (echo)", "<p data-parsoid='{\"dsr\":[0,40,0,0]}'><i about=\"#mwt1\"
typeof=\"mw:Transclusion\"
data-parsoid='{\"dsr\":[0,40,null,null],\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}],[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}],[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]]}'
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"''a\"}},\"i\":0}},{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"b''c''d\"}},\"i\":1}},{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"''e\"}},\"i\":2}}]}'>ab</i><span
about=\"#mwt1\">c</span><i about=\"#mwt1\">d</i><span
about=\"#mwt1\">e</span></p>");
@@ -880,13 +880,13 @@
add("html2html", "Gallery override link with malicious javascript (bug
34852)", "<p data-parsoid='{\"dsr\":[0,4,0,0]}'>\t\t* </p><div style=\"width:
155px\" data-parsoid='{\"stx\":\"html\",\"dsr\":[4,239,26,6]}'>\n\t\t\t<div
class=\"thumb\" style=\"width: 150px;\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[34,182,41,6]}'><div
style=\"margin:68px auto;\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[75,176,31,6]}'><img
src=\"http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg\"
alt=\"120px-Foobar.jpg\" rel=\"mw:externalImage\"
data-parsoid='{\"dsr\":[106,170,null,null]}'/></div></div>\n\t\t\t<div
class=\"gallerytext\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[186,230,25,6]}'>\n<p
data-parsoid='{\"dsr\":[212,219,0,0]}'>caption</p>\n\n\t\t\t</div>\n\t\t</div>\n");
add("html2html", "Gallery with invalid title as link (bug 43964)", "<p
data-parsoid='{\"dsr\":[0,4,0,0]}'>\t\t* </p><div style=\"width: 155px\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[4,229,26,6]}'>\n\t\t\t<div
class=\"thumb\" style=\"width: 150px;\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[34,182,41,6]}'><div
style=\"margin:68px auto;\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[75,176,31,6]}'><img
src=\"http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg\"
alt=\"120px-Foobar.jpg\" rel=\"mw:externalImage\"
data-parsoid='{\"dsr\":[106,170,null,null]}'/></div></div>\n\t\t\t<div
class=\"gallerytext\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[186,220,25,6]}'>\t\t\t</div>\n\t\t</div>\n");
add("html2html", "Disable TOC", "<p
data-parsoid='{\"dsr\":[0,4,0,0]}'>Lead</p>\n\n<h2
data-parsoid='{\"dsr\":[6,252,2,2]}'> <span class=\"mw-headline\"
id=\"Section_1\" data-parsoid='{\"stx\":\"html\",\"dsr\":[9,66,41,7]}'>Section
1</span><span class=\"mw-editsection\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[66,249,29,7]}'><span
class=\"mw-editsection-bracket\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[95,140,37,7]}'>[</span>[/index.php?title=Parser_test&action=edit&section=1
edit]<span class=\"mw-editsection-bracket\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[197,242,37,7]}'>]</span></span>
</h2>\n\n<h2 data-parsoid='{\"dsr\":[254,500,2,2]}'> <span
class=\"mw-headline\" id=\"Section_2\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[257,314,41,7]}'>Section 2</span><span
class=\"mw-editsection\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[314,497,29,7]}'><span
class=\"mw-editsection-bracket\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[343,388,37,7]}'>[</span>[/index.php?title=Parser_test&action=edit&section=2
edit]<span class=\"mw-editsection-bracket\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[445,490,37,7]}'>]</span></span>
</h2>\n\n<h2 data-parsoid='{\"dsr\":[502,748,2,2]}'> <span
class=\"mw-headline\" id=\"Section_3\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[505,562,41,7]}'>Section 3</span><span
class=\"mw-editsection\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[562,745,29,7]}'><span
class=\"mw-editsection-bracket\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[591,636,37,7]}'>[</span>[/index.php?title=Parser_test&action=edit&section=3
edit]<span class=\"mw-editsection-bracket\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[693,738,37,7]}'>]</span></span>
</h2>\n\n<h2 data-parsoid='{\"dsr\":[750,996,2,2]}'> <span
class=\"mw-headline\" id=\"Section_4\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[753,810,41,7]}'>Section 4</span><span
class=\"mw-editsection\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[810,993,29,7]}'><span
class=\"mw-editsection-bracket\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[839,884,37,7]}'>[</span>[/index.php?title=Parser_test&action=edit&section=4
edit]<span class=\"mw-editsection-bracket\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[941,986,37,7]}'>]</span></span>
</h2>\n\n<h2 data-parsoid='{\"dsr\":[998,1244,2,2]}'> <span
class=\"mw-headline\" id=\"Section_5\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[1001,1058,41,7]}'>Section
5</span><span class=\"mw-editsection\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[1058,1241,29,7]}'><span
class=\"mw-editsection-bracket\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[1087,1132,37,7]}'>[</span>[/index.php?title=Parser_test&action=edit&section=5
edit]<span class=\"mw-editsection-bracket\"
data-parsoid='{\"stx\":\"html\",\"dsr\":[1189,1234,37,7]}'>]</span></span>
</h2>\n");
-add("html2html", "Ref: 5. body should accept generic wikitext", "<p
data-parsoid='{\"dsr\":[0,81,0,0]}'>A <span about=\"#mwt2\" class=\"reference\"
id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[2,81,5,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"This is a <b
data-parsoid='{\\\"dsr\\\":[17,38,3,3]}'><a rel=\\\"mw:WikiLink\\\"
href=\\\"./Bolded_link\\\" title=\\\"Bolded link\\\"
data-parsoid='{\\\"stx\\\":\\\"simple\\\",\\\"a\\\":{\\\"href\\\":\\\"./Bolded_link\\\"},\\\"sa\\\":{\\\"href\\\":\\\"bolded
link\\\"},\\\"dsr\\\":[20,35,2,2]}'>bolded link</a></b> and this is
a <span about=\\\"#mwt3\\\" typeof=\\\"mw:Transclusion\\\"
data-parsoid='{\\\"pi\\\":[[{\\\"k\\\":\\\"1\\\",\\\"spc\\\":[\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\"]}]],\\\"dsr\\\":[53,74,null,null]}'
data-mw='{\\\"parts\\\":[{\\\"template\\\":{\\\"target\\\":{\\\"wt\\\":\\\"echo\\\",\\\"href\\\":\\\"./Template:Echo\\\"},\\\"params\\\":{\\\"1\\\":{\\\"wt\\\":\\\"transclusion\\\"}},\\\"i\\\":0}}]}'>transclusion</span>\\n\"},\"attrs\":{}}'><a
href=\"#cite_note-1\">[1]</a></span></p>\n\n<ol class=\"references\"
typeof=\"mw:Extension/references\" about=\"#mwt5\"
data-parsoid='{\"dsr\":[83,97,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li about=\"#cite_note-1\"
id=\"cite_note-1\"><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-1\">↑</a></span> This is a <b><a rel=\"mw:WikiLink\"
href=\"./Bolded_link\" title=\"Bolded link\"
data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Bolded_link\"},\"sa\":{\"href\":\"bolded
link\"},\"dsr\":[20,35,2,2]}'>bolded link</a></b> and this is a <span
about=\"#mwt3\" typeof=\"mw:Transclusion\"
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[53,74,null,null]}'
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"transclusion\"}},\"i\":0}}]}'>transclusion</span>\n</li></ol>");
-add("html2html", "Ref: 7. No p-wrapping in ref-body", "<p
data-parsoid='{\"dsr\":[0,30,0,0]}'>A <span about=\"#mwt2\" class=\"reference\"
id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[2,30,5,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"foo\\nbar\\nbaz\\nbooz\\n\"},\"attrs\":{}}'><a
href=\"#cite_note-1\">[1]</a></span></p>\n\n<ol class=\"references\"
typeof=\"mw:Extension/references\" about=\"#mwt4\"
data-parsoid='{\"dsr\":[32,46,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li about=\"#cite_note-1\"
id=\"cite_note-1\"><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-1\">↑</a></span> foo\nbar\nbaz\nbooz\n</li></ol>");
-add("html2html", "Ref: 8. transclusion wikitext has lower precedence", "<p
data-parsoid='{\"dsr\":[0,47,0,0]}'>A <span about=\"#mwt2\" class=\"reference\"
id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[2,24,5,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"foo <span
typeof=\\\"mw:Nowiki\\\"
data-parsoid='{\\\"src\\\":\\\"{{\\\",\\\"dsr\\\":[11,13,0,0]}'>{{</span>echo|\"},\"attrs\":{}}'><a
href=\"#cite_note-1\">[1]</a></span> B C<span typeof=\"mw:Nowiki\"
data-parsoid='{\"dsr\":[28,47,8,9]}'>}}</span></p>\n<ol class=\"references\"
typeof=\"mw:Extension/references\" about=\"#mwt4\"
data-parsoid='{\"dsr\":[48,62,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li about=\"#cite_note-1\"
id=\"cite_note-1\"><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-1\">↑</a></span> foo <span
typeof=\"mw:Nowiki\">{{</span>echo|</li></ol>");
-add("html2html", "Ref: 10. Unclosed HTML tags should not leak out of
ref-body", "<p data-parsoid='{\"dsr\":[0,25,0,0]}'>A <span about=\"#mwt2\"
class=\"reference\" id=\"cite_ref-1\" rel=\"dc:references\"
typeof=\"mw:Extension/ref\" data-parsoid='{\"dsr\":[2,21,5,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"<b
data-parsoid='{\\\"stx\\\":\\\"html\\\",\\\"autoInsertedEnd\\\":true,\\\"dsr\\\":[7,15,3,0]}'>
foo </b>\"},\"attrs\":{}}'><a href=\"#cite_note-1\">[1]</a></span> B
C</p>\n\n<ol class=\"references\" typeof=\"mw:Extension/references\"
about=\"#mwt4\" data-parsoid='{\"dsr\":[27,41,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li about=\"#cite_note-1\"
id=\"cite_note-1\"><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-1\">↑</a></span> <b
data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[7,15,3,0]}'>
foo </b></li></ol>");
-add("html2html", "Ref: 19. ref-tags with identical name encodings should get
identical indexes", "<p data-parsoid='{\"dsr\":[0,60,0,0]}'>1 <span
about=\"#mwt3\" class=\"reference\" id=\"cite_ref-a_.26_b_1-0\"
rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[2,29,18,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"foo\"},\"attrs\":{\"name\":\"a
& b\"}}'><a href=\"#cite_note-a_.26_b-1\">[1]</a></span> 2 <span
about=\"#mwt4\" class=\"reference\" id=\"cite_ref-a_.26amp.3B_b_2-0\"
rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[32,60,28,0]}'
data-mw='{\"name\":\"ref\",\"attrs\":{\"name\":\"a &amp;amp; b\"}}'><a
href=\"#cite_note-a_.26amp.3B_b-2\">[2]</a></span></p>\n\n<ol
class=\"references\" typeof=\"mw:Extension/references\" about=\"#mwt6\"
data-parsoid='{\"dsr\":[62,76,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li
about=\"#cite_note-a_.26_b-1\" id=\"cite_note-a_.26_b-1\"><span
rel=\"mw:referencedBy\"><a href=\"#cite_ref-a_.26_b_1-0\">↑</a></span>
foo</li><li about=\"#cite_note-a_.26amp.3B_b-2\"
id=\"cite_note-a_.26amp.3B_b-2\"><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-a_.26amp.3B_b_2-0\">↑</a></span> </li></ol>");
-add("html2html", "References: 5. ref tags in references should be processed
while ignoring all other content", "<p data-parsoid='{\"dsr\":[0,44,0,0]}'>A
<span about=\"#mwt2\" class=\"reference\" id=\"cite_ref-a_1-0\"
rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[2,18,16,0]}'
data-mw='{\"name\":\"ref\",\"attrs\":{\"name\":\"a\"}}'><a
href=\"#cite_note-a-1\">[1]</a></span>\nB <span about=\"#mwt4\"
class=\"reference\" id=\"cite_ref-b_2-0\" rel=\"dc:references\"
typeof=\"mw:Extension/ref\" data-parsoid='{\"dsr\":[21,44,14,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"bar\"},\"attrs\":{\"name\":\"b\"}}'><a
href=\"#cite_note-b-2\">[2]</a></span></p>\n\n<ol class=\"references\"
typeof=\"mw:Extension/references\" about=\"#mwt6\"
data-parsoid='{\"dsr\":[46,96,2,2]}'
data-mw='{\"name\":\"references\",\"body\":{\"extsrc\":\"<ref
name=\\\"a\\\">foo</ref>\",\"html\":\"\\n<span about=\\\"#mwt8\\\"
class=\\\"reference\\\" rel=\\\"dc:references\\\"
typeof=\\\"mw:Extension/ref\\\" data-parsoid='{\\\"src\\\":\\\"&lt;ref
name=\\\\\\\"a\\\\\\\">foo&lt;/ref>\\\",\\\"dsr\\\":[59,82,14,6]}'
data-mw='{\\\"name\\\":\\\"ref\\\",\\\"body\\\":{\\\"html\\\":\\\"foo\\\"},\\\"attrs\\\":{\\\"name\\\":\\\"a\\\"}}'><a
href=\\\"#cite_note-a-1\\\">[1]</a></span>\\n\"},\"attrs\":{}}'><li
about=\"#cite_note-a-1\" id=\"cite_note-a-1\"><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-a_1-0\">↑</a></span> foo</li><li about=\"#cite_note-b-2\"
id=\"cite_note-b-2\"><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-b_2-0\">↑</a></span> bar</li></ol>");
-add("html2html", "Entities in ref name", "<p
data-parsoid='{\"dsr\":[0,38,0,0]}'><span about=\"#mwt2\" class=\"reference\"
id=\"cite_ref-test_.26amp.3B_me_1-0\" rel=\"dc:references\"
typeof=\"mw:Extension/ref\" data-parsoid='{\"dsr\":[0,38,30,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"hi\"},\"attrs\":{\"name\":\"test
&amp;amp; me\"}}'><a
href=\"#cite_note-test_.26amp.3B_me-1\">[1]</a></span></p>\n<ol
class=\"references\" typeof=\"mw:Extension/references\" about=\"#mwt4\"
data-parsoid='{\"dsr\":[39,53,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li
about=\"#cite_note-test_.26amp.3B_me-1\"
id=\"cite_note-test_.26amp.3B_me-1\"><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-test_.26amp.3B_me_1-0\">↑</a></span> hi</li></ol>");
+add("html2html", "Ref: 5. body should accept generic wikitext", "<p
data-parsoid='{\"dsr\":[0,81,0,0]}'>A <span about=\"#mwt2\" class=\"reference\"
id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[2,81,5,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"This is a <b
data-parsoid='{\\\"dsr\\\":[17,38,3,3]}'><a rel=\\\"mw:WikiLink\\\"
href=\\\"./Bolded_link\\\" title=\\\"Bolded link\\\"
data-parsoid='{\\\"stx\\\":\\\"simple\\\",\\\"a\\\":{\\\"href\\\":\\\"./Bolded_link\\\"},\\\"sa\\\":{\\\"href\\\":\\\"bolded
link\\\"},\\\"dsr\\\":[20,35,2,2]}'>bolded link</a></b> and this is
a <span about=\\\"#mwt3\\\" typeof=\\\"mw:Transclusion\\\"
data-parsoid='{\\\"pi\\\":[[{\\\"k\\\":\\\"1\\\",\\\"spc\\\":[\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\"]}]],\\\"dsr\\\":[53,74,null,null]}'
data-mw='{\\\"parts\\\":[{\\\"template\\\":{\\\"target\\\":{\\\"wt\\\":\\\"echo\\\",\\\"href\\\":\\\"./Template:Echo\\\"},\\\"params\\\":{\\\"1\\\":{\\\"wt\\\":\\\"transclusion\\\"}},\\\"i\\\":0}}]}'>transclusion</span>\\n\"},\"attrs\":{}}'><a
href=\"#cite_note-1\">[1]</a></span></p>\n\n<ol class=\"references\"
typeof=\"mw:Extension/references\" about=\"#mwt5\"
data-parsoid='{\"dsr\":[83,97,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li about=\"#cite_note-1\"
id=\"cite_note-1\" data-parsoid='{\"stx\":\"ref\"}'><span
rel=\"mw:referencedBy\"><a href=\"#cite_ref-1\">↑</a></span> This is a <b
data-parsoid='{\"dsr\":[17,38,3,3]}'><a rel=\"mw:WikiLink\"
href=\"./Bolded_link\" title=\"Bolded link\"
data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Bolded_link\"},\"sa\":{\"href\":\"bolded
link\"},\"dsr\":[20,35,2,2]}'>bolded link</a></b> and this is a <span
about=\"#mwt3\" typeof=\"mw:Transclusion\"
data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[53,74,null,null]}'
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"transclusion\"}},\"i\":0}}]}'>transclusion</span>\n</li></ol>");
+add("html2html", "Ref: 7. No p-wrapping in ref-body", "<p
data-parsoid='{\"dsr\":[0,30,0,0]}'>A <span about=\"#mwt2\" class=\"reference\"
id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[2,30,5,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"foo\\nbar\\nbaz\\nbooz\\n\"},\"attrs\":{}}'><a
href=\"#cite_note-1\">[1]</a></span></p>\n\n<ol class=\"references\"
typeof=\"mw:Extension/references\" about=\"#mwt4\"
data-parsoid='{\"dsr\":[32,46,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li about=\"#cite_note-1\"
id=\"cite_note-1\" data-parsoid='{\"stx\":\"ref\"}'><span
rel=\"mw:referencedBy\"><a href=\"#cite_ref-1\">↑</a></span>
foo\nbar\nbaz\nbooz\n</li></ol>");
+add("html2html", "Ref: 8. transclusion wikitext has lower precedence", "<p
data-parsoid='{\"dsr\":[0,47,0,0]}'>A <span about=\"#mwt2\" class=\"reference\"
id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[2,24,5,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"foo <span
typeof=\\\"mw:Nowiki\\\"
data-parsoid='{\\\"src\\\":\\\"{{\\\",\\\"dsr\\\":[11,13,0,0]}'>{{</span>echo|\"},\"attrs\":{}}'><a
href=\"#cite_note-1\">[1]</a></span> B C<span typeof=\"mw:Nowiki\"
data-parsoid='{\"dsr\":[28,47,8,9]}'>}}</span></p>\n<ol class=\"references\"
typeof=\"mw:Extension/references\" about=\"#mwt4\"
data-parsoid='{\"dsr\":[48,62,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li about=\"#cite_note-1\"
id=\"cite_note-1\" data-parsoid='{\"stx\":\"ref\"}'><span
rel=\"mw:referencedBy\"><a href=\"#cite_ref-1\">↑</a></span> foo <span
typeof=\"mw:Nowiki\"
data-parsoid='{\"src\":\"{{\",\"dsr\":[11,13,0,0]}'>{{</span>echo|</li></ol>");
+add("html2html", "Ref: 10. Unclosed HTML tags should not leak out of
ref-body", "<p data-parsoid='{\"dsr\":[0,25,0,0]}'>A <span about=\"#mwt2\"
class=\"reference\" id=\"cite_ref-1\" rel=\"dc:references\"
typeof=\"mw:Extension/ref\" data-parsoid='{\"dsr\":[2,21,5,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"<b
data-parsoid='{\\\"stx\\\":\\\"html\\\",\\\"autoInsertedEnd\\\":true,\\\"dsr\\\":[7,15,3,0]}'>
foo </b>\"},\"attrs\":{}}'><a href=\"#cite_note-1\">[1]</a></span> B
C</p>\n\n<ol class=\"references\" typeof=\"mw:Extension/references\"
about=\"#mwt4\" data-parsoid='{\"dsr\":[27,41,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li about=\"#cite_note-1\"
id=\"cite_note-1\" data-parsoid='{\"stx\":\"ref\"}'><span
rel=\"mw:referencedBy\"><a href=\"#cite_ref-1\">↑</a></span> <b
data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[7,15,3,0]}'>
foo </b></li></ol>");
+add("html2html", "Ref: 19. ref-tags with identical name encodings should get
identical indexes", "<p data-parsoid='{\"dsr\":[0,60,0,0]}'>1 <span
about=\"#mwt3\" class=\"reference\" id=\"cite_ref-a_.26_b_1-0\"
rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[2,29,18,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"foo\"},\"attrs\":{\"name\":\"a
& b\"}}'><a href=\"#cite_note-a_.26_b-1\">[1]</a></span> 2 <span
about=\"#mwt4\" class=\"reference\" id=\"cite_ref-a_.26amp.3B_b_2-0\"
rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[32,60,28,0]}'
data-mw='{\"name\":\"ref\",\"attrs\":{\"name\":\"a &amp;amp; b\"}}'><a
href=\"#cite_note-a_.26amp.3B_b-2\">[2]</a></span></p>\n\n<ol
class=\"references\" typeof=\"mw:Extension/references\" about=\"#mwt6\"
data-parsoid='{\"dsr\":[62,76,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li
about=\"#cite_note-a_.26_b-1\" id=\"cite_note-a_.26_b-1\"
data-parsoid='{\"stx\":\"ref\"}'><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-a_.26_b_1-0\">↑</a></span> foo</li><li
about=\"#cite_note-a_.26amp.3B_b-2\" id=\"cite_note-a_.26amp.3B_b-2\"
data-parsoid='{\"stx\":\"ref\"}'><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-a_.26amp.3B_b_2-0\">↑</a></span> </li></ol>");
+add("html2html", "References: 5. ref tags in references should be processed
while ignoring all other content", "<p data-parsoid='{\"dsr\":[0,44,0,0]}'>A
<span about=\"#mwt2\" class=\"reference\" id=\"cite_ref-a_1-0\"
rel=\"dc:references\" typeof=\"mw:Extension/ref\"
data-parsoid='{\"dsr\":[2,18,16,0]}'
data-mw='{\"name\":\"ref\",\"attrs\":{\"name\":\"a\"}}'><a
href=\"#cite_note-a-1\">[1]</a></span>\nB <span about=\"#mwt4\"
class=\"reference\" id=\"cite_ref-b_2-0\" rel=\"dc:references\"
typeof=\"mw:Extension/ref\" data-parsoid='{\"dsr\":[21,44,14,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"bar\"},\"attrs\":{\"name\":\"b\"}}'><a
href=\"#cite_note-b-2\">[2]</a></span></p>\n\n<ol class=\"references\"
typeof=\"mw:Extension/references\" about=\"#mwt6\"
data-parsoid='{\"dsr\":[46,96,2,2]}'
data-mw='{\"name\":\"references\",\"body\":{\"extsrc\":\"<ref
name=\\\"a\\\">foo</ref>\",\"html\":\"\\n<span about=\\\"#mwt8\\\"
class=\\\"reference\\\" rel=\\\"dc:references\\\"
typeof=\\\"mw:Extension/ref\\\" data-parsoid='{\\\"src\\\":\\\"&lt;ref
name=\\\\\\\"a\\\\\\\">foo&lt;/ref>\\\",\\\"dsr\\\":[59,82,14,6]}'
data-mw='{\\\"name\\\":\\\"ref\\\",\\\"body\\\":{\\\"html\\\":\\\"foo\\\"},\\\"attrs\\\":{\\\"name\\\":\\\"a\\\"}}'><a
href=\\\"#cite_note-a-1\\\">[1]</a></span>\\n\"},\"attrs\":{}}'><li
about=\"#cite_note-a-1\" id=\"cite_note-a-1\"
data-parsoid='{\"stx\":\"ref\"}'><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-a_1-0\">↑</a></span> foo</li><li about=\"#cite_note-b-2\"
id=\"cite_note-b-2\" data-parsoid='{\"stx\":\"ref\"}'><span
rel=\"mw:referencedBy\"><a href=\"#cite_ref-b_2-0\">↑</a></span>
bar</li></ol>");
+add("html2html", "Entities in ref name", "<p
data-parsoid='{\"dsr\":[0,38,0,0]}'><span about=\"#mwt2\" class=\"reference\"
id=\"cite_ref-test_.26amp.3B_me_1-0\" rel=\"dc:references\"
typeof=\"mw:Extension/ref\" data-parsoid='{\"dsr\":[0,38,30,6]}'
data-mw='{\"name\":\"ref\",\"body\":{\"html\":\"hi\"},\"attrs\":{\"name\":\"test
&amp;amp; me\"}}'><a
href=\"#cite_note-test_.26amp.3B_me-1\">[1]</a></span></p>\n<ol
class=\"references\" typeof=\"mw:Extension/references\" about=\"#mwt4\"
data-parsoid='{\"dsr\":[39,53,2,2]}'
data-mw='{\"name\":\"references\",\"attrs\":{}}'><li
about=\"#cite_note-test_.26amp.3B_me-1\" id=\"cite_note-test_.26amp.3B_me-1\"
data-parsoid='{\"stx\":\"ref\"}'><span rel=\"mw:referencedBy\"><a
href=\"#cite_ref-test_.26amp.3B_me_1-0\">↑</a></span> hi</li></ol>");
add("html2html", "Empty LI and TR nodes should not be stripped from top-level
content", "<ul data-parsoid='{\"dsr\":[0,9,0,0]}'><li
data-parsoid='{\"dsr\":[0,3,1,0]}'> a</li>\n<li
data-parsoid='{\"dsr\":[4,5,1,0]}'></li>\n<li
data-parsoid='{\"dsr\":[6,9,1,0]}'> b</li></ul>\n\n<table
data-parsoid='{\"dsr\":[11,26,2,2]}'>\n\n<tbody
data-parsoid='{\"dsr\":[15,24,0,0]}'><tr
data-parsoid='{\"startTagSrc\":\"|-\",\"autoInsertedEnd\":true,\"dsr\":[15,22,2,0]}'>\n<td
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[18,22,1,0]}'>foo</td></tr>\n\n</tbody></table>\n");
add("html2html", "Headings: 6a. Heading chars in SOL context (with trailing
spaces)", "<p data-parsoid='{\"dsr\":[0,20,0,0]}'><span typeof=\"mw:Nowiki\"
data-parsoid='{\"dsr\":[0,20,8,9]}'>=a=</span></p>\n\n<p
data-parsoid='{\"dsr\":[22,42,0,0]}'><span typeof=\"mw:Nowiki\"
data-parsoid='{\"dsr\":[22,42,8,9]}'>=a=</span></p> \n\n<p
data-parsoid='{\"dsr\":[45,65,0,0]}'><span typeof=\"mw:Nowiki\"
data-parsoid='{\"dsr\":[45,65,8,9]}'>=a=</span></p>\t\n\n<p
data-parsoid='{\"dsr\":[68,88,0,0]}'><span typeof=\"mw:Nowiki\"
data-parsoid='{\"dsr\":[68,88,8,9]}'>=a=</span></p> \t\n");
add("html2html", "Headings: 6b. Heading chars in SOL context (with trailing
newlines)", "<p data-parsoid='{\"dsr\":[0,22,0,0]}'><span typeof=\"mw:Nowiki\"
data-parsoid='{\"dsr\":[0,22,8,9]}'>=a=\nb</span></p>\n\n<p
data-parsoid='{\"dsr\":[24,47,0,0]}'><span typeof=\"mw:Nowiki\"
data-parsoid='{\"dsr\":[24,47,8,9]}'>=a= \nb</span></p>\n\n<p
data-parsoid='{\"dsr\":[49,72,0,0]}'><span typeof=\"mw:Nowiki\"
data-parsoid='{\"dsr\":[49,72,8,9]}'>=a=\t\nb</span></p>\n\n<p
data-parsoid='{\"dsr\":[74,98,0,0]}'><span typeof=\"mw:Nowiki\"
data-parsoid='{\"dsr\":[74,98,8,9]}'>=a=\t \nb</span></p>\n");
--
To view, visit https://gerrit.wikimedia.org/r/191585
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I682316b53dba90d2e86bc1669407d058fdd6edc2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Marcoil <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits