Update MD031/blanks-around-fences and MD032/blanks-around-lists to ignore comments and blockquotes (fixes #171, fixes #172).

This commit is contained in:
David Anson 2019-03-20 21:48:18 -07:00
parent df2507f030
commit 1db87ef0c6
5 changed files with 120 additions and 16 deletions

View file

@ -3,17 +3,19 @@
"use strict";
const shared = require("./shared");
const { addErrorContext, forEachLine, isBlankLine } = shared;
module.exports = {
"names": [ "MD031", "blanks-around-fences" ],
"description": "Fenced code blocks should be surrounded by blank lines",
"tags": [ "code", "blank_lines" ],
"function": function MD031(params, onError) {
const lines = params.lines;
shared.forEachLine(function forLine(line, i, inCode, onFence) {
if (((onFence > 0) && (i - 1 >= 0) && lines[i - 1].length) ||
((onFence < 0) && (i + 1 < lines.length) && lines[i + 1].length)) {
shared.addErrorContext(onError, i + 1, lines[i].trim());
const { lines } = params;
const { length } = lines;
forEachLine(function forLine(line, i, inCode, onFence) {
if (((onFence > 0) && (i - 1 >= 0) && !isBlankLine(lines[i - 1])) ||
((onFence < 0) && (i + 1 < length) && !isBlankLine(lines[i + 1]))) {
addErrorContext(onError, i + 1, lines[i].trim());
}
});
}