jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/398418 )

Change subject: Linter: Suppress false positives for multiline-table-in-list
......................................................................


Linter: Suppress false positives for multiline-table-in-list

* Content of ref tags end up in the references section which
  happen to be rendered as an ordered list.

* So, the logic that looks for tables embedded in lists should
  ignore instances when that list happens to be the references list.

* Added a new mocha test to verify this expectation.

* Verified on itwiki:Padova

Change-Id: If633fc34584bde6a7f13ba903a563026fd304272
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
2 files changed, 14 insertions(+), 2 deletions(-)

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



diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index ffa1079..517b2ad 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -789,10 +789,19 @@
        detectMultipleUnclosedFormattingTags(lints);
 }
 
+function hasListAncestor(node) {
+       while (node && node.nodeName !== 'LI') {
+               node = node.parentNode;
+       }
+
+       // If the list item comes from references content, ignore it
+       return node && 
!(/mw:Extension\/references/.test(node.parentNode.getAttribute('typeof')));
+}
+
 function logPHPParserBug(env, node, dp, tplInfo) {
        if (!DU.isLiteralHTMLNode(node) ||
                node.nodeName !== 'TABLE' ||
-               !DU.hasAncestorOfName(node, 'LI') ||
+               !hasListAncestor(node) ||
                !/\n/.test(node.outerHTML)
        ) {
                return;
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index 69f02ad..9ee19f5 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -852,9 +852,12 @@
                                        
result[0].params.should.have.a.property("ancestorName", "li");
                                });
                        });
-                       it('should not detect single-line HTML tables in lists 
(2)', function() {
+                       it('should not detect single-line HTML tables in 
lists', function() {
                                return expectEmptyResults("* 
<div><table><tr><td>x</td></tr></table></div>");
                        });
+                       it('should not detect multiline HTML tables in ref 
tags', function() {
+                               return expectEmptyResults("a 
<ref><table>\n<tr><td>b</td></tr>\n</table></ref> <references />");
+                       });
                });
        });
 });

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If633fc34584bde6a7f13ba903a563026fd304272
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: C. Scott Ananian <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Sbailey <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to