mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +01:00
Handle case where token map extends beyond last line of input (fixes #166).
This commit is contained in:
parent
90bd0810e7
commit
3e753636cf
2 changed files with 30 additions and 1 deletions
|
|
@ -164,7 +164,7 @@ function annotateTokens(tokens, lines) {
|
||||||
token.line = lines[token.map[0]];
|
token.line = lines[token.map[0]];
|
||||||
token.lineNumber = token.map[0] + 1;
|
token.lineNumber = token.map[0] + 1;
|
||||||
// Trim bottom of token to exclude whitespace lines
|
// Trim bottom of token to exclude whitespace lines
|
||||||
while (token.map[1] && !(lines[token.map[1] - 1].trim())) {
|
while (token.map[1] && !((lines[token.map[1] - 1] || "").trim())) {
|
||||||
token.map[1]--;
|
token.map[1]--;
|
||||||
}
|
}
|
||||||
// Annotate children with lineNumber
|
// Annotate children with lineNumber
|
||||||
|
|
|
||||||
|
|
@ -2628,3 +2628,32 @@ module.exports.markdownItPluginsMathjax =
|
||||||
test.done();
|
test.done();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.markdownItPluginsMathjaxIssue166 =
|
||||||
|
function markdownItPluginsMathjaxIssue166(test) {
|
||||||
|
test.expect(2);
|
||||||
|
markdownlint({
|
||||||
|
"strings": {
|
||||||
|
"string":
|
||||||
|
`## Heading
|
||||||
|
|
||||||
|
$$
|
||||||
|
1
|
||||||
|
$$$$
|
||||||
|
2
|
||||||
|
$$`
|
||||||
|
},
|
||||||
|
"markdownItPlugins": [ [ pluginKatex ] ],
|
||||||
|
"resultVersion": 0
|
||||||
|
}, function callback(err, actual) {
|
||||||
|
test.ifError(err);
|
||||||
|
const expected = {
|
||||||
|
"string": {
|
||||||
|
"MD002": [ 1 ],
|
||||||
|
"MD041": [ 1 ]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
test.deepEqual(actual, expected, "Unexpected issues.");
|
||||||
|
test.done();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue