diff --git a/demo/markdownlint-browser.js b/demo/markdownlint-browser.js
index 88bdb947..1f4887b2 100644
--- a/demo/markdownlint-browser.js
+++ b/demo/markdownlint-browser.js
@@ -365,7 +365,7 @@ module.exports.filterTokens = filterTokens;
*/
function getLineMetadata(params) {
const lineMetadata = params.lines.map(
- (line, index) => [ line, index, false, 0, false, false, false ]
+ (line, index) => [ line, index, false, 0, false, false, false, false ]
);
filterTokens(params, "fence", (token) => {
lineMetadata[token.map[0]][3] = 1;
@@ -394,6 +394,11 @@ function getLineMetadata(params) {
filterTokens(params, "hr", (token) => {
lineMetadata[token.map[0]][6] = true;
});
+ filterTokens(params, "html_block", (token) => {
+ for (let i = token.map[0]; i < token.map[1]; i++) {
+ lineMetadata[i][7] = true;
+ }
+ });
return lineMetadata;
}
module.exports.getLineMetadata = getLineMetadata;
@@ -407,6 +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 block.
* @returns {void}
*/
@@ -4210,8 +4216,9 @@ module.exports = {
"tags": [ "headings", "atx", "spaces" ],
"parser": "none",
"function": function MD018(params, onError) {
- forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
+ forEachLine(lineMetadata(), (line, lineIndex, inCode, inFence, inTable, inItem, inBreak, inHtml) => {
if (!inCode &&
+ !inHtml &&
/^#+[^# \t]/.test(line) &&
!/#\s*$/.test(line) &&
!line.startsWith("#️⃣")) {
@@ -4353,8 +4360,9 @@ module.exports = {
"tags": [ "headings", "atx_closed", "spaces" ],
"parser": "none",
"function": function MD020(params, onError) {
- forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
- if (!inCode) {
+ 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 e8ed99bf..976b85d9 100644
--- a/helpers/helpers.js
+++ b/helpers/helpers.js
@@ -353,7 +353,7 @@ module.exports.filterTokens = filterTokens;
*/
function getLineMetadata(params) {
const lineMetadata = params.lines.map(
- (line, index) => [ line, index, false, 0, false, false, false ]
+ (line, index) => [ line, index, false, 0, false, false, false, false ]
);
filterTokens(params, "fence", (token) => {
lineMetadata[token.map[0]][3] = 1;
@@ -382,6 +382,11 @@ function getLineMetadata(params) {
filterTokens(params, "hr", (token) => {
lineMetadata[token.map[0]][6] = true;
});
+ filterTokens(params, "html_block", (token) => {
+ for (let i = token.map[0]; i < token.map[1]; i++) {
+ lineMetadata[i][7] = true;
+ }
+ });
return lineMetadata;
}
module.exports.getLineMetadata = getLineMetadata;
@@ -395,6 +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 block.
* @returns {void}
*/
diff --git a/lib/md018.js b/lib/md018.js
index 007c227a..333710fe 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) => {
+ 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 0207d9d6..2a6fe3a8 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) => {
- if (!inCode) {
+ 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
new file mode 100644
index 00000000..4bf4f033
--- /dev/null
+++ b/test/ignore-html-block.md
@@ -0,0 +1,13 @@
+# ignore-html-block.md
+
+
diff --git a/test/snapshots/markdownlint-test-scenarios.js.md b/test/snapshots/markdownlint-test-scenarios.js.md
index 6f31182f..530873af 100644
--- a/test/snapshots/markdownlint-test-scenarios.js.md
+++ b/test/snapshots/markdownlint-test-scenarios.js.md
@@ -19683,6 +19683,45 @@ Generated by [AVA](https://avajs.dev).
`,
}
+## ignore-html-block.md
+
+> Snapshot 1
+
+ {
+ errors: [
+ {
+ errorContext: null,
+ errorDetail: 'Element: style',
+ errorRange: [
+ 1,
+ 7,
+ ],
+ fixInfo: null,
+ lineNumber: 3,
+ ruleDescription: 'Inline HTML',
+ ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md033.md',
+ ruleNames: [
+ 'MD033',
+ 'no-inline-html',
+ ],
+ },
+ ],
+ fixed: `# ignore-html-block.md␊
+ ␊
+ ␊
+ `,
+ }
+
## inconsistent_bullet_indent_same_level.md
> Snapshot 1
diff --git a/test/snapshots/markdownlint-test-scenarios.js.snap b/test/snapshots/markdownlint-test-scenarios.js.snap
index e7678c20..8bbe46a8 100644
Binary files a/test/snapshots/markdownlint-test-scenarios.js.snap and b/test/snapshots/markdownlint-test-scenarios.js.snap differ