mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-18 06:50:12 +01:00
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`.
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
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);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
};
|