mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add support for inline comments markdownlint-capture/markdownlint-restore (fixes #194).
This commit is contained in:
parent
64351f73be
commit
65052f6200
5 changed files with 167 additions and 15 deletions
|
@ -255,16 +255,24 @@ function getEnabledRulesPerLineNumber(
|
|||
allRuleNames.push(ruleName);
|
||||
enabledRules[ruleName] = !!effectiveConfig[ruleName];
|
||||
});
|
||||
let capturedRules = enabledRules;
|
||||
function forMatch(match) {
|
||||
const enabled = match[1].toUpperCase() === "EN";
|
||||
const items = match[2] ?
|
||||
match[2].trim().toUpperCase().split(/\s+/) :
|
||||
allRuleNames;
|
||||
items.forEach(function forItem(nameUpper) {
|
||||
(aliasToRuleNames[nameUpper] || []).forEach(function forRule(ruleName) {
|
||||
enabledRules[ruleName] = enabled;
|
||||
const action = match[1].toUpperCase();
|
||||
if (action === "CAPTURE") {
|
||||
capturedRules = { ...enabledRules };
|
||||
} else if (action === "RESTORE") {
|
||||
enabledRules = { ...capturedRules };
|
||||
} else {
|
||||
const enabled = (action === "ENABLE");
|
||||
const items = match[2] ?
|
||||
match[2].trim().toUpperCase().split(/\s+/) :
|
||||
allRuleNames;
|
||||
items.forEach(function forItem(nameUpper) {
|
||||
(aliasToRuleNames[nameUpper] || []).forEach(function forRule(ruleName) {
|
||||
enabledRules[ruleName] = enabled;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
const enabledRulesPerLineNumber = new Array(1 + frontMatterLines.length);
|
||||
lines.forEach(function forLine(line) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue