jenkins-bot has submitted this change and it was merged.

Change subject: T88660: Emit reflists for <ref> with no explicit <references>
......................................................................


T88660: Emit reflists for <ref> with no explicit <references>

This patch emits a reflist for all ref groups that still have
<ref>s in them at the end of the document. Currently Cite.php only
does so for the default group. See also T88290.

On html2wt the missing <references> are added to the wikitext,
which makes the wikitext correct. Selser catches this if not part
of the edit.

Change tests to include an explicit <references /> tag, and add
one for explcitly testing that they do get added. This last one
has to be blacklisted as the new <references /> don't appear with
selser.

Change-Id: I79af2c34481cadbf0d68d9571928979adf559b58
---
M lib/dom.processRefs.js
M lib/ext.Cite.js
M tests/parserTests-blacklist.js
M tests/parserTests.txt
4 files changed, 160 insertions(+), 25 deletions(-)

Approvals:
  Subramanya Sastry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/dom.processRefs.js b/lib/dom.processRefs.js
index 6865d9b..077ed92 100644
--- a/lib/dom.processRefs.js
+++ b/lib/dom.processRefs.js
@@ -53,6 +53,7 @@
 function processRefs(refsExt, node, env, options, atTopLevel) {
        if (atTopLevel) {
                _processRefs(refsExt, node);
+               refsExt.insertMissingReferencesIntoDOM(env, node);
        }
 }
 
diff --git a/lib/ext.Cite.js b/lib/ext.Cite.js
index 7d1c704..eb3af0a 100644
--- a/lib/ext.Cite.js
+++ b/lib/ext.Cite.js
@@ -482,6 +482,33 @@
        this.reset(group);
 };
 
+References.prototype.insertMissingReferencesIntoDOM = function (env, node) {
+       var doc = node.ownerDocument,
+               referencesId = env.newAboutId(),
+               self = this;
+
+       this.refGroups.forEach(function (refsData, refsGroup) {
+               var ol = doc.createElement('ol'),
+                       dp = DU.getDataParsoid(ol);
+               DU.addAttributes(ol, {
+                       'class': 'references',
+                       typeof: 'mw:Extension/references',
+                       about: referencesId
+               });
+               // The new references come out of "nowhere", so to make selser 
work
+               // propertly, add a zero-sized DSR pointing to the end of the 
document.
+               dp.dsr = [env.page.src.length, env.page.src.length, 0, 0];
+               if (refsGroup) {
+                       dp.group = refsGroup;
+               }
+               DU.storeDataParsoid(ol, dp);
+               node.appendChild(ol);
+               // Put a \n in here so that each <references /> appears in its 
own line.
+               node.appendChild(doc.createTextNode("\n"));
+               self.insertReferencesIntoDOM(ol, ["\n"]);
+       });
+};
+
 /**
  * Native Parsoid implementation of the Cite extension
  * that ties together <ref> and <references>
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index dde5fba..048534f 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -509,7 +509,7 @@
 add("wt2wt", "Bug 19052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed 
external links", "[http://www.example.org/ ideograms]\n");
 add("wt2wt", "Ignore pipe between table row attributes", "{|\n| quux\n|- 
id=\"foo\" style=\"color: red\" |\n| bar\n|}");
 add("wt2wt", "2. Bad treebuilder fixup of formatting elt is cleaned up", 
"'''foo'''[[File:Foobar.jpg|thumb|'''caption''']]'''bar'''\n\n<small>[[Image:Foobar.jpg|right|300px]]</small>");
-add("wt2wt", "Ref: 3. spaces in ref-names should be ignored", "A <ref 
name=\"x\">foo</ref>\nB <ref name=\"x\" />\nC <ref name=\"x\" />\n");
+add("wt2wt", "Ref: 3. spaces in ref-names should be ignored", "A <ref 
name=\"x\">foo</ref>\nB <ref name=\"x\" />\nC <ref name=\"x\" />\n<references 
/>");
 add("wt2wt", "Ref: 5. body should accept generic wikitext", "A <ref>This is a 
'''[[bolded link]]''' and this is a 
{{echo|transclusion}}\n</ref>\n\n<references />");
 add("wt2wt", "Ref: 6. indent-pres should not be output in ref-body", "A 
<ref>foo\n bar\n baz\n</ref>\n\n<references />");
 add("wt2wt", "Ref: 7. No p-wrapping in ref-body", "A 
<ref>foo\nbar\nbaz\nbooz\n</ref>\n\n<references />");
@@ -518,7 +518,8 @@
 add("wt2wt", "Ref: 10. Unclosed HTML tags should not leak out of ref-body", "A 
<ref><b> foo </ref> B C\n\n<references />");
 add("wt2wt", "Ref: 19. ref-tags with identical name encodings should get 
identical indexes", "1 <ref name=\"a & b\">foo</ref> 2 <ref name=\"a &amp;amp; 
b\" />\n\n<references />");
 add("wt2wt", "References: 5. ref tags in references should be processed while 
ignoring all other content", "A <ref name=\"a\" />\nB <ref 
name=\"b\">bar</ref>\n\n<references>\n<ref 
name=\"a\">foo</ref>\n</references>");
-add("wt2wt", "Entities in ref name", "<ref name=\"test &amp;amp; 
me\">hi</ref>\n");
+add("wt2wt", "References: 9. Generate missing references list at the end", "A 
<ref>foo</ref>\nB <ref group=\"inexistent\">bar</ref><references 
/>\n<references group=\"inexistent\" />\n");
+add("wt2wt", "Entities in ref name", "<ref name=\"test &amp;amp; 
me\">hi</ref>\n<references />");
 add("wt2wt", "HTML tag with broken attribute value quoting", "<span 
title=\"Hello world\">Foo</span>\n");
 add("wt2wt", "Parsoid-only: HTML tag with broken attribute value quoting", 
"<span title=\"Hello world\">Foo</span>\n");
 add("wt2wt", "Table with broken attribute value quoting", "{|\n| title=\"Hello 
world\" |Foo\n|}");
@@ -886,7 +887,7 @@
 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\":\"&lt;b 
data-parsoid=&#39;{\\\"stx\\\":\\\"html\\\",\\\"autoInsertedEnd\\\":true,\\\"dsr\\\":[7,15,3,0]}&#39;>
 foo &lt;/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 
&amp; 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;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\":\"&lt;ref 
name=\\\"a\\\">foo&lt;/ref>\",\"html\":\"\\n&lt;span about=\\\"#mwt8\\\" 
class=\\\"reference\\\" rel=\\\"dc:references\\\" 
typeof=\\\"mw:Extension/ref\\\" data-parsoid=&#39;{\\\"src\\\":\\\"&amp;lt;ref 
name=\\\\\\\"a\\\\\\\">foo&amp;lt;/ref>\\\",\\\"dsr\\\":[59,82,14,6]}&#39; 
data-mw=&#39;{\\\"name\\\":\\\"ref\\\",\\\"body\\\":{\\\"html\\\":\\\"foo\\\"},\\\"attrs\\\":{\\\"name\\\":\\\"a\\\"}}&#39;>&lt;a
 href=\\\"#cite_note-a-1\\\">[1]&lt;/a>&lt;/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;amp; me\"}}'><a 
href=\"#cite_note-test_.26amp.3B_me-1\">[1]</a></span></p>\n");
+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;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", "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");
@@ -1713,7 +1714,7 @@
 add("html2wt", "Padleft and padright as substr", "abc\nabc\n");
 add("html2wt", "Special parser function", 
"Special:Random\nSpecial:Badtitle\nSpecial:Foobar\n");
 add("html2wt", "Disable TOC", "Lead\n\n== <span class=\"mw-headline\" 
id=\"Section_1\">Section 1</span><span class=\"mw-editsection\"><span 
class=\"mw-editsection-bracket\">[</span>[/index.php?title=Parser_test&action=edit&section=1
 edit]<span class=\"mw-editsection-bracket\">]</span></span> ==\n\n== <span 
class=\"mw-headline\" id=\"Section_2\">Section 2</span><span 
class=\"mw-editsection\"><span 
class=\"mw-editsection-bracket\">[</span>[/index.php?title=Parser_test&action=edit&section=2
 edit]<span class=\"mw-editsection-bracket\">]</span></span> ==\n\n== <span 
class=\"mw-headline\" id=\"Section_3\">Section 3</span><span 
class=\"mw-editsection\"><span 
class=\"mw-editsection-bracket\">[</span>[/index.php?title=Parser_test&action=edit&section=3
 edit]<span class=\"mw-editsection-bracket\">]</span></span> ==\n\n== <span 
class=\"mw-headline\" id=\"Section_4\">Section 4</span><span 
class=\"mw-editsection\"><span 
class=\"mw-editsection-bracket\">[</span>[/index.php?title=Parser_test&action=edit&section=4
 edit]<span class=\"mw-editsection-bracket\">]</span></span> ==\n\n== <span 
class=\"mw-headline\" id=\"Section_5\">Section 5</span><span 
class=\"mw-editsection\"><span 
class=\"mw-editsection-bracket\">[</span>[/index.php?title=Parser_test&action=edit&section=5
 edit]<span class=\"mw-editsection-bracket\">]</span></span> ==\n");
-add("html2wt", "Ref: 3. spaces in ref-names should be ignored", "A <ref 
name=\"x\">foo</ref>\nB <ref name=\"x\" />\nC <ref name=\"x\" />\n");
+add("html2wt", "Ref: 3. spaces in ref-names should be ignored", "A <ref 
name=\"x\">foo</ref>\nB <ref name=\"x\" />\nC <ref name=\"x\" />\n<references 
/>");
 add("html2wt", "Ref: 5. body should accept generic wikitext", "A <ref>This is 
a '''[[bolded link]]''' and this is a 
{{echo|transclusion}}\n</ref>\n\n<references />");
 add("html2wt", "Ref: 6. indent-pres should not be output in ref-body", "A 
<ref>foo\n bar\n baz\n</ref>\n\n<references />");
 add("html2wt", "Ref: 7. No p-wrapping in ref-body", "A 
<ref>foo\nbar\nbaz\nbooz\n</ref>\n\n<references />");
@@ -1722,7 +1723,8 @@
 add("html2wt", "Ref: 10. Unclosed HTML tags should not leak out of ref-body", 
"A <ref><b> foo </ref> B C\n\n<references />");
 add("html2wt", "Ref: 19. ref-tags with identical name encodings should get 
identical indexes", "1 <ref name=\"a & b\">foo</ref> 2 <ref name=\"a &amp;amp; 
b\" />\n\n<references />");
 add("html2wt", "References: 5. ref tags in references should be processed 
while ignoring all other content", "A <ref name=\"a\" />\nB <ref 
name=\"b\">bar</ref>\n\n<references>\n<ref 
name=\"a\">foo</ref>\n</references>");
-add("html2wt", "Entities in ref name", "<ref name=\"test &amp;amp; 
me\">hi</ref>\n");
+add("html2wt", "References: 9. Generate missing references list at the end", 
"A <ref>foo</ref> B <ref group=\"inexistent\">bar</ref><!--</p-->\n<references 
/>\n<references group=\"inexistent\" />");
+add("html2wt", "Entities in ref name", "<ref name=\"test &amp;amp; 
me\">hi</ref>\n<references />");
 add("html2wt", "Empty LI and TR nodes should not be stripped from top-level 
content", "* a\n*\n* b\n\n{|\n\n|-\n|foo\n\n|}\n");
 add("html2wt", "Lists: 1. Nested inside html", "* <nowiki>*foo</nowiki>\n\n* 
<nowiki>#foo</nowiki>\n\n* <nowiki>:foo</nowiki>\n\n* <nowiki>;foo</nowiki>\n# 
<nowiki>*foo</nowiki>\n\n# <nowiki>#foo</nowiki>\n\n# 
<nowiki>:foo</nowiki>\n\n# <nowiki>;foo</nowiki>\n");
 add("html2wt", "Lists: 2. Inside definition lists", "; 
<nowiki>;foo</nowiki>\n\n; <nowiki>:foo</nowiki>\n\n; <nowiki>:foo</nowiki>\n: 
bar\n\n: <nowiki>:foo</nowiki>\n");
@@ -2647,23 +2649,23 @@
 add("selser", "2. Bad treebuilder fixup of formatting elt is cleaned up 
[[3],0,[1],0,4]", 
"[[File:Foobar.jpg|thumb|caption]]'''bar'''\n\nily87fh4z6nipb9\n");
 add("selser", "2. Bad treebuilder fixup of formatting elt is cleaned up 
[4,[0,1],2,0,0]", 
"ns2t3vre6xjn61or[[File:Foobar.jpg|thumb|'''caption''']]ett722e3n2162yb9\n\nbar'''\n\n<small>[[Image:Foobar.jpg|right|300px]]</small>");
 add("selser", "2. Bad treebuilder fixup of formatting elt is cleaned up 
[1,[0,[2]],[1],0,3]", 
"'''foo[[File:Foobar.jpg|thumb|3nwdrc96evrvygb9'''caption''']]'''bar'''\n");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[0,0,2,0,3,0]]", 
"A <ref name=\"x\">foo</ref>4e761xuztftlz0k9\nB <ref name=\" x \" /><ref name= 
x  />");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[0,0,4,0,2,0]]", 
"A <ref name=\"x\">foo</ref>3w7ovsl9a3fk1emi<ref name=\" x \" 
/>0ge9uw9zjpk6s9k9\nC <ref name= x  />");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[0,0,3,0,0,0]]", 
"A <ref name=\"x\">foo</ref><ref name=\" x \" />\nC <ref name= x  />");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[4,0,3,0,3,0]]", 
"9bipqi2pwdi2uik9<ref name=\"x\">foo</ref><ref name=\" x \" /><ref name= x  
/>");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [2]", 
"ygeccjbn41fez5mi\n\nA <ref name=\"x\">foo</ref>\nB <ref name=\" x \" />\nC 
<ref name= x  />");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[3,0,4,0,0,0]]", 
"<ref name=\"x\">foo</ref>2mkm6z95yrx561or<ref name=\" x \" />\nC <ref name= x  
/>");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [1]", "A <ref 
name=\"x\">foo</ref>\nB <ref name=\" x \" />\nC <ref name= x  />");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[4,0,2,0,0,0]]", 
"bsstrf4asth5b3xr<ref name=\"x\">foo</ref>ykhvrcwh9cc8fr\nB <ref name=\" x \" 
/>\nC <ref name= x  />");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[2,0,0,0,0,0]]", 
"w0g5031j8wr8uxrA <ref name=\"x\">foo</ref>\nB <ref name=\" x \" />\nC <ref 
name= x  />");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[3,0,3,0,0,0]]", 
"<ref name=\"x\">foo</ref><ref name=\" x \" />\nC <ref name= x  />");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[0,0,4,0,3,0]]", 
"A <ref name=\"x\">foo</ref>h81b8wtpyjznz5mi<ref name=\" x \" /><ref name= x  
/>");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[4,0,0,0,3,0]]", 
"9b0gpvrxsxetgldi<ref name=\"x\">foo</ref>\nB <ref name=\" x \" /><ref name= x  
/>");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[0,0,4,0,0,0]]", 
"A <ref name=\"x\">foo</ref>1i7un9k3kza4te29<ref name=\" x \" />\nC <ref name= 
x  />");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[0,0,0,0,3,0]]", 
"A <ref name=\"x\">foo</ref>\nB <ref name=\" x \" /><ref name= x  />");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[3,0,2,0,0,0]]", 
"<ref name=\"x\">foo</ref>old27zbnsf7uv7vi\nB <ref name=\" x \" />\nC <ref 
name= x  />");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[0,0,3,0,4,0]]", 
"A <ref name=\"x\">foo</ref><ref name=\" x \" />waf2vtqqnxjyk3xr<ref name= x  
/>");
-add("selser", "Ref: 3. spaces in ref-names should be ignored [[0,0,0,0,4,0]]", 
"A <ref name=\"x\">foo</ref>\nB <ref name=\" x \" />gzf0q2rm80hehfr<ref name= x 
 />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[0,0,2,0,3,0],0,0]", "A <ref name=\"x\">foo</ref>4e761xuztftlz0k9\nB <ref 
name=\" x \" /><ref name= x  />\n<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[0,0,4,0,2,0],0,0]", "A <ref name=\"x\">foo</ref>3w7ovsl9a3fk1emi<ref name=\" 
x \" />0ge9uw9zjpk6s9k9\nC <ref name= x  />\n<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[0,0,3,0,0,0],3,0]", "A <ref name=\"x\">foo</ref><ref name=\" x \" />\nC <ref 
name= x  /><references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[4,0,3,0,3,0],0,0]", "9bipqi2pwdi2uik9<ref name=\"x\">foo</ref><ref name=\" x 
\" /><ref name= x  />\n<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored [2,0,0]", 
"ygeccjbn41fez5mi\n\nA <ref name=\"x\">foo</ref>\nB <ref name=\" x \" />\nC 
<ref name= x  />\n<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[3,0,4,0,0,0],4,0]", "<ref name=\"x\">foo</ref>2mkm6z95yrx561or<ref name=\" x 
\" />\nC <ref name= x  />\n\nbrxr5q2im99c0udi<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored [1,2,0]", "A <ref 
name=\"x\">foo</ref>\nB <ref name=\" x \" />\nC <ref name= x  
/>\n\n6y8eehlkc3lbx1or\n<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored [0,4,0]", "A <ref 
name=\"x\">foo</ref>\nB <ref name=\" x \" />\nC <ref name= x  
/>\n\naakjv0zefcgqr529<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[4,0,2,0,0,0],0,0]", "bsstrf4asth5b3xr<ref 
name=\"x\">foo</ref>ykhvrcwh9cc8fr\nB <ref name=\" x \" />\nC <ref name= x  
/>\n<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[3,0,3,0,0,0],0,0]", "<ref name=\"x\">foo</ref><ref name=\" x \" />\nC <ref 
name= x  />\n<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[0,0,4,0,3,0],4,0]", "A <ref name=\"x\">foo</ref>h81b8wtpyjznz5mi<ref name=\" 
x \" /><ref name= x  />\n\n7srb7c5gx28olxr<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[4,0,0,0,3,0],2,0]", "9b0gpvrxsxetgldi<ref name=\"x\">foo</ref>\nB <ref 
name=\" x \" /><ref name= x  />\n\nkha2wn0z9qr7wrk9\n<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[3,0,3,0,0,0],2,0]", "<ref name=\"x\">foo</ref><ref name=\" x \" />\nC <ref 
name= x  />\n\n1i7un9k3kza4te29\n<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored [1,0,0]", "A <ref 
name=\"x\">foo</ref>\nB <ref name=\" x \" />\nC <ref name= x  />\n<references 
/>");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[3,0,0,0,0,0],3,0]", "<ref name=\"x\">foo</ref>\nB <ref name=\" x \" />\nC 
<ref name= x  /><references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[3,0,4,0,2,0],0,0]", "<ref name=\"x\">foo</ref>waf2vtqqnxjyk3xr<ref name=\" x 
\" />dyfyyn5o3sqvvx6r\nC <ref name= x  />\n<references />");
+add("selser", "Ref: 3. spaces in ref-names should be ignored 
[[0,0,0,0,4,0],0,0]", "A <ref name=\"x\">foo</ref>\nB <ref name=\" x \" 
/>gzf0q2rm80hehfr<ref name= x  />\n<references />");
 add("selser", "Ref: 5. body should accept generic wikitext [0,2,0]", "A 
<ref>\n This is a '''[[bolded link]]''' and this is a 
{{echo|transclusion}}\n</ref>\n\ndwm4quuvdsjg7gb9\n\n<references />");
 add("selser", "Ref: 5. body should accept generic wikitext [[2,0],0,0]", 
"64pys175oa90be29A <ref>\n This is a '''[[bolded link]]''' and this is a 
{{echo|transclusion}}\n</ref>\n\n<references />");
 add("selser", "Ref: 5. body should accept generic wikitext [[2,0],4,0]", 
"4jyox5aerj05dn29A <ref>\n This is a '''[[bolded link]]''' and this is a 
{{echo|transclusion}}\n</ref>\n\ne8ivhnmx87uy2e29<references />");
@@ -2751,6 +2753,7 @@
 add("selser", "Ref: 10. Unclosed HTML tags should not leak out of ref-body 
[[2,0,0],2,0]", "3i2udpyjqgehr529A <ref> <b> foo </ref> B 
C\n\n04ufs7jtgivsra4i\n\n<references />");
 add("selser", "Ref: 10. Unclosed HTML tags should not leak out of ref-body 
[0,4,0]", "A <ref> <b> foo </ref> B C\n\nexksatqzwpgsc3di<references />");
 add("selser", "Ref: 10. Unclosed HTML tags should not leak out of ref-body 
[[0,0,4],3,0]", "A <ref> <b> foo </ref>3ds74snl9wly2e29<references />");
+add("selser", "Ref: 12. ref-tags act as trailing newline migration barrier 
[4,[2],3,2,4,[4],3,0]", 
"m5deo7xhmiaoflxr\n\nqhnq99nstl8oajora\n\nf16ctvb87p919k9\n\nb<!--the newline 
at the end of this line stays inside the p-tag--> <ref />\n<ref 
/>\n\ni5sgdy5g0bb7qfr\n\nlppjadx2v8q41jor\n<references />");
 add("selser", "Ref: 19. ref-tags with identical name encodings should get 
identical indexes [[2,0,4,0],0,0]", "0dpatm9gsbqk6gvi1 <ref name=\"a & 
b\">foo</ref>k0yidhh5u2b21emi<ref name=\"a &amp; b\" />\n\n<references />");
 add("selser", "Ref: 19. ref-tags with identical name encodings should get 
identical indexes [2,0,0]", "zmmmjlha7xim5cdi\n\n1 <ref name=\"a & 
b\">foo</ref> 2 <ref name=\"a &amp; b\" />\n\n<references />");
 add("selser", "Ref: 19. ref-tags with identical name encodings should get 
identical indexes [1,0,0]", "1 <ref name=\"a & b\">foo</ref> 2 <ref name=\"a 
&amp; b\" />\n\n<references />");
@@ -2782,8 +2785,37 @@
 add("selser", "References: 5. ref tags in references should be processed while 
ignoring all other content [4,4,0]", 
"lfl5lazff7irizfr\n\nt2vlo1j32ipjsjor<references>\n<ref 
name=\"a\">foo</ref>\nThis should just get lost.\n</references>");
 add("selser", "References: 5. ref tags in references should be processed while 
ignoring all other content [3,4,0]", "nuwpe9pypyb3ayvi<references>\n<ref 
name=\"a\">foo</ref>\nThis should just get lost.\n</references>");
 add("selser", "References: 5. ref tags in references should be processed while 
ignoring all other content [0,2,0]", "A <ref name=\"a\" />\nB <ref 
name=\"b\">bar</ref>\n\nky16pugtafywrk9\n\n<references>\n<ref 
name=\"a\">foo</ref>\nThis should just get lost.\n</references>");
-add("selser", "Entities in ref name [2]", "72oie2a08o69wwmi\n\n<ref 
name=\"test &amp; me\">hi</ref>");
-add("selser", "Entities in ref name [1]", "<ref name=\"test &amp; 
me\">hi</ref>");
+add("selser", "References: 9. Generate missing references list at the end 
[0,0,4,0,3]", "A <ref>foo</ref>\nB <ref 
group=\"inexistent\">bar</ref>b7ysmcsq3gd86w29");
+add("selser", "References: 9. Generate missing references list at the end 
[4,0,4,0,4]", "lvnt8vr7angq4cxrwue4r5n3y3a3jtt9rhjjeyvdl0qtcsor\n");
+add("selser", "References: 9. Generate missing references list at the end 
[[2,0,2,0],0,0,0,3]", "7xhpxcasifwdn29A <ref>foo</ref>562x1ybv3p3w61or\nB <ref 
group=\"inexistent\">bar</ref>");
+add("selser", "References: 9. Generate missing references list at the end 
[3,0,0,0,2]", "tkairlq0upfa8aor\n");
+add("selser", "References: 9. Generate missing references list at the end 
[[0,0,2,0],0,2,0,0]", "A <ref>foo</ref>djzbwa2njauivn29\nB <ref 
group=\"inexistent\">bar</ref>xfjjewhbw1k2zkt9\n\n");
+add("selser", "References: 9. Generate missing references list at the end 
[4,0,2,0,3]", "q1p2la2weglul3diwd4bqvoes653766r\n");
+add("selser", "References: 9. Generate missing references list at the end 
[0,0,3,0,0]", "A <ref>foo</ref>\nB <ref group=\"inexistent\">bar</ref>\n");
+add("selser", "References: 9. Generate missing references list at the end 
[[0,0,4,0],0,0,0,4]", "A <ref>foo</ref>gpnrlcm305a2x1or<ref 
group=\"inexistent\">bar</ref>ctwao900ott3ayvi\n");
+add("selser", "References: 9. Generate missing references list at the end 
[[0,0,4,0],0,0,0,3]", "A <ref>foo</ref>0byd6o7cb9jxlxr<ref 
group=\"inexistent\">bar</ref>");
+add("selser", "References: 9. Generate missing references list at the end 
[[3,0,0,0],0,3,0,0]", "<ref>foo</ref>\nB <ref 
group=\"inexistent\">bar</ref>\n");
+add("selser", "References: 9. Generate missing references list at the end 
[3,0,3,0,0]", "\n");
+add("selser", "References: 9. Generate missing references list at the end 
[[4,0,4,0],0,2,0,4]", "hrabkskjen7mn29<ref>foo</ref>jrecig5npts2a9k9<ref 
group=\"inexistent\">bar</ref>wci03bzp3f9cz0k9\nyhh3izw25u9s5rk9\n");
+add("selser", "References: 9. Generate missing references list at the end 
[4,0,3,0,2]", "tjzrngic8rhvkj4ixv4c3yomv5yfzuxr\n");
+add("selser", "References: 9. Generate missing references list at the end 
[2,0,3,0,0]", "p5fvot19vi996bt9\n\nA <ref>foo</ref>\nB <ref 
group=\"inexistent\">bar</ref>\n");
+add("selser", "References: 9. Generate missing references list at the end 
[[4,0,0,0],0,3,0,0]", "dseofkxrc6w7y14i<ref>foo</ref>\nB <ref 
group=\"inexistent\">bar</ref>\n");
+add("selser", "References: 9. Generate missing references list at the end 
[[4,0,0,0],0,0,0,2]", "sjp70faz66flxr<ref>foo</ref>\nB <ref 
group=\"inexistent\">bar</ref>zltmz19843uzbyb9\n");
+add("selser", "References: 9. Generate missing references list at the end 
[1,0,3,0,0]", "A <ref>foo</ref>\nB <ref group=\"inexistent\">bar</ref>\n");
+add("selser", "References: 9. Generate missing references list at the end 
[0,0,0,0,4]", "A <ref>foo</ref>\nB <ref 
group=\"inexistent\">bar</ref>gzp6lrkdgkx4j9k9\n");
+add("selser", "References: 9. Generate missing references list at the end 
[[4,0,0,0],0,3,0,3]", "a021rh5a9i442t9<ref>foo</ref>\nB <ref 
group=\"inexistent\">bar</ref>");
+add("selser", "References: 9. Generate missing references list at the end 
[3,0,0,0,0]", "\n");
+add("selser", "Entities in ref name [0,2,0]", "<ref name=\"test &amp; 
me\">hi</ref>\n\n72oie2a08o69wwmi\n<references />");
+add("selser", "Entities in ref name [1,0,0]", "<ref name=\"test &amp; 
me\">hi</ref>\n<references />");
+add("selser", "Entities in ref name [2,0,0]", "znce1z6h58sn61or\n\n<ref 
name=\"test &amp; me\">hi</ref>\n<references />");
+add("selser", "Entities in ref name [2,4,0]", "70va6oxusf50cnmi\n\n<ref 
name=\"test &amp; me\">hi</ref>\n\n5gl7pqxbevm6xbt9<references />");
+add("selser", "Entities in ref name [0,3,0]", "<ref name=\"test &amp; 
me\">hi</ref><references />");
+add("selser", "Entities in ref name [1,2,0]", "<ref name=\"test &amp; 
me\">hi</ref>\n\numckb0hhr64oyldi\n<references />");
+add("selser", "Entities in ref name [2,2,0]", "z44h5udalp6qolxr\n\n<ref 
name=\"test &amp; me\">hi</ref>\n\naq2zpjm7twc23xr\n<references />");
+add("selser", "Entities in ref name [0,4,0]", "<ref name=\"test &amp; 
me\">hi</ref>\n\n5nvlkjfbc7iafw29<references />");
+add("selser", "Entities in ref name [2,3,0]", "uoi5udkn099vygb9\n\n<ref 
name=\"test &amp; me\">hi</ref><references />");
+add("selser", "Entities in ref name [1,3,0]", "<ref name=\"test &amp; 
me\">hi</ref><references />");
+add("selser", "Entities in ref name [1,4,0]", "<ref name=\"test &amp; 
me\">hi</ref>\n\np6wq2v8daq0k9<references />");
 add("selser", "Headings: 5. Empty headings [[2],3,2,0,4,4,0,2,1,3,0]", 
"=hnjo2713bjvjwcdi<nowiki/>=\nx2d05yq3dapaxlxr\n\n==<nowiki/>==\n\nkaovt9si227ta9k9\n\nb2688fvzpaocrf6r\n\n====<nowiki/>====\nljshl952j0emte29\n\n=====<nowiki/>=====\n\n======<nowiki/>======");
 add("selser", "Headings: 6a. Heading chars in SOL context (with trailing 
spaces) [4,0,1,0,4,4,[2],3]", "o4fu7yz6zedvlsor\n\n<nowiki>=a=</nowiki> 
\n\nfzi337zwgfmbzkt9\n\nrziif3qr3rspp66r\n\nzm9kz709iqpsnhfr<nowiki>=a=</nowiki>
 \t");
 add("selser", "1a. Quotes inside <b> and <i> 
[[0,0,[[2]],0,[3],4,0,2,0,1,0,[[3]],3,[[3]],2,4,0,0,0,0,0,0,[3],0,3,2,1,4,[4],0,4,1,0,2,2,0,[3],3,4,[2,0],0,2,0,1,4,3,3,0,4]]",
 
"''<nowiki/>'foo'''\n''<nowiki>1e9muev8ss5g66r''foo''</nowiki>''\n''<nowiki/>''4d5ycsl2y8kw3ik9''foo''aupv0np9y23dte29<nowiki/>'s\n'''<nowiki/>'foo''''\n'''<nowiki></nowiki><nowiki></nowiki>'''7v99l2g58uf8ncdi\nt25xhsjezsxuhaor\n'''foo'''<nowiki/>'s\n'''foo''\n''<nowiki/>''<nowiki/>4jfax21zqk273nmi''foo'''<nowiki/>4cjse042djk8olxr''uuxn7j5hunlsdcxr''<nowiki/>gxsdwksxmc5zh0k9'''foo'''\nebmq8hwo94yousor'''foo'''8vbmckzt1zg58kt9<nowiki/>'\n''''<nowiki/>'''uvlpop77khtihpvi''8bzt3z0trdwh4cxrfools'<span>
 errand</span>''\n4ni438wzhzsvpldi''<span>fool</span>'s 
errand''\n'<nowiki/>457s295v8krtqpvi\na|!*#-:;+-~[]{}b'itx2quuq6dqb0529\n");
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 8a0fef6..e2da829 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -19624,10 +19624,16 @@
 A <ref>foo</ref>
 B <ref name="x">foo</ref>
 C <ref name="y" />
+<references />
 !! html
 <p>A <span about="#mwt2" class="reference" id="cite_ref-1" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{}}'><a 
href="#cite_note-1">[1]</a></span>
 B <span about="#mwt4" class="reference" id="cite_ref-x_2-0" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{"name":"x"}}'><a 
href="#cite_note-x-2">[2]</a></span>
 C <span about="#mwt6" class="reference" id="cite_ref-y_3-0" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","attrs":{"name":"y"}}'><a 
href="#cite_note-y-3">[3]</a></span></p>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{}}'>
+<li id="cite_note-1"><span rel="mw:referencedBy"><a 
href="#cite_ref-1">↑</a></span> foo</li>
+<li id="cite_note-x-2"><span rel="mw:referencedBy"><a 
href="#cite_ref-x_2-0">↑</a></span> foo</li>
+<li id="cite_note-y-3"><span rel="mw:referencedBy"><a 
href="#cite_ref-y_3-0">↑</a></span></li>
+</ol>
 !!end
 
 !!test
@@ -19637,9 +19643,13 @@
 !! wikitext
 A <ref name="x">foo</ref>
 B <ref name="x" />
+<references />
 !! html
 <p>A <span about="#mwt2" class="reference" id="cite_ref-x_1-0" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{"name":"x"}}'><a 
href="#cite_note-x-1">[1]</a></span>
 B <span about="#mwt4" class="reference" id="cite_ref-x_1-1" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","attrs":{"name":"x"}}'><a 
href="#cite_note-x-1">[1]</a></span></p>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{}}'>
+<li id="cite_note-x-1"><span rel="mw:referencedBy">↑ <a 
href="#cite_ref-x_1-0">1.0</a> <a href="#cite_ref-x_1-1">1.1</a></span> foo</li>
+</ol>
 !!end
 
 !!test
@@ -19650,10 +19660,14 @@
 A <ref name="x">foo</ref>
 B <ref name=" x " />
 C <ref name= x  />
+<references />
 !! html
 <p>A <span about="#mwt2" class="reference" id="cite_ref-x_1-0" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{"name":"x"}}'><a 
href="#cite_note-x-1">[1]</a></span>
 B <span about="#mwt4" class="reference" id="cite_ref-x_1-1" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","attrs":{"name":"x"}}'><a 
href="#cite_note-x-1">[1]</a></span>
 C <span about="#mwt6" class="reference" id="cite_ref-x_1-2" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","attrs":{"name":"x"}}'><a 
href="#cite_note-x-1">[1]</a></span></p>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{}}'>
+<li id="cite_note-x-1"><span rel="mw:referencedBy">↑ <a 
href="#cite_ref-x_1-0">1.0</a> <a href="#cite_ref-x_1-1">1.1</a> <a 
href="#cite_ref-x_1-2">1.2</a></span> foo</li>
+</ol>
 !!end
 
 # NOTE: constructor is a predefined property in JS and constructor as a 
ref-name can clash with it if not handled properly)
@@ -19663,8 +19677,12 @@
 parsoid
 !! wikitext
 A <ref name="constructor">foo</ref>
+<references />
 !! html
 <p>A <span about="#mwt2" class="reference" id="cite_ref-constructor_1-0" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{"name":"constructor"}}'><a
 href="#cite_note-constructor-1">[1]</a></span></p>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{}}'>
+<li id="cite_note-constructor-1"><span rel="mw:referencedBy"><a 
href="#cite_ref-constructor_1-0">↑</a></span> foo</li>
+</ol>
 !!end
 
 !!test
@@ -19799,9 +19817,14 @@
 !! wikitext
 A <ref>foo</ref> B
 C <ref>bar</ref> D
+<references />
 !! html
 <p>A <span about="#mwt2" class="reference" id="cite_ref-1" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{}}'><a 
href="#cite_note-1">[1]</a></span> B
 C <span about="#mwt4" class="reference" id="cite_ref-2" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"bar"},"attrs":{}}'><a 
href="#cite_note-2">[2]</a></span> D</p>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{}}'>
+<li id="cite_note-1"><span rel="mw:referencedBy"><a 
href="#cite_ref-1">↑</a></span> foo</li>
+<li id="cite_note-2"><span rel="mw:referencedBy"><a 
href="#cite_ref-2">↑</a></span> bar</li>
+</ol>
 !!end
 
 !!test
@@ -19815,6 +19838,7 @@
 <ref />
 
 c
+<references />
 !! html
 <p><!--the newline at the end of this line moves out of the p-tag-->a</p>
 
@@ -19823,6 +19847,10 @@
 <span about="#mwt4" class="reference" id="cite_ref-2" rel="dc:references" 
typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{}}'><a 
href="#cite_note-2">[2]</a></span></p>
 
 <p>c</p>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{}}'>
+<li id="cite_note-1"><span rel="mw:referencedBy"><a 
href="#cite_ref-1">↑</a></span></li>
+<li id="cite_note-2"><span rel="mw:referencedBy"><a 
href="#cite_ref-2">↑</a></span></li>
+</ol>
 !!end
 
 !!test
@@ -19833,9 +19861,14 @@
 <ref>foo</ref> A
 <ref>bar
 </ref> B
+<references />
 !! html
 <p><span about="#mwt2" class="reference" id="cite_ref-1" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{}}'><a 
href="#cite_note-1">[1]</a></span> A
 <span about="#mwt4" class="reference" id="cite_ref-2" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"bar\n"},"attrs":{}}'><a 
href="#cite_note-2">[2]</a></span> B</p>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{}}'>
+<li id="cite_note-1"><span rel="mw:referencedBy"><a 
href="#cite_ref-1">↑</a></span> foo</li>
+<li id="cite_note-2"><span rel="mw:referencedBy"><a 
href="#cite_ref-2">↑</a></span> bar</li>
+</ol>
 !!end
 
 !!test
@@ -19951,13 +19984,22 @@
 !! wikitext
 A <ref group="a">foo</ref>
 B <ref group="b">bar</ref>
+C <ref>baz</ref>
 
 <references group="a" />
+<references />
+<references group="b" />
 !! html
 <p>A <span about="#mwt2" class="reference" id="cite_ref-1" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{"group":"a"}}'><a 
href="#cite_note-1">[a 1]</a></span>
-B <span about="#mwt4" class="reference" id="cite_ref-2" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"bar"},"attrs":{"group":"b"}}'><a 
href="#cite_note-2">[b 1]</a></span></p>
+B <span about="#mwt4" class="reference" id="cite_ref-2" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"bar"},"attrs":{"group":"b"}}'><a 
href="#cite_note-2">[b 1]</a></span>
+C <span class="reference" id="cite_ref-3" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"baz"},"attrs":{}}'><a 
href="#cite_note-3">[1]</a></span></p>
 
 <ol class="references" typeof="mw:Extension/references" about="#mwt6" 
data-mw='{"name":"references","attrs":{"group":"a"}}'><li about="#cite_note-1" 
id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1">↑</a></span> 
foo</li>
+</ol>
+<ol class="references" typeof="mw:Extension/references" about="#mwt6" 
data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-3" 
id="cite_note-3"><span rel="mw:referencedBy"><a href="#cite_ref-3">↑</a></span> 
baz</li>
+</ol>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{"group":"b"}}'>
+<li id="cite_note-2"><span rel="mw:referencedBy"><a 
href="#cite_ref-2">↑</a></span> bar</li>
 </ol>
 !!end
 
@@ -20076,14 +20118,39 @@
 <ol class="references" typeof="mw:Extension/references" about="#mwt4" 
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 <b data-parsoid='{"stx":"html"}'>bar</b> and baz boo</li></ol>
 !!end
 
+# This test only works in wt2html now as the <references /> are always 
generated
+# unless selser is active. Once T72722 is fixed, we should add a changes test
+# here to ensure that unrelated changes don't add the new <references /> in
+# wt2wt.
+!! test
+References: 9. Generate missing references list at the end
+!! options
+parsoid
+!! wikitext
+A <ref>foo</ref>
+B <ref group="inexistent">bar</ref>
+!! html
+<p>A <span class="reference" id="cite_ref-1" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{}}'><a 
href="#cite_note-1">[1]</a></span> B <span class="reference" id="cite_ref-2" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"bar"},"attrs":{"group":"inexistent"}}'><a
 href="#cite_note-2">[inexistent 1]</a></span></</p>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{}}'>
+<li id="cite_note-1"><span rel="mw:referencedBy"><a 
href="#cite_ref-1">↑</a></span> foo</li>
+</ol>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{"group":"inexistent"}}'>
+<li id="cite_note-2"><span rel="mw:referencedBy"><a 
href="#cite_ref-2">↑</a></span> bar</li>
+</ol>
+!! end
+
 !! test
 Entities in ref name
 !! options
 parsoid
 !! wikitext
 <ref name="test &amp; me">hi</ref>
+<references />
 !! html
 <p><span about="#mwt2" class="reference" id="cite_ref-test_.26_me_1-0" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"hi"},"attrs":{"name":"test &amp;amp; 
me"}}'><a href="#cite_note-test_.26_me-1">[1]</a></span></p>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{}}'>
+<li id="cite_note-test_.26_me-1"><span rel="mw:referencedBy"><a 
href="#cite_ref-test_.26_me_1-0">↑</a></span> hi</li>
+</ol>
 !! end
 
 # This test is wt2html only because we're permitting the serializer to produce
@@ -21364,6 +21431,7 @@
 '''foo'' <ref>test</ref>
 '''foo'' <div title="name">test</div>
 '''foo'' and <br> bar
+<references />
 !! html
 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
@@ -21372,6 +21440,9 @@
 '<i>foo</i> <span class="reference" id="cite_ref-1-0" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"test"},"attrs":{}}'><a 
href="#cite_note-1">[1]</a></span>
 '<i>foo</i> <div title="name">test</div>
 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{}}'>
+<li id="cite_note-1"><span rel="mw:referencedBy"><a 
href="#cite_ref-1">↑</a></span> test</li>
+</ol>
 !! end
 
 !! test
@@ -21485,8 +21556,12 @@
 !! wikitext
 foo <ref>''a''
  b</ref>
+<references />
 !! html
 <p>foo <span about="#mwt2" class="reference" id="cite_ref-1" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"&lt;i 
data-parsoid=&#39;{\"dsr\":[9,14,2,2]}&#39;>a&lt;/i>\n b"},"attrs":{}}'><a 
href="#cite_note-1">[1]</a></span></p>
+<ol class="references" typeof="mw:Extension/references" 
data-mw='{"name":"references","attrs":{}}'>
+<li id="cite_note-1"><span rel="mw:referencedBy"><a 
href="#cite_ref-1">↑</a></span> <i>a</i> b</li>
+</ol>
 !! end
 
 !! test

-- 
To view, visit https://gerrit.wikimedia.org/r/189974
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I79af2c34481cadbf0d68d9571928979adf559b58
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Marcoil <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Marcoil <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to