Add MD012, MD028 with tests, support multiple markers by line.

This commit is contained in:
David Anson 2015-03-04 18:09:46 -08:00
parent f35d690fb1
commit c864ac1b96
4 changed files with 85 additions and 3 deletions

View 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)

View 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

View file

@ -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;
}
});