diff --git a/demo/markdownlint-browser.js b/demo/markdownlint-browser.js index 2bedef71..1673603c 100644 --- a/demo/markdownlint-browser.js +++ b/demo/markdownlint-browser.js @@ -2678,7 +2678,7 @@ module.exports = { const tokenLines = params.lines.slice(token.map[0], token.map[1]); forEachInlineCodeSpan(tokenLines.join("\n"), (code, lineIndex) => { const codeLineCount = code.split(newLineRe).length; - for (let i = 0; i < codeLineCount; i++) { + for (let i = 0; i < codeLineCount - 1; i++) { codeInlineLineNumbers.push(token.lineNumber + lineIndex + i); } }); @@ -2699,7 +2699,7 @@ module.exports = { includesSorted(codeInlineLineNumbers, lineNumber))))) { const column = line.length - trailingSpaces + 1; addError(onError, lineNumber, "Expected: " + (expected === 0 ? "" : "0 or ") + - expected + "; Actual: " + trailingSpaces, null, [column, trailingSpaces], { + expected + "; Actual: " + trailingSpaces, undefined, [column, trailingSpaces], { "editColumn": column, "deleteCount": trailingSpaces }); diff --git a/lib/md009.js b/lib/md009.js index 15a7b26d..8efff15b 100644 --- a/lib/md009.js +++ b/lib/md009.js @@ -38,7 +38,7 @@ module.exports = { const tokenLines = params.lines.slice(token.map[0], token.map[1]); forEachInlineCodeSpan(tokenLines.join("\n"), (code, lineIndex) => { const codeLineCount = code.split(newLineRe).length; - for (let i = 0; i < codeLineCount; i++) { + for (let i = 0; i < codeLineCount - 1; i++) { codeInlineLineNumbers.push(token.lineNumber + lineIndex + i); } }); @@ -67,7 +67,7 @@ module.exports = { lineNumber, "Expected: " + (expected === 0 ? "" : "0 or ") + expected + "; Actual: " + trailingSpaces, - null, + undefined, [ column, trailingSpaces ], { "editColumn": column, diff --git a/test/hard-line-breaks.md b/test/hard-line-breaks.md index f2381559..ee0b9692 100644 --- a/test/hard-line-breaks.md +++ b/test/hard-line-breaks.md @@ -53,6 +53,15 @@ Text text text text text +Text text +text `code +span` text + +Text text +text `code +span code +span` text + {MD009:9} {MD009:24} {MD009:32} @@ -62,3 +71,7 @@ text {MD009:43} {MD009:48} {MD009:54} +{MD009:58} +{MD009:61} +{MD009:62} +{MD009:63} diff --git a/test/snapshots/markdownlint-test-scenarios.js.md b/test/snapshots/markdownlint-test-scenarios.js.md index e8699ba3..98ee1b3c 100644 --- a/test/snapshots/markdownlint-test-scenarios.js.md +++ b/test/snapshots/markdownlint-test-scenarios.js.md @@ -11940,6 +11940,82 @@ Generated by [AVA](https://avajs.dev). 'no-trailing-spaces', ], }, + { + errorContext: null, + errorDetail: 'Expected: 0 or 2; Actual: 2', + errorRange: [ + 11, + 2, + ], + fixInfo: { + deleteCount: 2, + editColumn: 11, + }, + lineNumber: 58, + ruleDescription: 'Trailing spaces', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009', + ruleNames: [ + 'MD009', + 'no-trailing-spaces', + ], + }, + { + errorContext: null, + errorDetail: 'Expected: 0 or 2; Actual: 2', + errorRange: [ + 11, + 2, + ], + fixInfo: { + deleteCount: 2, + editColumn: 11, + }, + lineNumber: 61, + ruleDescription: 'Trailing spaces', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009', + ruleNames: [ + 'MD009', + 'no-trailing-spaces', + ], + }, + { + errorContext: null, + errorDetail: 'Expected: 0 or 2; Actual: 2', + errorRange: [ + 10, + 2, + ], + fixInfo: { + deleteCount: 2, + editColumn: 10, + }, + lineNumber: 62, + ruleDescription: 'Trailing spaces', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009', + ruleNames: [ + 'MD009', + 'no-trailing-spaces', + ], + }, + { + errorContext: null, + errorDetail: 'Expected: 0 or 2; Actual: 2', + errorRange: [ + 11, + 2, + ], + fixInfo: { + deleteCount: 2, + editColumn: 11, + }, + lineNumber: 63, + ruleDescription: 'Trailing spaces', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009', + ruleNames: [ + 'MD009', + 'no-trailing-spaces', + ], + }, ], fixed: `# Hard Line Breaks␊ ␊ @@ -11996,6 +12072,15 @@ Generated by [AVA](https://avajs.dev). text text␊ text␊ ␊ + Text text␊ + text \`code␊ + span\` text␊ + ␊ + Text text␊ + text \`code␊ + span code␊ + span\` text␊ + ␊ {MD009:9}␊ {MD009:24}␊ {MD009:32}␊ @@ -12005,6 +12090,10 @@ Generated by [AVA](https://avajs.dev). {MD009:43}␊ {MD009:48}␊ {MD009:54}␊ + {MD009:58}␊ + {MD009:61}␊ + {MD009:62}␊ + {MD009:63}␊ `, } diff --git a/test/snapshots/markdownlint-test-scenarios.js.snap b/test/snapshots/markdownlint-test-scenarios.js.snap index df124447..68c4cff3 100644 Binary files a/test/snapshots/markdownlint-test-scenarios.js.snap and b/test/snapshots/markdownlint-test-scenarios.js.snap differ