mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Update MD031/blanks-around-fences and MD032/blanks-around-lists to ignore comments and blockquotes (fixes #171, fixes #172).
This commit is contained in:
parent
df2507f030
commit
1db87ef0c6
5 changed files with 120 additions and 16 deletions
20
lib/md032.js
20
lib/md032.js
|
|
@ -3,24 +3,22 @@
|
|||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
|
||||
const blankLineRe = /^[\s>]*$/;
|
||||
const { addErrorContext, flattenLists, isBlankLine } = shared;
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD032", "blanks-around-lists" ],
|
||||
"description": "Lists should be surrounded by blank lines",
|
||||
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
||||
"function": function MD032(params, onError) {
|
||||
shared.flattenLists().filter((list) => !list.nesting).forEach((list) => {
|
||||
const firstLineIndex = list.open.map[0];
|
||||
if (!blankLineRe.test(params.lines[firstLineIndex - 1] || "")) {
|
||||
shared.addErrorContext(
|
||||
onError, firstLineIndex + 1, params.lines[firstLineIndex].trim());
|
||||
const { lines } = params;
|
||||
flattenLists().filter((list) => !list.nesting).forEach((list) => {
|
||||
const firstIndex = list.open.map[0];
|
||||
if (!isBlankLine(lines[firstIndex - 1])) {
|
||||
addErrorContext(onError, firstIndex + 1, lines[firstIndex].trim());
|
||||
}
|
||||
const bottomLineIndex = list.lastLineIndex - 1;
|
||||
if (!blankLineRe.test(params.lines[bottomLineIndex + 1] || "")) {
|
||||
shared.addErrorContext(
|
||||
onError, bottomLineIndex + 1, params.lines[bottomLineIndex].trim());
|
||||
const lastIndex = list.lastLineIndex - 1;
|
||||
if (!isBlankLine(lines[lastIndex + 1])) {
|
||||
addErrorContext(onError, lastIndex + 1, lines[lastIndex].trim());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue