mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-01-19 21:56:08 +01:00
Re-implement MD038 to handle multi-line spans better and rely less on RegExp.
This commit is contained in:
parent
3b49414183
commit
ff50da3b42
7 changed files with 235 additions and 40 deletions
|
|
@ -46,3 +46,13 @@ text.
|
|||
|
||||
* List
|
||||
---
|
||||
|
||||
Text
|
||||
text ```code
|
||||
span code
|
||||
span code ``` text
|
||||
text
|
||||
text text ```` code
|
||||
span code
|
||||
span```` text
|
||||
text.
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@
|
|||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "` code\nspan`",
|
||||
"errorContext": "` code",
|
||||
"errorRange": [ 6, 6 ]
|
||||
},
|
||||
{
|
||||
|
|
@ -194,9 +194,27 @@
|
|||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "`code\nspan `",
|
||||
"errorContext": "span `",
|
||||
"errorRange": [ 1, 7 ]
|
||||
},
|
||||
{
|
||||
"lineNumber": 53,
|
||||
"ruleNames": [ "MD038", "no-space-in-code" ],
|
||||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "span code ```",
|
||||
"errorRange": [ 1, 13 ]
|
||||
},
|
||||
{
|
||||
"lineNumber": 55,
|
||||
"ruleNames": [ "MD038", "no-space-in-code" ],
|
||||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "```` code",
|
||||
"errorRange": [ 11, 9 ]
|
||||
},
|
||||
{
|
||||
"lineNumber": 19,
|
||||
"ruleNames": [ "MD039", "no-space-in-links" ],
|
||||
|
|
|
|||
|
|
@ -56,3 +56,13 @@ text `code
|
|||
span code
|
||||
span ` text {MD038}
|
||||
text.
|
||||
|
||||
Text
|
||||
text `code
|
||||
span code
|
||||
span ` text {MD038}
|
||||
text
|
||||
text ` code {MD038}
|
||||
span code
|
||||
span` text
|
||||
text.
|
||||
|
|
|
|||
|
|
@ -1420,6 +1420,107 @@ module.exports.trimLeftRight = function trimLeftRight(test) {
|
|||
test.done();
|
||||
};
|
||||
|
||||
module.exports.forEachInlineCodeSpan = function forEachInlineCodeSpan(test) {
|
||||
test.expect(94);
|
||||
const testCases =
|
||||
[
|
||||
[
|
||||
"`code`",
|
||||
[ [ "code", 0, 1, 1 ] ]
|
||||
],
|
||||
[
|
||||
"text `code` text",
|
||||
[ [ "code", 0, 6, 1 ] ]
|
||||
],
|
||||
[
|
||||
"text `code` text `edoc`",
|
||||
[
|
||||
[ "code", 0, 6, 1 ],
|
||||
[ "edoc", 0, 18, 1 ]
|
||||
]
|
||||
],
|
||||
[
|
||||
"text `code` text `edoc` text",
|
||||
[
|
||||
[ "code", 0, 6, 1 ],
|
||||
[ "edoc", 0, 18, 1 ]
|
||||
]
|
||||
],
|
||||
[
|
||||
"text ``code`code`` text",
|
||||
[ [ "code`code", 0, 7, 2 ] ]
|
||||
],
|
||||
[
|
||||
"`code `` code`",
|
||||
[ [ "code `` code", 0, 1, 1 ] ]
|
||||
],
|
||||
[
|
||||
"`code\\`text`",
|
||||
[ [ "code\\", 0, 1, 1 ] ]
|
||||
],
|
||||
[
|
||||
"``\ncode\n``",
|
||||
[ [ "\ncode\n", 0, 2, 2 ] ]
|
||||
],
|
||||
[
|
||||
"text\n`code`\ntext",
|
||||
[ [ "code", 1, 1, 1 ] ]
|
||||
],
|
||||
[
|
||||
"text\ntext\n`code`\ntext\n`edoc`\ntext",
|
||||
[
|
||||
[ "code", 2, 1, 1 ],
|
||||
[ "edoc", 4, 1, 1 ]
|
||||
]
|
||||
],
|
||||
[
|
||||
"text `code\nedoc` text",
|
||||
[ [ "code\nedoc", 0, 6, 1 ] ]
|
||||
],
|
||||
[
|
||||
"> text `code` text",
|
||||
[ [ "code", 0, 8, 1 ] ]
|
||||
],
|
||||
[
|
||||
"> text\n> `code`\n> text",
|
||||
[ [ "code", 1, 3, 1 ] ]
|
||||
],
|
||||
[
|
||||
"> text\n> `code\n> edoc`\n> text",
|
||||
[ [ "code\n> edoc", 1, 3, 1 ] ]
|
||||
],
|
||||
[
|
||||
"```text``",
|
||||
[]
|
||||
],
|
||||
[
|
||||
"text `text text",
|
||||
[]
|
||||
],
|
||||
[
|
||||
"`text``code``",
|
||||
[ [ "code", 0, 7, 2 ] ]
|
||||
],
|
||||
[
|
||||
"text \\` text `code`",
|
||||
[ [ "code", 0, 14, 1 ] ]
|
||||
]
|
||||
];
|
||||
testCases.forEach((testCase) => {
|
||||
const [ input, expecteds ] = testCase;
|
||||
shared.forEachInlineCodeSpan(input, (code, line, column, ticks) => {
|
||||
const [ expectedCode, expectedLine, expectedColumn, expectedTicks ] =
|
||||
expecteds.shift();
|
||||
test.equal(code, expectedCode, input);
|
||||
test.equal(line, expectedLine, input);
|
||||
test.equal(column, expectedColumn, input);
|
||||
test.equal(ticks, expectedTicks, input);
|
||||
});
|
||||
test.equal(expecteds.length, 0, "length");
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
module.exports.configSingle = function configSingle(test) {
|
||||
test.expect(2);
|
||||
markdownlint.readConfig("./test/config/config-child.json",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue