mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Add MD012, MD028 with tests, support multiple markers by line.
This commit is contained in:
parent
f35d690fb1
commit
c864ac1b96
4 changed files with 85 additions and 3 deletions
31
test/blockquote_blank_lines.md
Normal file
31
test/blockquote_blank_lines.md
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
Some text
|
||||
|
||||
> a quote
|
||||
> same quote
|
||||
|
||||
> blank line above me
|
||||
|
||||
|
||||
> two blank lines above me
|
||||
|
||||
> space above me
|
||||
|
||||
* List with embedded blockquote
|
||||
|
||||
> Test
|
||||
> Test
|
||||
|
||||
> Test
|
||||
|
||||
* Item 2
|
||||
|
||||
> Test. The blank line below should _not_ trigger MD028 as one blockquote is
|
||||
> inside the list, and the other is outside it.
|
||||
|
||||
> Test
|
||||
|
||||
Expected errors:
|
||||
|
||||
{MD028:5} {MD028:8} {MD028:10} {MD028:17}
|
||||
{MD009:10} (trailing space is intentional)
|
||||
{MD012:8} (multiple blank lines are intentional)
|
||||
11
test/consecutive_blank_lines.md
Normal file
11
test/consecutive_blank_lines.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Some text
|
||||
|
||||
|
||||
Some text {MD012:3}
|
||||
|
||||
This is a code block
|
||||
|
||||
|
||||
with two blank lines in it
|
||||
|
||||
Some more text
|
||||
|
|
@ -34,11 +34,12 @@ function createTestForFile(file) {
|
|||
var lines = contents.split(/\r\n|\r|\n/g);
|
||||
var results = {};
|
||||
lines.forEach(function forLine(line, lineNum) {
|
||||
var match = line.match(/\{(MD\d+)(?::(\d+))?\}/);
|
||||
if (match) {
|
||||
var regex = /\{(MD\d+)(?::(\d+))?\}/g;
|
||||
var match;
|
||||
while ((match = regex.exec(line))) {
|
||||
var rule = match[1];
|
||||
var errors = results[rule] || [];
|
||||
errors.push(lineNum + 1);
|
||||
errors.push(match[2] ? parseInt(match[2], 10) : lineNum + 1);
|
||||
results[rule] = errors;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue