Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/389531 )

Change subject: T171381: Linter: Handle Optional end tags in missing-end-tag 
category
......................................................................

T171381: Linter: Handle Optional end tags in missing-end-tag category

Additional DOM analysis will be required for handling
tbody, thead, tfoot, and colgroup tags. But, these tags are
not common in our corpus, so not worth the extra effort.

Change-Id: I4455fa26a969fc8dea56273259140d13e9995236
---
M lib/config/WikitextConstants.js
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
3 files changed, 14 insertions(+), 1 deletion(-)


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

diff --git a/lib/config/WikitextConstants.js b/lib/config/WikitextConstants.js
index 1382b7c..a9dd312 100644
--- a/lib/config/WikitextConstants.js
+++ b/lib/config/WikitextConstants.js
@@ -253,6 +253,16 @@
                        'TABLE', 'TBODY', 'THEAD', 'TFOOT', 'CAPTION', 'TH', 
'TR', 'TD',
                ]),
 
+               // https://www.w3.org/TR/html5/tabular-data.html#the-tr-element
+               // https://www.w3.org/TR/html5/tabular-data.html#the-td-element
+               // https://www.w3.org/TR/html5/tabular-data.html#the-th-element
+               //
+               // tbody, tfoot, thead, colgroup also have optional end tag 
requirements
+               // but they are conditional on other properties of the DOM.
+               OptionalEndTags: new Set([
+                       'TR', 'TD', 'TH'
+               ]),
+
                // Table tags that can be parents
                ParentTableTags: new Set([
                        "TABLE", "TBODY", "THEAD", "TFOOT", "TR",
diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index d50a5ec..ed5794b 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -317,7 +317,7 @@
                                        }
                                        adjDp.tmp.linted = true;
                                        env.log('lint/misnested-tag', lintObj);
-                               } else if (DU.hasLiteralHTMLMarker(dp)) {
+                               } else if (DU.hasLiteralHTMLMarker(dp) && 
!Consts.HTML.OptionalEndTags.has(c.nodeName)) {
                                        env.log('lint/missing-end-tag', 
lintObj);
                                }
                        }
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index be4fe7d..abf642d 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -67,6 +67,9 @@
                                result[0].params.should.have.a.property("name", 
"p");
                        });
                });
+               it('should not flag tags where end tags are optional in the 
spec', function() {
+                       return expectEmptyResults('<table><tr><th>heading 
1<tr><td>col 1<td>col 2</table>');
+               });
        });
 
        describe('STRIPPED TAGS', function() {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4455fa26a969fc8dea56273259140d13e9995236
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>

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

Reply via email to