diff --git a/demo/markdownlint-browser.js b/demo/markdownlint-browser.js index 45a17a70..db149627 100644 --- a/demo/markdownlint-browser.js +++ b/demo/markdownlint-browser.js @@ -1454,12 +1454,12 @@ function filterByPredicate(tokens, allowed, transformChildren) { * Filter a list of Micromark tokens by type. * * @param {Token[]} tokens Micromark tokens. - * @param {string[]} allowed Types to allow. + * @param {string[]} types Types to allow. * @returns {Token[]} Filtered tokens. */ -function filterByTypes(tokens, allowed) { +function filterByTypes(tokens, types) { var predicate = function predicate(token) { - return allowed.includes(token.type); + return types.includes(token.type); }; var flatTokens = tokens[flatTokensSymbol]; if (flatTokens) { @@ -1508,6 +1508,22 @@ function getHtmlTagInfo(token) { return null; } +/** + * Gets the nearest parent of the specified type for a Micromark token. + * + * @param {Token} token Micromark token. + * @param {string[]} types Types to allow. + * @returns {Token | null} Parent token. + */ +function getTokenParentOfType(token, types) { + /** @type {Token | null} */ + var current = token; + while ((current = current.parent) && !types.includes(current.type)) { + // Empty + } + return current; +} + /** * Get the text of a single token from a list of Micromark tokens by type. * @@ -1522,6 +1538,16 @@ function getTokenTextByType(tokens, type) { return filtered.length === 1 ? filtered[0].text : null; } +/** + * Determines if a Micromark token has an htmlFlow-type parent. + * + * @param {Token} token Micromark token. + * @returns {boolean} True iff the token has an htmlFlow-type parent. + */ +function inHtmlFlow(token) { + return getTokenParentOfType(token, ["htmlFlow"]) !== null; +} + /** * Determines a list of Micromark tokens matches and returns a subset. * @@ -1564,7 +1590,9 @@ module.exports = { getHeadingLevel: getHeadingLevel, getHtmlTagInfo: getHtmlTagInfo, getMicromarkEvents: getMicromarkEvents, + getTokenParentOfType: getTokenParentOfType, getTokenTextByType: getTokenTextByType, + inHtmlFlow: inHtmlFlow, matchAndGetTokensByType: matchAndGetTokensByType, tokenIfType: tokenIfType }; @@ -3428,13 +3456,16 @@ var _require = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _require.addError, addErrorDetailIf = _require.addErrorDetailIf; var _require2 = __webpack_require__(/*! ../helpers/micromark.cjs */ "../helpers/micromark.cjs"), - filterByTypes = _require2.filterByTypes; + filterByTypes = _require2.filterByTypes, + inHtmlFlow = _require2.inHtmlFlow; module.exports = { "names": ["MD005", "list-indent"], "description": "Inconsistent indentation for list items at the same level", "tags": ["bullet", "ul", "indentation"], "function": function MD005(params, onError) { - var lists = filterByTypes(params.parsers.micromark.tokens, ["listOrdered", "listUnordered"]); + var lists = filterByTypes(params.parsers.micromark.tokens, ["listOrdered", "listUnordered"]).filter(function (list) { + return !inHtmlFlow(list); + }); var _iterator = _createForOfIteratorHelper(lists), _step; try { @@ -3570,12 +3601,16 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var _require = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _require.addErrorDetailIf; var _require2 = __webpack_require__(/*! ../helpers/micromark.cjs */ "../helpers/micromark.cjs"), - filterByTypes = _require2.filterByTypes; + filterByTypes = _require2.filterByTypes, + getTokenParentOfType = _require2.getTokenParentOfType, + inHtmlFlow = _require2.inHtmlFlow; /** * @typedef {import("../helpers/micromark.cjs").Token} Token */ +var unorderedListTypes = ["blockQuotePrefix", "listItemPrefix", "listUnordered"]; +var unorderedParentTypes = ["blockQuote", "listOrdered", "listUnordered"]; module.exports = { "names": ["MD007", "ul-indent"], "description": "Unordered list indentation", @@ -3586,7 +3621,7 @@ module.exports = { var startIndent = Number(params.config.start_indent || indent); var unorderedListNesting = new Map(); var lastBlockQuotePrefix = null; - var tokens = filterByTypes(params.parsers.micromark.tokens, ["blockQuotePrefix", "listItemPrefix", "listUnordered"]); + var tokens = filterByTypes(params.parsers.micromark.tokens, unorderedListTypes); var _iterator = _createForOfIteratorHelper(tokens), _step; try { @@ -3602,20 +3637,19 @@ module.exports = { var nesting = 0; /** @type {Token | null} */ var current = token; - while (current = current.parent) { + while (current = getTokenParentOfType(current, unorderedParentTypes)) { if (current.type === "listUnordered") { nesting++; + continue; } else if (current.type === "listOrdered") { nesting = -1; - break; - } else if (current.type === "blockQuote") { - break; } + break; } if (nesting >= 0) { unorderedListNesting.set(token, nesting); } - } else { + } else if (!inHtmlFlow(token)) { // listItemPrefix var _nesting = unorderedListNesting.get(parent); if (_nesting !== undefined) { @@ -4306,7 +4340,8 @@ var _require = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), isBlankLine = _require.isBlankLine; var _require2 = __webpack_require__(/*! ../helpers/micromark.cjs */ "../helpers/micromark.cjs"), filterByTypes = _require2.filterByTypes, - getHeadingLevel = _require2.getHeadingLevel; + getHeadingLevel = _require2.getHeadingLevel, + inHtmlFlow = _require2.inHtmlFlow; var defaultLines = 1; var getLinesFunction = function getLinesFunction(linesParam) { if (Array.isArray(linesParam)) { @@ -4349,7 +4384,9 @@ module.exports = { var getLinesBelow = getLinesFunction(params.config.lines_below); var lines = params.lines, parsers = params.parsers; - var headings = filterByTypes(parsers.micromark.tokens, ["atxHeading", "setextHeading"]); + var headings = filterByTypes(parsers.micromark.tokens, ["atxHeading", "setextHeading"]).filter(function (heading) { + return !inHtmlFlow(heading); + }); var _iterator2 = _createForOfIteratorHelper(headings), _step2; try { @@ -5327,7 +5364,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var _require = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _require.addError; var _require2 = __webpack_require__(/*! ../helpers/micromark.cjs */ "../helpers/micromark.cjs"), - filterByPredicate = _require2.filterByPredicate; + filterByPredicate = _require2.filterByPredicate, + inHtmlFlow = _require2.inHtmlFlow; module.exports = { "names": ["MD037", "no-space-in-emphasis"], "description": "Spaces inside emphasis markers", @@ -5373,7 +5411,7 @@ module.exports = { type = child.type; if (type === "data" && text.length <= 3) { var _emphasisTokens = emphasisTokensByMarker.get(text); - if (_emphasisTokens) { + if (_emphasisTokens && !inHtmlFlow(child)) { _emphasisTokens.push(child); } } @@ -5459,6 +5497,7 @@ var _require = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _require.addErrorContext; var _require2 = __webpack_require__(/*! ../helpers/micromark.cjs */ "../helpers/micromark.cjs"), filterByTypes = _require2.filterByTypes, + inHtmlFlow = _require2.inHtmlFlow, tokenIfType = _require2.tokenIfType; var leftSpaceRe = /^\s(?:[^`]|$)/; var rightSpaceRe = /[^`]\s$/; @@ -5477,13 +5516,15 @@ module.exports = { "description": "Spaces inside code span elements", "tags": ["whitespace", "code"], "function": function MD038(params, onError) { - var codeTextTokens = filterByTypes(params.parsers.micromark.tokens, ["codeText"]); - var _iterator = _createForOfIteratorHelper(codeTextTokens), + var codeTexts = filterByTypes(params.parsers.micromark.tokens, ["codeText"]).filter(function (codeText) { + return !inHtmlFlow(codeText); + }); + var _iterator = _createForOfIteratorHelper(codeTexts), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { - var token = _step.value; - var children = token.children; + var codeText = _step.value; + var children = codeText.children; var first = 0; var last = children.length - 1; var startSequence = tokenIfType(children[first], "codeTextSequence"); diff --git a/helpers/micromark.cjs b/helpers/micromark.cjs index 96e68d77..e4cb21e9 100644 --- a/helpers/micromark.cjs +++ b/helpers/micromark.cjs @@ -281,11 +281,11 @@ function filterByPredicate(tokens, allowed, transformChildren) { * Filter a list of Micromark tokens by type. * * @param {Token[]} tokens Micromark tokens. - * @param {string[]} allowed Types to allow. + * @param {string[]} types Types to allow. * @returns {Token[]} Filtered tokens. */ -function filterByTypes(tokens, allowed) { - const predicate = (token) => allowed.includes(token.type); +function filterByTypes(tokens, types) { + const predicate = (token) => types.includes(token.type); const flatTokens = tokens[flatTokensSymbol]; if (flatTokens) { return flatTokens.filter(predicate); @@ -336,6 +336,22 @@ function getHtmlTagInfo(token) { return null; } +/** + * Gets the nearest parent of the specified type for a Micromark token. + * + * @param {Token} token Micromark token. + * @param {string[]} types Types to allow. + * @returns {Token | null} Parent token. + */ +function getTokenParentOfType(token, types) { + /** @type {Token | null} */ + let current = token; + while ((current = current.parent) && !types.includes(current.type)) { + // Empty + } + return current; +} + /** * Get the text of a single token from a list of Micromark tokens by type. * @@ -348,6 +364,16 @@ function getTokenTextByType(tokens, type) { return (filtered.length === 1) ? filtered[0].text : null; } +/** + * Determines if a Micromark token has an htmlFlow-type parent. + * + * @param {Token} token Micromark token. + * @returns {boolean} True iff the token has an htmlFlow-type parent. + */ +function inHtmlFlow(token) { + return getTokenParentOfType(token, [ "htmlFlow" ]) !== null; +} + /** * Determines a list of Micromark tokens matches and returns a subset. * @@ -391,7 +417,9 @@ module.exports = { getHeadingLevel, getHtmlTagInfo, getMicromarkEvents, + getTokenParentOfType, getTokenTextByType, + inHtmlFlow, matchAndGetTokensByType, tokenIfType }; diff --git a/lib/md005.js b/lib/md005.js index 39a7e8be..d86253ba 100644 --- a/lib/md005.js +++ b/lib/md005.js @@ -3,7 +3,7 @@ "use strict"; const { addError, addErrorDetailIf } = require("../helpers"); -const { filterByTypes } = require("../helpers/micromark.cjs"); +const { filterByTypes, inHtmlFlow } = require("../helpers/micromark.cjs"); module.exports = { "names": [ "MD005", "list-indent" ], @@ -13,7 +13,7 @@ module.exports = { const lists = filterByTypes( params.parsers.micromark.tokens, [ "listOrdered", "listUnordered" ] - ); + ).filter((list) => !inHtmlFlow(list)); for (const list of lists) { const expectedIndent = list.startColumn - 1; let expectedEnd = 0; diff --git a/lib/md007.js b/lib/md007.js index a735bca9..689a5fd6 100644 --- a/lib/md007.js +++ b/lib/md007.js @@ -3,12 +3,18 @@ "use strict"; const { addErrorDetailIf } = require("../helpers"); -const { filterByTypes } = require("../helpers/micromark.cjs"); +const { filterByTypes, getTokenParentOfType, inHtmlFlow } = + require("../helpers/micromark.cjs"); /** * @typedef {import("../helpers/micromark.cjs").Token} Token */ +const unorderedListTypes = + [ "blockQuotePrefix", "listItemPrefix", "listUnordered" ]; +const unorderedParentTypes = + [ "blockQuote", "listOrdered", "listUnordered" ]; + module.exports = { "names": [ "MD007", "ul-indent" ], "description": "Unordered list indentation", @@ -21,7 +27,7 @@ module.exports = { let lastBlockQuotePrefix = null; const tokens = filterByTypes( params.parsers.micromark.tokens, - [ "blockQuotePrefix", "listItemPrefix", "listUnordered" ] + unorderedListTypes ); for (const token of tokens) { const { parent, startColumn, startLine, type } = token; @@ -31,20 +37,21 @@ module.exports = { let nesting = 0; /** @type {Token | null} */ let current = token; - while ((current = current.parent)) { + while ( + (current = getTokenParentOfType(current, unorderedParentTypes)) + ) { if (current.type === "listUnordered") { nesting++; + continue; } else if (current.type === "listOrdered") { nesting = -1; - break; - } else if (current.type === "blockQuote") { - break; } + break; } if (nesting >= 0) { unorderedListNesting.set(token, nesting); } - } else { + } else if (!inHtmlFlow(token)) { // listItemPrefix const nesting = unorderedListNesting.get(parent); if (nesting !== undefined) { diff --git a/lib/md022.js b/lib/md022.js index 28f83a4d..62d5b0fc 100644 --- a/lib/md022.js +++ b/lib/md022.js @@ -4,7 +4,7 @@ const { addErrorDetailIf, blockquotePrefixRe, isBlankLine } = require("../helpers"); -const { filterByTypes, getHeadingLevel } = +const { filterByTypes, getHeadingLevel, inHtmlFlow } = require("../helpers/micromark.cjs"); const defaultLines = 1; @@ -42,7 +42,7 @@ module.exports = { const headings = filterByTypes( parsers.micromark.tokens, [ "atxHeading", "setextHeading" ] - ); + ).filter((heading) => !inHtmlFlow(heading)); for (const heading of headings) { const { startLine, endLine } = heading; const line = lines[startLine - 1].trim(); diff --git a/lib/md037.js b/lib/md037.js index 69842bb8..4f10a640 100644 --- a/lib/md037.js +++ b/lib/md037.js @@ -3,7 +3,7 @@ "use strict"; const { addError } = require("../helpers"); -const { filterByPredicate } = require("../helpers/micromark.cjs"); +const { filterByPredicate, inHtmlFlow } = require("../helpers/micromark.cjs"); module.exports = { "names": [ "MD037", "no-space-in-emphasis" ], @@ -31,7 +31,7 @@ module.exports = { const { text, type } = child; if ((type === "data") && (text.length <= 3)) { const emphasisTokens = emphasisTokensByMarker.get(text); - if (emphasisTokens) { + if (emphasisTokens && !inHtmlFlow(child)) { emphasisTokens.push(child); } } diff --git a/lib/md038.js b/lib/md038.js index 984fd09b..83d861e9 100644 --- a/lib/md038.js +++ b/lib/md038.js @@ -3,7 +3,8 @@ "use strict"; const { addErrorContext } = require("../helpers"); -const { filterByTypes, tokenIfType } = require("../helpers/micromark.cjs"); +const { filterByTypes, inHtmlFlow, tokenIfType } = + require("../helpers/micromark.cjs"); const leftSpaceRe = /^\s(?:[^`]|$)/; const rightSpaceRe = /[^`]\s$/; @@ -23,10 +24,11 @@ module.exports = { "description": "Spaces inside code span elements", "tags": [ "whitespace", "code" ], "function": function MD038(params, onError) { - const codeTextTokens = - filterByTypes(params.parsers.micromark.tokens, [ "codeText" ]); - for (const token of codeTextTokens) { - const { children } = token; + const codeTexts = + filterByTypes(params.parsers.micromark.tokens, [ "codeText" ]) + .filter((codeText) => !inHtmlFlow(codeText)); + for (const codeText of codeTexts) { + const { children } = codeText; const first = 0; const last = children.length - 1; const startSequence = tokenIfType(children[first], "codeTextSequence"); diff --git a/test/html-comments.md b/test/html-comments.md index 51e6cbca..b486967d 100644 --- a/test/html-comments.md +++ b/test/html-comments.md @@ -19,9 +19,9 @@ *comment * *comment * --> - *{MD037} * --> + *text * --> - *{MD037} * --> + *text * --> diff --git a/test/inline-disable-enable.md b/test/inline-disable-enable.md index 80be1642..739d5baa 100644 --- a/test/inline-disable-enable.md +++ b/test/inline-disable-enable.md @@ -95,7 +95,7 @@ hard tab / space *in * emphasis / space `in ` code hard tab / space *in * emphasis / space `in ` code hard tab {MD010} / space *in * emphasis {MD037} / space `in ` code {MD038} - hard tab / space *in * emphasis {MD037} / space `in ` code + hard tab / space *in * emphasis / space `in ` code hard tab {MD010} / space *in * emphasis {MD037} / space `in ` code {MD038} hard tab / space *in * emphasis {MD037} / space `in ` code hard tab {MD010} / space *in * emphasis {MD037} / space `in ` code {MD038} diff --git a/test/markdown-in-html.md b/test/markdown-in-html.md new file mode 100644 index 00000000..ed614f98 --- /dev/null +++ b/test/markdown-in-html.md @@ -0,0 +1,37 @@ +# Markdown in HTML + +Text + ++ Item + +Text + +
+## Heading 2a + - Text *text* text * text * text ** text ** text `text` text ` text ` text +- Text https://example.com/ [ link ](https://example.com/) +
+ ++### Heading 3a ### +Text +
+ +Text + ++ +## Heading 2b {MD019} {MD022} + - Text *text* text * text * text ** text ** text `text` text ` text ` text {MD004} {MD007} {MD032} {MD037} {MD038} +- Text https://example.com/ [ link ](https://example.com/) {MD004} {MD005} {MD039} + +
+ ++ +### Heading 3b {MD003} {MD021} {MD022} ### +Text + +
+ + diff --git a/test/snapshots/markdownlint-test-repos.js.md b/test/snapshots/markdownlint-test-repos.js.md index 70ad1fd0..f7f15674 100644 --- a/test/snapshots/markdownlint-test-repos.js.md +++ b/test/snapshots/markdownlint-test-repos.js.md @@ -42,11 +42,7 @@ Generated by [AVA](https://avajs.dev). test-repos/mdn-content/files/en-us/web/css/angle/index.md: 60: MD045/no-alt-text Images should have alternate text (alt text)␊ test-repos/mdn-content/files/en-us/web/css/angle/index.md: 71: MD045/no-alt-text Images should have alternate text (alt text)␊ test-repos/mdn-content/files/en-us/web/css/transform-function/rotate3d/index.md: 67: MD045/no-alt-text Images should have alternate text (alt text)␊ - test-repos/mdn-content/files/en-us/web/css/transform-function/rotate3d/index.md: 251: MD045/no-alt-text Images should have alternate text (alt text)␊ - test-repos/mdn-content/files/en-us/web/svg/attribute/d/index.md: 234: MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 10]␊ - test-repos/mdn-content/files/en-us/web/svg/attribute/d/index.md: 556: MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 12]␊ - test-repos/mdn-content/files/en-us/web/svg/attribute/d/index.md: 769: MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 12]␊ - test-repos/mdn-content/files/en-us/web/svg/attribute/d/index.md: 838: MD007/ul-indent Unordered list indentation [Expected: 0; Actual: 12]` + test-repos/mdn-content/files/en-us/web/css/transform-function/rotate3d/index.md: 251: MD045/no-alt-text Images should have alternate text (alt text)` ## https://github.com/mkdocs/mkdocs diff --git a/test/snapshots/markdownlint-test-repos.js.snap b/test/snapshots/markdownlint-test-repos.js.snap index fa7766ac..e5993302 100644 Binary files a/test/snapshots/markdownlint-test-repos.js.snap and b/test/snapshots/markdownlint-test-repos.js.snap differ diff --git a/test/snapshots/markdownlint-test-scenarios.js.md b/test/snapshots/markdownlint-test-scenarios.js.md index d83d4eeb..1d960cbd 100644 --- a/test/snapshots/markdownlint-test-scenarios.js.md +++ b/test/snapshots/markdownlint-test-scenarios.js.md @@ -18250,44 +18250,6 @@ Generated by [AVA](https://avajs.dev). { errors: [ - { - errorContext: '} *', - errorDetail: null, - errorRange: [ - 14, - 3, - ], - fixInfo: { - deleteCount: 1, - editColumn: 15, - }, - lineNumber: 22, - ruleDescription: 'Spaces inside emphasis markers', - ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md037.md', - ruleNames: [ - 'MD037', - 'no-space-in-emphasis', - ], - }, - { - errorContext: '} *', - errorDetail: null, - errorRange: [ - 15, - 3, - ], - fixInfo: { - deleteCount: 1, - editColumn: 16, - }, - lineNumber: 24, - ruleDescription: 'Spaces inside emphasis markers', - ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md037.md', - ruleNames: [ - 'MD037', - 'no-space-in-emphasis', - ], - }, { errorContext: '} *', errorDetail: null, @@ -18348,9 +18310,9 @@ Generated by [AVA](https://avajs.dev). *comment *␊ *comment * -->␊ ␊ - *{MD037}* -->␊ + *text * -->␊ ␊ - *{MD037}* -->␊ + *text * -->␊ ␊ ␊ ␊ @@ -22064,25 +22026,6 @@ Generated by [AVA](https://avajs.dev). 'no-space-in-emphasis', ], }, - { - errorContext: 'n *', - errorDetail: null, - errorRange: [ - 67, - 3, - ], - fixInfo: { - deleteCount: 1, - editColumn: 68, - }, - lineNumber: 98, - ruleDescription: 'Spaces inside emphasis markers', - ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md037.md', - ruleNames: [ - 'MD037', - 'no-space-in-emphasis', - ], - }, { errorContext: 'n *', errorDetail: null, @@ -22835,7 +22778,7 @@ Generated by [AVA](https://avajs.dev). hard tab {MD010} / space *in* emphasis {MD037} / space \`in\` code {MD038}␊ hard tab / space *in * emphasis / space \`in \` code␊ hard tab {MD010} / space *in* emphasis {MD037} / space \`in\` code {MD038}␊ - hard tab / space *in* emphasis {MD037} / space \`in \` code␊ + hard tab / space *in * emphasis / space \`in \` code␊ hard tab {MD010} / space *in* emphasis {MD037} / space \`in\` code {MD038}␊ hard tab / space *in* emphasis {MD037} / space \`in \` code ␊ hard tab {MD010} / space *in* emphasis {MD037} / space \`in\` code {MD038}␊ @@ -33077,6 +33020,352 @@ Generated by [AVA](https://avajs.dev). `, } +## markdown-in-html.md + +> Snapshot 1 + + { + errors: [ + { + errorContext: null, + errorDetail: 'Expected: atx; Actual: atx_closed', + errorRange: null, + fixInfo: null, + lineNumber: 32, + ruleDescription: 'Heading style', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md003.md', + ruleNames: [ + 'MD003', + 'heading-style', + 'header-style', + ], + }, + { + errorContext: null, + errorDetail: 'Expected: plus; Actual: dash', + errorRange: [ + 1, + 3, + ], + fixInfo: { + deleteCount: 1, + editColumn: 2, + insertText: '+', + }, + lineNumber: 25, + ruleDescription: 'Unordered list style', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md004.md', + ruleNames: [ + 'MD004', + 'ul-style', + ], + }, + { + errorContext: null, + errorDetail: 'Expected: plus; Actual: dash', + errorRange: [ + 1, + 2, + ], + fixInfo: { + deleteCount: 1, + editColumn: 1, + insertText: '+', + }, + lineNumber: 26, + ruleDescription: 'Unordered list style', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md004.md', + ruleNames: [ + 'MD004', + 'ul-style', + ], + }, + { + errorContext: null, + errorDetail: 'Expected: 1; Actual: 0', + errorRange: [ + 1, + 2, + ], + fixInfo: null, + lineNumber: 26, + ruleDescription: 'Inconsistent indentation for list items at the same level', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md005.md', + ruleNames: [ + 'MD005', + 'list-indent', + ], + }, + { + errorContext: null, + errorDetail: 'Expected: 0; Actual: 1', + errorRange: [ + 1, + 3, + ], + fixInfo: { + deleteCount: 1, + editColumn: 1, + insertText: '', + }, + lineNumber: 25, + ruleDescription: 'Unordered list indentation', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md007.md', + ruleNames: [ + 'MD007', + 'ul-indent', + ], + }, + { + errorContext: '## Heading 2b {MD019} {MD022}', + errorDetail: null, + errorRange: [ + 1, + 5, + ], + fixInfo: { + deleteCount: 1, + editColumn: 3, + }, + lineNumber: 24, + ruleDescription: 'Multiple spaces after hash on atx style heading', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md019.md', + ruleNames: [ + 'MD019', + 'no-multiple-space-atx', + ], + }, + { + errorContext: '### Heading 3b...1} {MD022} ###', + errorDetail: null, + errorRange: [ + 1, + 6, + ], + fixInfo: { + deleteCount: 44, + editColumn: 1, + insertText: '### Heading 3b {MD003} {MD021} {MD022} ###', + }, + lineNumber: 32, + ruleDescription: 'Multiple spaces inside hashes on closed atx style heading', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md021.md', + ruleNames: [ + 'MD021', + 'no-multiple-space-closed-atx', + ], + }, + { + errorContext: '## Heading 2b {MD019} {MD022}', + errorDetail: 'Expected: 1; Actual: 0; Below', + errorRange: null, + fixInfo: { + insertText: `␊ + `, + lineNumber: 25, + }, + lineNumber: 24, + ruleDescription: 'Headings should be surrounded by blank lines', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md022.md', + ruleNames: [ + 'MD022', + 'blanks-around-headings', + 'blanks-around-headers', + ], + }, + { + errorContext: '### Heading 3b {MD003} {MD021} {MD022} ###', + errorDetail: 'Expected: 1; Actual: 0; Below', + errorRange: null, + fixInfo: { + insertText: `␊ + `, + lineNumber: 33, + }, + lineNumber: 32, + ruleDescription: 'Headings should be surrounded by blank lines', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md022.md', + ruleNames: [ + 'MD022', + 'blanks-around-headings', + 'blanks-around-headers', + ], + }, + { + errorContext: '- Text *text* text * text * te...', + errorDetail: null, + errorRange: null, + fixInfo: { + insertText: `␊ + `, + }, + lineNumber: 25, + ruleDescription: 'Lists should be surrounded by blank lines', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md032.md', + ruleNames: [ + 'MD032', + 'blanks-around-lists', + ], + }, + { + errorContext: '* t', + errorDetail: null, + errorRange: [ + 21, + 3, + ], + fixInfo: { + deleteCount: 1, + editColumn: 22, + }, + lineNumber: 25, + ruleDescription: 'Spaces inside emphasis markers', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md037.md', + ruleNames: [ + 'MD037', + 'no-space-in-emphasis', + ], + }, + { + errorContext: 't *', + errorDetail: null, + errorRange: [ + 26, + 3, + ], + fixInfo: { + deleteCount: 1, + editColumn: 27, + }, + lineNumber: 25, + ruleDescription: 'Spaces inside emphasis markers', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md037.md', + ruleNames: [ + 'MD037', + 'no-space-in-emphasis', + ], + }, + { + errorContext: '** t', + errorDetail: null, + errorRange: [ + 35, + 4, + ], + fixInfo: { + deleteCount: 1, + editColumn: 37, + }, + lineNumber: 25, + ruleDescription: 'Spaces inside emphasis markers', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md037.md', + ruleNames: [ + 'MD037', + 'no-space-in-emphasis', + ], + }, + { + errorContext: 't **', + errorDetail: null, + errorRange: [ + 41, + 4, + ], + fixInfo: { + deleteCount: 1, + editColumn: 42, + }, + lineNumber: 25, + ruleDescription: 'Spaces inside emphasis markers', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md037.md', + ruleNames: [ + 'MD037', + 'no-space-in-emphasis', + ], + }, + { + errorContext: '` text `', + errorDetail: null, + errorRange: [ + 63, + 10, + ], + fixInfo: { + deleteCount: 8, + editColumn: 64, + insertText: 'text', + }, + lineNumber: 25, + ruleDescription: 'Spaces inside code span elements', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md038.md', + ruleNames: [ + 'MD038', + 'no-space-in-code', + ], + }, + { + errorContext: '[ link ]', + errorDetail: null, + errorRange: [ + 29, + 8, + ], + fixInfo: { + deleteCount: 6, + editColumn: 30, + insertText: 'link', + }, + lineNumber: 26, + ruleDescription: 'Spaces inside link text', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md039.md', + ruleNames: [ + 'MD039', + 'no-space-in-links', + ], + }, + ], + fixed: `# Markdown in HTML␊ + ␊ + Text␊ + ␊ + + Item␊ + ␊ + Text␊ + ␊ +␊ + ## Heading 2a␊ + - Text *text* text * text * text ** text ** text \`text\` text \` text \` text␊ + - Text https://example.com/ [ link ](https://example.com/)␊ +
␊ + ␊ +␊ + ### Heading 3a ###␊ + Text␊ +
␊ + ␊ + Text␊ + ␊ +␊ + ␊ + ## Heading 2b {MD019} {MD022}␊ + ␊ + + Text *text* text *text* text **text** text \`text\` text \`text\` text {MD004} {MD007} {MD032} {MD037} {MD038}␊ + + Text https://example.com/ [link](https://example.com/) {MD004} {MD005} {MD039}␊ + ␊ +
␊ + ␊ +␊ + ␊ + ### Heading 3b {MD003} {MD021} {MD022} ###␊ + ␊ + Text␊ + ␊ +
␊ + ␊ + ␊ + `, + } + ## mathjax-scenarios.md > Snapshot 1 @@ -45551,44 +45840,6 @@ Generated by [AVA](https://avajs.dev). 'no-space-in-emphasis', ], }, - { - errorContext: '* H', - errorDetail: null, - errorRange: [ - 17, - 3, - ], - fixInfo: { - deleteCount: 1, - editColumn: 18, - }, - lineNumber: 383, - ruleDescription: 'Spaces inside emphasis markers', - ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md037.md', - ruleNames: [ - 'MD037', - 'no-space-in-emphasis', - ], - }, - { - errorContext: 'L *', - errorDetail: null, - errorRange: [ - 22, - 3, - ], - fixInfo: { - deleteCount: 1, - editColumn: 23, - }, - lineNumber: 383, - ruleDescription: 'Spaces inside emphasis markers', - ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md037.md', - ruleNames: [ - 'MD037', - 'no-space-in-emphasis', - ], - }, { errorContext: '* H', errorDetail: null, @@ -46010,7 +46261,7 @@ Generated by [AVA](https://avajs.dev). Emphasis inside *HTML* content {MD033} {MD037}␊ ␊{MD033}␊ - Emphasis inside *HTML* content {MD037}␊ + Emphasis inside * HTML * content␊
␊ ␊ Emphasis {MD033}␊ diff --git a/test/snapshots/markdownlint-test-scenarios.js.snap b/test/snapshots/markdownlint-test-scenarios.js.snap index 149b8ce7..eb022881 100644 Binary files a/test/snapshots/markdownlint-test-scenarios.js.snap and b/test/snapshots/markdownlint-test-scenarios.js.snap differ diff --git a/test/spaces_inside_emphasis_markers.md b/test/spaces_inside_emphasis_markers.md index 0253320d..30539707 100644 --- a/test/spaces_inside_emphasis_markers.md +++ b/test/spaces_inside_emphasis_markers.md @@ -380,7 +380,7 @@ Partial *em*phasis of a *wo*rd. Emphasis inside * HTML * content {MD033} {MD037}{MD033} -Emphasis inside * HTML * content {MD037} +Emphasis inside * HTML * content
Emphasis {MD033}