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

@ -64,6 +64,13 @@ module.exports.isEmptyString = function isEmptyString(str) {
return str.length === 0;
};
// Returns true iff the input line is blank (no content)
// Example: Contains nothing, whitespace, or comments
const blankLineRe = />|(?:<!--.*?-->)/g;
module.exports.isBlankLine = function isBlankLine(line) {
return !line || !line.trim() || !line.replace(blankLineRe, "").trim();
};
// Replaces the text of all properly-formatted HTML comments with whitespace
// This preserves the line/column information for the rest of the document
// Trailing whitespace is avoided with a '\' character in the last column