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
38
lib/rules/noMultipleSpaceBlockQuote.js
Normal file
38
lib/rules/noMultipleSpaceBlockQuote.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
var shared = require("../shared");
|
||||
var expressions = require("../expressions");
|
||||
|
||||
module.exports = {
|
||||
"name": "MD027",
|
||||
"desc": "Multiple spaces after blockquote symbol",
|
||||
"tags": [ "blockquote", "whitespace", "indentation" ],
|
||||
"aliases": [ "no-multiple-space-blockquote" ],
|
||||
"regexp": expressions.spaceAfterBlockQuote,
|
||||
"func": function MD027(params, errors) {
|
||||
var blockquoteNesting = 0;
|
||||
var listItemNesting = 0;
|
||||
params.tokens.forEach(function forToken(token) {
|
||||
if (token.type === "blockquote_open") {
|
||||
blockquoteNesting++;
|
||||
} else if (token.type === "blockquote_close") {
|
||||
blockquoteNesting--;
|
||||
} else if (token.type === "list_item_open") {
|
||||
listItemNesting++;
|
||||
} else if (token.type === "list_item_close") {
|
||||
listItemNesting--;
|
||||
} else if ((token.type === "inline") && (blockquoteNesting > 0)) {
|
||||
var multipleSpaces = listItemNesting ?
|
||||
/^(\s*>)+\s\s+>/.test(token.line) :
|
||||
/^(\s*>)+\s\s/.test(token.line);
|
||||
if (multipleSpaces) {
|
||||
errors.addContext(token.lineNumber, token.line);
|
||||
}
|
||||
token.content.split(shared.newLineRe)
|
||||
.forEach(function forLine(line, offset) {
|
||||
if (/^\s/.test(line)) {
|
||||
errors.addContext(token.lineNumber + offset, "> " + line);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue