mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Update definition of helpers.isBlankLine to treat unterminated start/end comments as potentially blank lines (fixes #431).
This commit is contained in:
parent
1b23976aa2
commit
6dea67825a
4 changed files with 67 additions and 11 deletions
|
|
@ -77,12 +77,18 @@ module.exports.isObject = function isObject(obj) {
|
|||
return (obj !== null) && (typeof obj === "object") && !Array.isArray(obj);
|
||||
};
|
||||
// Returns true iff the input line is blank (no content)
|
||||
// Example: Contains nothing, whitespace, or comments
|
||||
var blankLineRe = />|(?:<!--.*?-->)/g;
|
||||
// Example: Contains nothing, whitespace, or comment (unclosed start/end okay)
|
||||
module.exports.isBlankLine = function isBlankLine(line) {
|
||||
// Call to String.replace follows best practices and is not a security check
|
||||
// False-positive for js/incomplete-multi-character-sanitization
|
||||
return !line || !line.trim() || !line.replace(blankLineRe, "").trim();
|
||||
return (!line ||
|
||||
!line.trim() ||
|
||||
!line
|
||||
.replace(/<!--.*?-->/g, "")
|
||||
.replace(/<!--.*$/g, "")
|
||||
.replace(/^.*-->/g, "")
|
||||
.replace(/>/g, "")
|
||||
.trim());
|
||||
};
|
||||
/**
|
||||
* Compare function for Array.prototype.sort for ascending order of numbers.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue