mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-03-13 05:36:13 +01:00
Add support for using custom rules.
This commit is contained in:
parent
4619a8c824
commit
f24f98e146
11 changed files with 497 additions and 71 deletions
28
test/rules/letters-E-X.js
Normal file
28
test/rules/letters-E-X.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"names": [ "letters-E-X", "letter-E-letter-X", "contains-ex" ],
|
||||
"description": "Rule that reports an error for lines with the letters 'EX'",
|
||||
"tags": [ "test" ],
|
||||
"function": function rule(params, onError) {
|
||||
params.tokens.filter(function filterToken(token) {
|
||||
return token.type === "inline";
|
||||
}).forEach(function forToken(inline) {
|
||||
inline.children.filter(function filterChild(child) {
|
||||
return child.type === "text";
|
||||
}).forEach(function forChild(text) {
|
||||
var index = text.content.toLowerCase().indexOf("ex");
|
||||
if (index !== -1) {
|
||||
onError({
|
||||
"lineNumber": text.lineNumber,
|
||||
"detail": null,
|
||||
"context": text.content.substr(index - 1, 4),
|
||||
"range": null
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue