diff --git a/demo/markdownlint-browser.js b/demo/markdownlint-browser.js index 344a40cdc..1f4887b2d 100644 --- a/demo/markdownlint-browser.js +++ b/demo/markdownlint-browser.js @@ -412,7 +412,7 @@ module.exports.getLineMetadata = getLineMetadata; * @param {boolean} inTable Iff in a table. * @param {boolean} inItem Iff in a list item. * @param {boolean} inBreak Iff in semantic break. - * @param {boolean} inHTML Iff in HTML. + * @param {boolean} inHtml Iff in HTML block. * @returns {void} */ @@ -4216,8 +4216,9 @@ module.exports = { "tags": [ "headings", "atx", "spaces" ], "parser": "none", "function": function MD018(params, onError) { - forEachLine(lineMetadata(), (line, lineIndex, inCode, inFence, inTable, inItem, inBreak, inHTML) => { - if (!inCode && !inHTML && + forEachLine(lineMetadata(), (line, lineIndex, inCode, inFence, inTable, inItem, inBreak, inHtml) => { + if (!inCode && + !inHtml && /^#+[^# \t]/.test(line) && !/#\s*$/.test(line) && !line.startsWith("#️⃣")) { @@ -4359,8 +4360,9 @@ module.exports = { "tags": [ "headings", "atx_closed", "spaces" ], "parser": "none", "function": function MD020(params, onError) { - forEachLine(lineMetadata(), (line, lineIndex, inCode, inFence, inTable, inItem, inBreak, inHTML) => { - if (!inCode && !inHTML) { + forEachLine(lineMetadata(), (line, lineIndex, inCode, inFence, inTable, inItem, inBreak, inHtml) => { + if (!inCode && + !inHtml) { const match = /^(#+)([ \t]*)([^#]*?[^#\\])([ \t]*)((?:\\#)?)(#+)(\s*)$/.exec(line); if (match) { diff --git a/helpers/helpers.js b/helpers/helpers.js index 19a4a653b..976b85d93 100644 --- a/helpers/helpers.js +++ b/helpers/helpers.js @@ -400,7 +400,7 @@ module.exports.getLineMetadata = getLineMetadata; * @param {boolean} inTable Iff in a table. * @param {boolean} inItem Iff in a list item. * @param {boolean} inBreak Iff in semantic break. - * @param {boolean} inHTML Iff in HTML. + * @param {boolean} inHtml Iff in HTML block. * @returns {void} */ diff --git a/lib/md018.js b/lib/md018.js index b97f31cc4..333710fe2 100644 --- a/lib/md018.js +++ b/lib/md018.js @@ -13,8 +13,9 @@ module.exports = { "tags": [ "headings", "atx", "spaces" ], "parser": "none", "function": function MD018(params, onError) { - forEachLine(lineMetadata(), (line, lineIndex, inCode, inFence, inTable, inItem, inBreak, inHTML) => { - if (!inCode && !inHTML && + forEachLine(lineMetadata(), (line, lineIndex, inCode, inFence, inTable, inItem, inBreak, inHtml) => { + if (!inCode && + !inHtml && /^#+[^# \t]/.test(line) && !/#\s*$/.test(line) && !line.startsWith("#️⃣")) { diff --git a/lib/md020.js b/lib/md020.js index b2db40cce..2a6fe3a8a 100644 --- a/lib/md020.js +++ b/lib/md020.js @@ -13,8 +13,9 @@ module.exports = { "tags": [ "headings", "atx_closed", "spaces" ], "parser": "none", "function": function MD020(params, onError) { - forEachLine(lineMetadata(), (line, lineIndex, inCode, inFence, inTable, inItem, inBreak, inHTML) => { - if (!inCode && !inHTML) { + forEachLine(lineMetadata(), (line, lineIndex, inCode, inFence, inTable, inItem, inBreak, inHtml) => { + if (!inCode && + !inHtml) { const match = /^(#+)([ \t]*)([^#]*?[^#\\])([ \t]*)((?:\\#)?)(#+)(\s*)$/.exec(line); if (match) { diff --git a/test/ignore-html-block.md b/test/ignore-html-block.md index 4aca04d10..4bf4f033d 100644 --- a/test/ignore-html-block.md +++ b/test/ignore-html-block.md @@ -1,15 +1,13 @@ # ignore-html-block.md -## Title + diff --git a/test/snapshots/markdownlint-test-scenarios.js.md b/test/snapshots/markdownlint-test-scenarios.js.md index 0f1531ef2..037bf8624 100644 --- a/test/snapshots/markdownlint-test-scenarios.js.md +++ b/test/snapshots/markdownlint-test-scenarios.js.md @@ -17219,70 +17219,15 @@ Generated by [AVA](https://avajs.dev). { errors: [ - { - errorContext: '##Title2 {MD018}', - errorDetail: null, - errorRange: [ - 1, - 3, - ], - fixInfo: { - editColumn: 3, - insertText: ' ', - }, - lineNumber: 5, - ruleDescription: 'No space after hash on atx style heading', - ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md018.md', - ruleNames: [ - 'MD018', - 'no-missing-space-atx', - ], - }, - { - errorContext: '##Title3 {MD020}##', - errorDetail: null, - errorRange: [ - 1, - 3, - ], - fixInfo: { - deleteCount: 18, - editColumn: 1, - insertText: '## Title3 {MD020} ##', - }, - lineNumber: 11, - ruleDescription: 'No space inside hashes on closed atx style heading', - ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md020.md', - ruleNames: [ - 'MD020', - 'no-missing-space-closed-atx', - ], - }, { errorContext: null, - errorDetail: 'Element: div', + errorDetail: 'Element: style', errorRange: [ 1, - 5, - ], - fixInfo: null, - lineNumber: 7, - ruleDescription: 'Inline HTML', - ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md033.md', - ruleNames: [ - 'MD033', - 'no-inline-html', - ], - }, - { - errorContext: null, - errorDetail: 'Element: div', - errorRange: [ - 1, - 5, + 7, ], fixInfo: null, - lineNumber: 13, + lineNumber: 3, ruleDescription: 'Inline HTML', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md033.md', ruleNames: [ @@ -17293,19 +17238,17 @@ Generated by [AVA](https://avajs.dev). ], fixed: `# ignore-html-block.md␊ ␊ - ## Title␊ + ␊ `, } diff --git a/test/snapshots/markdownlint-test-scenarios.js.snap b/test/snapshots/markdownlint-test-scenarios.js.snap index b0942b901..f7bbf2074 100644 Binary files a/test/snapshots/markdownlint-test-scenarios.js.snap and b/test/snapshots/markdownlint-test-scenarios.js.snap differ