mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Fix MD032 to recognize blank lines around lists in block quotes.
This commit is contained in:
parent
f24dc4bee0
commit
0f64bd5b4e
2 changed files with 30 additions and 2 deletions
|
|
@ -766,15 +766,16 @@ module.exports = [
|
||||||
"aliases": [ "blanks-around-lists" ],
|
"aliases": [ "blanks-around-lists" ],
|
||||||
"regexp": null,
|
"regexp": null,
|
||||||
"func": function MD032(params, errors) {
|
"func": function MD032(params, errors) {
|
||||||
|
var blankOrListRe = /^[\s>]*($|\s)/;
|
||||||
var inList = false;
|
var inList = false;
|
||||||
var prevLine = "";
|
var prevLine = "";
|
||||||
forEachLine(params, function forLine(line, lineIndex, inCode, onFence) {
|
forEachLine(params, function forLine(line, lineIndex, inCode, onFence) {
|
||||||
if (!inCode || onFence) {
|
if (!inCode || onFence) {
|
||||||
var lineTrim = line.trim();
|
var lineTrim = line.trim();
|
||||||
var listMarker = listItemMarkerRe.test(lineTrim);
|
var listMarker = listItemMarkerRe.test(lineTrim);
|
||||||
if (listMarker && !inList && !/^($|\s)/.test(prevLine)) {
|
if (listMarker && !inList && !blankOrListRe.test(prevLine)) {
|
||||||
errors.addContext(lineIndex + 1, lineTrim);
|
errors.addContext(lineIndex + 1, lineTrim);
|
||||||
} else if (!listMarker && inList && !/^($|\s)/.test(line)) {
|
} else if (!listMarker && inList && !blankOrListRe.test(line)) {
|
||||||
errors.addContext(lineIndex, lineTrim);
|
errors.addContext(lineIndex, lineTrim);
|
||||||
}
|
}
|
||||||
inList = listMarker;
|
inList = listMarker;
|
||||||
|
|
|
||||||
|
|
@ -62,3 +62,30 @@ Text
|
||||||
> * Item
|
> * Item
|
||||||
>>* Item
|
>>* Item
|
||||||
>> * Item
|
>> * Item
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> Quoted text
|
||||||
|
>
|
||||||
|
> * A list
|
||||||
|
> * of items
|
||||||
|
>
|
||||||
|
> More quoted text
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> Quoted text
|
||||||
|
>
|
||||||
|
> > * A list
|
||||||
|
> > * of items
|
||||||
|
>
|
||||||
|
> More quoted text
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> Quoted text
|
||||||
|
>
|
||||||
|
> > * A list
|
||||||
|
> > * of items
|
||||||
|
> >
|
||||||
|
> > More quoted text
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue