mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update annotateTokens to handle multi-line code spans.
This commit is contained in:
parent
3632ce28b9
commit
40ac584482
2 changed files with 20 additions and 0 deletions
|
@ -172,11 +172,20 @@ function annotateTokens(tokens, lines) {
|
|||
}
|
||||
// Annotate children with lineNumber
|
||||
let lineNumber = token.lineNumber;
|
||||
const codeSpanExtraLines = [];
|
||||
helpers.forEachInlineCodeSpan(
|
||||
token.content,
|
||||
function handleInlineCodeSpan(code) {
|
||||
codeSpanExtraLines.push(code.split(helpers.newLineRe).length - 1);
|
||||
}
|
||||
);
|
||||
(token.children || []).forEach(function forChild(child) {
|
||||
child.lineNumber = lineNumber;
|
||||
child.line = lines[lineNumber - 1];
|
||||
if ((child.type === "softbreak") || (child.type === "hardbreak")) {
|
||||
lineNumber++;
|
||||
} else if (child.type === "code_inline") {
|
||||
lineNumber += codeSpanExtraLines.shift();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,3 +11,14 @@ the (same text)[https://www.example.com/two]. {MD011} {MD034}
|
|||
|
||||
<!-- markdownlint-disable line-length -->
|
||||
Two (issues)[https://www.example.com/three] on the (same line)[https://www.example.com/four]. {MD011} {MD034}
|
||||
|
||||
`code code
|
||||
code`
|
||||
(reversed)[link] {MD011}
|
||||
|
||||
text
|
||||
text `code
|
||||
code code
|
||||
code` text
|
||||
text
|
||||
text (reversed)[link] text {MD011}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue