mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add maximum parameter to MD012/no-multiple-blanks (fixes #27).
This commit is contained in:
parent
ce9ec8fb5e
commit
affd94e061
6 changed files with 86 additions and 5 deletions
|
@ -306,6 +306,8 @@ Tags: whitespace, blank_lines
|
|||
|
||||
Aliases: no-multiple-blanks
|
||||
|
||||
Parameters: maximum (number; default 1)
|
||||
|
||||
This rule is triggered when there are multiple consecutive blank lines in the
|
||||
document:
|
||||
|
||||
|
@ -323,6 +325,9 @@ To fix this, delete the offending lines:
|
|||
Note: this rule will not be triggered if there are multiple consecutive blank
|
||||
lines inside code blocks.
|
||||
|
||||
Note: The `maximum` parameter can be used to configure the maximum number of
|
||||
consecutive blank lines.
|
||||
|
||||
## MD013 - Line length
|
||||
|
||||
Tags: line_length
|
||||
|
|
|
@ -358,13 +358,13 @@ module.exports = [
|
|||
"tags": [ "whitespace", "blank_lines" ],
|
||||
"aliases": [ "no-multiple-blanks" ],
|
||||
"func": function MD012(params, errors) {
|
||||
var prevLine = "-";
|
||||
var maximum = params.options.maximum || 1;
|
||||
var count = 0;
|
||||
forEachLine(params, function forLine(line, lineIndex, inCode) {
|
||||
line = line.trim();
|
||||
if (!inCode && !line.length && !prevLine.length) {
|
||||
count = (inCode || line.trim().length) ? 0 : count + 1;
|
||||
if (maximum < count) {
|
||||
errors.push(lineIndex + 1);
|
||||
}
|
||||
prevLine = line;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -857,7 +857,7 @@ module.exports.readme = function readme(test) {
|
|||
};
|
||||
|
||||
module.exports.doc = function doc(test) {
|
||||
test.expect(294);
|
||||
test.expect(295);
|
||||
fs.readFile("doc/Rules.md", shared.utf8Encoding,
|
||||
function readFile(err, contents) {
|
||||
test.ifError(err);
|
||||
|
|
6
test/no-multiple-blanks-maximum.json
Normal file
6
test/no-multiple-blanks-maximum.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"default": true,
|
||||
"MD012": {
|
||||
"maximum": 3
|
||||
}
|
||||
}
|
46
test/no-multiple-blanks-maximum.md
Normal file
46
test/no-multiple-blanks-maximum.md
Normal file
|
@ -0,0 +1,46 @@
|
|||
# Heading
|
||||
|
||||
Text
|
||||
|
||||
Text
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
|
||||
|
||||
Text {MD012:16}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Text {MD012:21} {MD012:22}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Text {MD012:27} {MD012:28} {MD012:29}
|
||||
|
||||
Text
|
||||
|
||||
|
||||
|
||||
|
||||
Text {MD012:36}
|
||||
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
Text
|
||||
|
||||
Text
|
24
test/no-multiple-blanks.md
Normal file
24
test/no-multiple-blanks.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Heading
|
||||
|
||||
Text
|
||||
|
||||
Text
|
||||
|
||||
|
||||
Text {MD012:7}
|
||||
|
||||
|
||||
|
||||
Text {MD012:10} {MD012:11}
|
||||
|
||||
|
||||
|
||||
|
||||
Text {MD012:14} {MD012:15} {MD012:16}
|
||||
|
||||
Text
|
||||
|
||||
|
||||
Text {MD012:21}
|
||||
|
||||
Text
|
Loading…
Add table
Add a link
Reference in a new issue