mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-19 07:20:13 +01:00
Moved rules into their own files
Everything under `lib/rules/*` is a rules file (with the name of the rule in camelCase), re-exported into an array in `lib/rules.js`. Moved the regular expressions from `lib/rules.js` to `lib/expressions.js`, and the rest of the variables into `lib/shared.js`.
This commit is contained in:
parent
77e27cbe09
commit
b63647f6b1
43 changed files with 1283 additions and 1177 deletions
33
lib/rules/blanksAroundLists.js
Normal file
33
lib/rules/blanksAroundLists.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
var shared = require("../shared");
|
||||
var expressions = require("../expressions");
|
||||
|
||||
module.exports = {
|
||||
"name": "MD032",
|
||||
"desc": "Lists should be surrounded by blank lines",
|
||||
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
||||
"aliases": [ "blanks-around-lists" ],
|
||||
"regexp": null,
|
||||
"func": function MD032(params, errors) {
|
||||
var blankOrListRe = /^[\s>]*($|\s)/;
|
||||
var inList = false;
|
||||
var prevLine = "";
|
||||
shared.forEachLine(params, function forLine(line, lineIndex, inCode, onFence) {
|
||||
if (!inCode || onFence) {
|
||||
var lineTrim = line.trim();
|
||||
var listMarker = expressions.listItemMarkerRe.test(lineTrim);
|
||||
if (listMarker && !inList && !blankOrListRe.test(prevLine)) {
|
||||
// Check whether this list prefix can interrupt a paragraph
|
||||
if (expressions.listItemMarkerInterruptsRe.test(lineTrim)) {
|
||||
errors.addContext(lineIndex + 1, lineTrim);
|
||||
} else {
|
||||
listMarker = false;
|
||||
}
|
||||
} else if (!listMarker && inList && !blankOrListRe.test(line)) {
|
||||
errors.addContext(lineIndex, lineTrim);
|
||||
}
|
||||
inList = listMarker;
|
||||
}
|
||||
prevLine = line;
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue