mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update MD032/blanks-around-lists to ignore non-interrupting prefixes (fixes #34).
This commit is contained in:
parent
d8975282dc
commit
5fa065a7b0
3 changed files with 46 additions and 3 deletions
|
|
@ -11,6 +11,7 @@ var dollarCommandRe = /^(\s*)(\$\s)/;
|
|||
var emptyLinkRe = /\[[^\]]*](?=(?:\((?:#?|(?:<>))\))|(?:\[[^\]]*]))/;
|
||||
var htmlRe = /<[^>]*>/;
|
||||
var listItemMarkerRe = /^[\s>]*(?:[*+-]|\d+\.)\s+/;
|
||||
var listItemMarkerInterruptsRe = /^[\s>]*(?:[*+-]|1\.)\s+/;
|
||||
var reversedLinkRe = /\([^)]+\)\[[^\]^][^\]]*]/;
|
||||
var spaceAfterBlockQuote = />\s+\S/;
|
||||
var spaceBeforeHeaderRe = /^\s+\S/;
|
||||
|
|
@ -774,7 +775,12 @@ module.exports = [
|
|||
var lineTrim = line.trim();
|
||||
var listMarker = listItemMarkerRe.test(lineTrim);
|
||||
if (listMarker && !inList && !blankOrListRe.test(prevLine)) {
|
||||
errors.addContext(lineIndex + 1, lineTrim);
|
||||
// Check whether this list prefix can interrupt a paragraph
|
||||
if (listItemMarkerInterruptsRe.test(lineTrim)) {
|
||||
errors.addContext(lineIndex + 1, lineTrim);
|
||||
} else {
|
||||
listMarker = false;
|
||||
}
|
||||
} else if (!listMarker && inList && !blankOrListRe.test(line)) {
|
||||
errors.addContext(lineIndex, lineTrim);
|
||||
}
|
||||
|
|
|
|||
37
test/list-syntax-in-paragraph-text.md
Normal file
37
test/list-syntax-in-paragraph-text.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# Heading
|
||||
|
||||
This paragraph has the number
|
||||
5. More text.
|
||||
|
||||
This paragraph has the number
|
||||
11. More text.
|
||||
|
||||
This non-paragraph has the number
|
||||
1. This is a list. {MD032}
|
||||
|
||||
This non-paragraph has the number
|
||||
1. This is a list. It also has the number {MD032}
|
||||
5. This is a list. {MD029}
|
||||
|
||||
This non-paragraph has spaces and the number
|
||||
1. This is a list. {MD030} {MD032}
|
||||
|
||||
This non-paragraph has a dash
|
||||
- in its list. {MD032}
|
||||
|
||||
This non-paragraph has a dash
|
||||
- in its list. It also has a plus {MD032}
|
||||
+ in its list. {MD004}
|
||||
|
||||
This non-paragraph has spaces and a dash
|
||||
- This is a list. {MD030} {MD032}
|
||||
|
||||
This is a mixed paragraph that has
|
||||
2. followed by text followed by
|
||||
1. which creates a list {MD032}
|
||||
1. with a couple of items
|
||||
|
||||
Another mixed paragraph
|
||||
2. with more text
|
||||
in the middle of things
|
||||
1. before the list {MD032}
|
||||
|
|
@ -19,8 +19,8 @@ text
|
|||
text
|
||||
|
||||
text
|
||||
10. list {MD032}
|
||||
20. list
|
||||
1. list {MD032}
|
||||
2. list
|
||||
|
||||
text
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue