Arlolra has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/179210

Change subject: Fix regression in definition list parsing
......................................................................

Fix regression in definition list parsing

 * Introduced in 220374b36ac70f100333050cffdfc6de8d51876e.

 * Accounts for tables pushing the frame..

 * Fixes the rt of svwiki/Prince_of_Wales_Conference?oldid=22895440

 * Adds a test that exposes a different bug. It looks like the php
   parser closes all lists on a table end. To be investigated in a
   follow up patch.

Change-Id: I2e8cf99e92246194f335223cc71555d763be3f1c
---
M lib/ext.core.ListHandler.js
M tests/parserTests-blacklist.js
M tests/parserTests.txt
3 files changed, 29 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/10/179210/1

diff --git a/lib/ext.core.ListHandler.js b/lib/ext.core.ListHandler.js
index d93b260..377323a 100644
--- a/lib/ext.core.ListHandler.js
+++ b/lib/ext.core.ListHandler.js
@@ -84,7 +84,11 @@
 
        // Keep track of open tags per list frame in order to prevent colons
        // starting lists illegally. Php's findColonNoLinks.
-       if ( token.constructor === TagTk ) {
+       if ( token.constructor === TagTk &&
+               // Table tokens will push the frame and remain balanced.
+               // They're safe to ignore in the bookkeeping.
+               token.name !== "table"
+       ) {
                this.currListFrame.numOpenTags += 1;
        } else if ( token.constructor === EndTagTk && 
this.currListFrame.numOpenTags > 0 ) {
                this.currListFrame.numOpenTags -= 1;
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index 6b3b958..bc9ba56 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -51,6 +51,7 @@
 add("wt2html", "4. Indent-Pre and extension tags", "<pre 
data-parsoid='{\"dsr\":[0,39,1,0]}'>a <span typeof=\"mw:Extension/gallery\" 
about=\"#mwt1\" 
data-parsoid='{\"stx\":\"html\",\"src\":\"&lt;gallery>\\nFile:foobar.jpg\\n&lt;/gallery>\",\"tagWidths\":[9,10],\"dsr\":[3,39,9,10]}'>&lt;gallery>\nFile:foobar.jpg\n&lt;/gallery></span></pre>");
 add("wt2html", "6. Pre-blocks should extend across lines with leading WS even 
when there is no wrappable content", "<pre 
data-parsoid='{\"dsr\":[0,26,1,0]}'>a\n\n <!-- continue -->\nb</pre>\n\n<pre 
data-parsoid='{\"dsr\":[28,30,1,0]}'>c</pre>\n \n<p 
data-parsoid='{\"dsr\":[33,34,0,0]}'>d</p>");
 add("wt2html", "Definition Lists: colons occurring in tags", "<dl 
data-parsoid='{\"dsr\":[0,93,0,0]}'><dt 
data-parsoid='{\"dsr\":[0,2,1,0]}'>a</dt><dd 
data-parsoid='{\"stx\":\"row\",\"dsr\":[2,4,1,0]}'>b</dd>\n<dt 
data-parsoid='{\"dsr\":[5,15,1,0]}'><b 
data-parsoid='{\"dsr\":[6,15,3,3]}'>a:b</b></dt>\n<dt 
data-parsoid='{\"dsr\":[16,27,1,0]}'><i 
data-parsoid='{\"stx\":\"html\",\"dsr\":[17,27,3,4]}'>a:b</i></dt>\n<dt 
data-parsoid='{\"dsr\":[28,45,1,0]}'><span 
data-parsoid='{\"stx\":\"html\",\"dsr\":[29,45,6,7]}'>a:b</span></dt>\n<dt 
data-parsoid='{\"dsr\":[46,61,1,0]}'><div 
data-parsoid='{\"stx\":\"html\",\"dsr\":[47,61,5,6]}'>a:b</div></dt>\n<dt 
data-parsoid='{\"dsr\":[62,71,1,0]}'><span typeof=\"mw:Nowiki\" 
data-parsoid='{\"src\":\"{{\",\"dsr\":[63,65,0,0]}'>{{</span>echo|a</dt><dd 
data-parsoid='{\"stx\":\"row\",\"dsr\":[71,75,1,0]}'>b<span 
typeof=\"mw:Nowiki\" 
data-parsoid='{\"src\":\"}}\",\"dsr\":[73,75,0,0]}'>}}</span></dd>\n<dt 
data-parsoid='{\"dsr\":[76,93,1,0]}'><span typeof=\"mw:Nowiki\" 
data-parsoid='{\"src\":\"{{\",\"dsr\":[77,79,0,0]}'>{{</span>echo|<i 
data-parsoid='{\"dsr\":[84,91,2,2]}'>a:b</i><span typeof=\"mw:Nowiki\" 
data-parsoid='{\"src\":\"}}\",\"dsr\":[91,93,0,0]}'>}}</span></dt></dl>");
+add("wt2html", "Definition Lists: colons and tables", "<dl 
data-parsoid='{\"dsr\":[0,21,0,0]}'><dd 
data-parsoid='{\"dsr\":[0,10,1,0]}'><table 
data-parsoid='{\"dsr\":[1,10,2,2]}'>\n<tbody 
data-parsoid='{\"dsr\":[4,8,0,0]}'><tr 
data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[4,7,0,0]}'><td
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[4,7,1,0]}'> 
x</td></tr>\n</tbody></table></dd>\n<dd 
data-parsoid='{\"dsr\":[11,21,1,0]}'><table 
data-parsoid='{\"dsr\":[12,21,2,2]}'>\n<tbody 
data-parsoid='{\"dsr\":[15,19,0,0]}'><tr 
data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[15,18,0,0]}'><td
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[15,18,1,0]}'> 
y</td></tr>\n</tbody></table></dd></dl>");
 add("wt2html", "External links: Free with trailing punctuation", "<p 
data-parsoid='{\"dsr\":[0,198,0,0]}'><a rel=\"mw:ExtLink\" 
href=\"http://example.com\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[0,18,0,0]}'>http://example.com</a>,\n<a 
rel=\"mw:ExtLink\" href=\"http://example.com;\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[20,39,0,0]}'>http://example.com;</a>\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com\\\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[40,59,0,0]}'>http://example.com\\</a>\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[60,78,0,0]}'>http://example.com</a>.\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[80,98,0,0]}'>http://example.com</a>:\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com!\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[100,119,0,0]}'>http://example.com!</a>\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com?\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[120,139,0,0]}'>http://example.com?</a>\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[140,158,0,0]}'>http://example.com</a>)\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com/url_with_(brackets)\" 
data-parsoid='{\"stx\":\"url\",\"dsr\":[160,198,0,0]}'>http://example.com/url_with_(brackets)</a></p>");
 add("wt2html", "Bug 2702: Mismatched <i>, <b> and <a> tags are invalid", "<p 
data-parsoid='{\"dsr\":[0,204,0,0]}'><i 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[0,29,2,0]}'><a 
rel=\"mw:ExtLink\" href=\"http://example.com\"; 
data-parsoid='{\"targetOff\":22,\"contentOffsets\":[22,28],\"dsr\":[2,29,20,1]}'>text<i
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[26,28,2,0]}'></i></a></i>\n<a 
rel=\"mw:ExtLink\" href=\"http://example.com\"; 
data-parsoid='{\"targetOff\":50,\"contentOffsets\":[50,57],\"dsr\":[30,58,20,1]}'><b
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[50,57,3,0]}'>text</b></a><b 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[58,61,3,0]}'></b>\n<i 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[62,106,2,0]}'>Something <a 
rel=\"mw:ExtLink\" href=\"http://example.com\"; 
data-parsoid='{\"targetOff\":94,\"contentOffsets\":[94,105],\"dsr\":[74,106,20,1]}'>in
 italic<i 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[103,105,2,0]}'></i></a></i>\n<i
 data-parsoid='{\"dsr\":[107,164,2,2]}'>Something <a rel=\"mw:ExtLink\" 
href=\"http://example.com\"; 
data-parsoid='{\"targetOff\":139,\"contentOffsets\":[139,160],\"dsr\":[119,161,20,1]}'>mixed<b
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[144,160,3,0]}'><i 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[147,160,2,0]}'>, even 
bold</i></b></a>'</i>\n<b 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[165,204,3,0]}'><i 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[168,204,2,0]}'>Now <a 
rel=\"mw:ExtLink\" href=\"http://example.com\"; 
data-parsoid='{\"targetOff\":194,\"contentOffsets\":[194,203],\"dsr\":[174,204,20,1]}'>both<b
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[198,203,3,0]}'><i 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[201,203,2,0]}'></i></b></a></i></b></p>");
 add("wt2html", "External link containing double-single-quotes in text embedded 
in italics (bug 4598 sanity check)", "<p data-parsoid='{\"dsr\":[0,60,0,0]}'><i 
data-parsoid='{\"dsr\":[0,60,2,2]}'>Some <a rel=\"mw:ExtLink\" 
href=\"http://example.com/\"; 
data-parsoid='{\"targetOff\":28,\"contentOffsets\":[28,56],\"dsr\":[7,57,21,1]}'>pretty
 <i data-parsoid='{\"dsr\":[35,46,2,2]}'>italics</i> and stuff</a>!</i></p>");
@@ -561,6 +562,7 @@
 add("html2html", "Definition list with wikilink containing colon", "<dl 
data-parsoid='{\"dsr\":[0,95,0,0]}'><dt data-parsoid='{\"dsr\":[0,24,1,0]}'> 
[/index.php?title=Help</dt><dd 
data-parsoid='{\"stx\":\"row\",\"dsr\":[24,60,1,0]}'>FAQ&amp;action=edit&amp;redlink=1
 Help:FAQ]</dd>\n<dd data-parsoid='{\"dsr\":[61,95,1,0]}'> The least-read page 
on Wikipedia</dd></dl>\n");
 add("html2html", "Definition lists: colon in HTML attribute", "<dl 
data-parsoid='{\"dsr\":[0,12,0,0]}'><dt data-parsoid='{\"dsr\":[0,12,1,0]}'> <b 
data-parsoid='{\"dsr\":[2,12,3,3]}'>bold</b></dt></dl>\n");
 add("html2html", "Definition Lists: Nesting: Multi-level (Parsoid only)", 
"\n<dl data-parsoid='{\"dsr\":[1,116,0,0]}'><dt 
data-parsoid='{\"dsr\":[1,6,1,0]}'> t1 </dt>\n<dd 
data-parsoid='{\"dsr\":[7,17,1,0]}'> d1      </dd>\n<dt 
data-parsoid='{\"dsr\":[18,116,1,0]}'><dl 
data-parsoid='{\"dsr\":[19,116,0,0]}'><dt data-parsoid='{\"dsr\":[19,24,1,0]}'> 
t2 </dt>\n<dd data-parsoid='{\"dsr\":[25,62,1,0]}'> <span typeof=\"mw:Nowiki\" 
data-parsoid='{\"dsr\":[28,48,8,9]}'>:d2</span>              </dd>\n<dt 
data-parsoid='{\"dsr\":[63,116,2,0]}'><dl 
data-parsoid='{\"dsr\":[65,116,0,0]}'><dt data-parsoid='{\"dsr\":[65,70,1,0]}'> 
t3 </dt>\n<dd data-parsoid='{\"dsr\":[71,116,1,0]}'> <span typeof=\"mw:Nowiki\" 
data-parsoid='{\"dsr\":[75,96,8,9]}'>::d3</span>                    
</dd></dl></dt></dl></dt></dl>\n");
+add("html2html", "Definition Lists: colons and tables", "<dl 
data-parsoid='{\"dsr\":[0,26,0,0]}'><dd data-parsoid='{\"dsr\":[0,12,1,0]}'> 
<table data-parsoid='{\"dsr\":[2,12,2,2]}'>\n\n<tbody 
data-parsoid='{\"dsr\":[6,10,0,0]}'><tr 
data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[6,9,0,0]}'><td
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[6,9,1,0]}'> 
x</td></tr>\n</tbody></table></dd>\n\n<dd data-parsoid='{\"dsr\":[14,26,1,0]}'> 
<table data-parsoid='{\"dsr\":[16,26,2,2]}'>\n\n<tbody 
data-parsoid='{\"dsr\":[20,24,0,0]}'><tr 
data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[20,23,0,0]}'><td
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[20,23,1,0]}'> 
y</td></tr>\n</tbody></table></dd></dl>\n");
 add("html2html", "External links: Free with trailing punctuation", "<p 
data-parsoid='{\"dsr\":[0,198,0,0]}'><a rel=\"mw:ExtLink\" 
href=\"http://example.com\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[0,18,0,0]}'>http://example.com</a>,\n<a 
rel=\"mw:ExtLink\" href=\"http://example.com;\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[20,39,0,0]}'>http://example.com;</a>\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com\\\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[40,59,0,0]}'>http://example.com\\</a>\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[60,78,0,0]}'>http://example.com</a>.\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[80,98,0,0]}'>http://example.com</a>:\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com!\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[100,119,0,0]}'>http://example.com!</a>\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com?\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[120,139,0,0]}'>http://example.com?</a>\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com\"; 
data-parsoid='{\"stx\":\"url\",\"dsr\":[140,158,0,0]}'>http://example.com</a>)\n<a
 rel=\"mw:ExtLink\" href=\"http://example.com/url_with_(brackets)\" 
data-parsoid='{\"stx\":\"url\",\"dsr\":[160,198,0,0]}'>http://example.com/url_with_(brackets)</a></p>\n");
 add("html2html", "External links: Clickable images", "<p 
data-parsoid='{\"dsr\":[0,78,0,0]}'>ja-style clickable images: <img 
src=\"http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png\"; 
alt=\"Ncwikicol.png\" rel=\"mw:externalImage\" 
data-parsoid='{\"dsr\":[27,78,null,null]}'/></p>\n");
 add("html2html", "Indented table markup mixed with indented pre content 
(proposed in bug 6200)", " <table 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[1,58,2,0]}'>\n \n <tbody 
data-parsoid='{\"dsr\":[7,58,0,0]}'><tr 
data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[7,58,0,0]}'><td
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[7,58,1,0]}'>\n<pre 
data-parsoid='{\"dsr\":[9,58,1,0]}'>Text that should be rendered preformatted 
\n\n|}</pre></td></tr></tbody></table>\n");
@@ -1039,6 +1041,7 @@
 add("html2wt", "Definition Lists: Mixed Lists: Test 11", "\n*#*#;*;; foo 
:bar\n*#*#; boo :baz\n");
 add("html2wt", "Definition Lists: Weird Ones: Test 1", "\n*#;*::;; foo : bar 
(who uses this?)\n");
 add("html2wt", "Definition Lists: colons occurring in tags", "; a\n: b\n; 
'''<nowiki>a:b</nowiki>'''\n; ''<nowiki>a:b</nowiki>''\n; 
<span><nowiki>a:b</nowiki></span>\n; <div><nowiki>a:b</nowiki></div>\n; a\n: 
b\n; ''<nowiki>a:b</nowiki>''\n");
+add("html2wt", "Definition Lists: colons and tables", ": {|\n\n| x\n|}\n\n: 
{|\n\n| y\n|}\n");
 add("html2wt", "External links: URL in text", "URL in text: 
http://example.com\n";);
 add("html2wt", "External links: Clickable images", "ja-style clickable images: 
http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png\n";);
 add("html2wt", "External links: raw ampersand", "Old & use: http://x&y\n";);
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 0fe2502..e5b27a8 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -3989,6 +3989,27 @@
 
 !! end
 
+!! test
+Definition Lists: colons and tables
+!! wikitext
+:{|
+| x
+|}
+:{|
+| y
+|}
+!! html
+<dl><dd><table>
+<tr>
+<td> x
+</td></tr></table></dd></dl>
+<dl><dd><table>
+<tr>
+<td> y
+</td></tr></table></dd></dl>
+
+!! end
+
 
 ###
 ### External links

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e8cf99e92246194f335223cc71555d763be3f1c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <abrea...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to