mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Work around problems related to markdown-it-texmath plugin's token.map not accounting for math_block_end.
This commit is contained in:
parent
a3f8fb7c62
commit
32db81b740
3 changed files with 90 additions and 0 deletions
|
@ -271,6 +271,14 @@ module.exports.flattenLists = function flattenLists(params) {
|
|||
const nestingStack = [];
|
||||
let lastWithMap = { "map": [ 0, 1 ] };
|
||||
params.tokens.forEach(function forToken(token) {
|
||||
if (
|
||||
(token.type === "math_block") &&
|
||||
(token.tag === "math") &&
|
||||
token.map[1]
|
||||
) {
|
||||
// markdown-it-texmath package does not account for math_block_end
|
||||
token.map[1]++;
|
||||
}
|
||||
if ((token.type === "bullet_list_open") ||
|
||||
(token.type === "ordered_list_open")) {
|
||||
// Save current context and start a new one
|
||||
|
|
|
@ -1473,6 +1473,21 @@ $$\n`
|
|||
});
|
||||
});
|
||||
|
||||
tape("texmath-content-in-lists with texmath plugin", (test) => {
|
||||
test.plan(2);
|
||||
markdownlint({
|
||||
"files": [ "./test/texmath-content-in-lists.md" ],
|
||||
"markdownItPlugins": [ [ pluginTexMath, pluginTexMathOptions ] ]
|
||||
}, function callback(err, actual) {
|
||||
test.ifError(err);
|
||||
const expected = {
|
||||
"./test/texmath-content-in-lists.md": []
|
||||
};
|
||||
test.deepEqual(actual, expected, "Unexpected issues.");
|
||||
test.end();
|
||||
});
|
||||
});
|
||||
|
||||
tape("getVersion", (test) => {
|
||||
test.plan(1);
|
||||
const actual = markdownlint.getVersion();
|
||||
|
|
67
test/texmath-content-in-lists.md
Normal file
67
test/texmath-content-in-lists.md
Normal file
|
@ -0,0 +1,67 @@
|
|||
# texmath-content-in-lists
|
||||
|
||||
Text
|
||||
|
||||
- Item
|
||||
$$
|
||||
e = mc^2
|
||||
$$
|
||||
|
||||
Text
|
||||
|
||||
- Item
|
||||
|
||||
$$
|
||||
e = mc^2
|
||||
$$
|
||||
|
||||
Text
|
||||
|
||||
- Item
|
||||
|
||||
$$
|
||||
e = mc^2
|
||||
e = mc^2
|
||||
$$
|
||||
|
||||
Text
|
||||
|
||||
- Item
|
||||
|
||||
$$
|
||||
$$
|
||||
|
||||
Text
|
||||
|
||||
- Item
|
||||
|
||||
- Item
|
||||
|
||||
$$
|
||||
e = mc^2
|
||||
$$
|
||||
|
||||
- Item
|
||||
|
||||
Text
|
||||
|
||||
- $$
|
||||
e = mc^2
|
||||
$$
|
||||
|
||||
Text
|
||||
|
||||
- $e = mc^2$
|
||||
|
||||
Text
|
||||
|
||||
- Item
|
||||
- $e = mc^2$
|
||||
|
||||
Text
|
||||
|
||||
- Item
|
||||
- $e = mc^2$
|
||||
- Item
|
||||
|
||||
Text
|
Loading…
Add table
Add a link
Reference in a new issue