jenkins-bot has submitted this change and it was merged. Change subject: linter: Don't log obsolete HTML tags for auto inserted elements ......................................................................
linter: Don't log obsolete HTML tags for auto inserted elements For example, the wikitext '<big>foo\n\n\nbar' is transformed into '<big>foo</big>\n\n<big>bar</big>' but it doesn't make sense to log two obsolete HTML elements - just one is necessary for the warning to go away. Change-Id: Ic9c04c7ec549a3dd1cffe3a4eef6fe7385b0bf0a --- M lib/wt2html/pp/handlers/linter.js M tests/mocha/lintertest.js 2 files changed, 16 insertions(+), 10 deletions(-) Approvals: Arlolra: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/wt2html/pp/handlers/linter.js b/lib/wt2html/pp/handlers/linter.js index 1ea45ed..234e90d 100644 --- a/lib/wt2html/pp/handlers/linter.js +++ b/lib/wt2html/pp/handlers/linter.js @@ -206,20 +206,13 @@ * */ function logObsoleteHTMLTags(env, c, dp, tplInfo) { - var dsr = dp.dsr; - var inTransclusion = false; var re = /^(BIG|CENTER|FONT|STRIKE|TT)$/; - if (tplInfo) { - dsr = tplInfo.dsr; - inTransclusion = true; - } - - if (re.test(c.nodeName)) { + if (!(dp.autoInsertedStart && dp.autoInsertedEnd) && re.test(c.nodeName)) { var lintObj = { src: env.page.src, - dsr: dsr, - inTransclusion: inTransclusion, + dsr: tplInfo ? tplInfo.dsr : dp.dsr, + inTransclusion: !!tplInfo, params: { name: c.nodeName.toLowerCase() }, }; env.log('lint/obsolete-tag', lintObj); diff --git a/tests/mocha/lintertest.js b/tests/mocha/lintertest.js index 0146bfc..6ebd188 100644 --- a/tests/mocha/lintertest.js +++ b/tests/mocha/lintertest.js @@ -83,6 +83,19 @@ result[0].params.should.have.a.property("name", "big"); }); }); + it('should not lint auto-inserted obsolete tags', function() { + return parseWT('<big>foo\n\n\nbar').then(function(result) { + // obsolete-tag and missing-end-tag + result.should.have.length(2); + result[0].should.have.a.property("type", "missing-end-tag"); + result[1].should.have.a.property("type", "obsolete-tag"); + result[1].should.have.a.property("wiki", "enwiki"); + result[1].dsr.should.include.members([ 0, 8, 5, 0 ]); + result[1].should.have.a.property("src", "<big>foo"); + result[1].should.have.a.property("params"); + result[1].params.should.have.a.property("name", "big"); + }); + }); it('should lint fostered content correctly', function() { return parseWT('{|\nfoo\n|-\n| bar\n|}').then(function(result) { result.should.have.length(1); -- To view, visit https://gerrit.wikimedia.org/r/316046 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic9c04c7ec549a3dd1cffe3a4eef6fe7385b0bf0a Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits