mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-19 23:40:12 +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
41
lib/rules/noEmphasisAsHeader.js
Normal file
41
lib/rules/noEmphasisAsHeader.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
module.exports = {
|
||||
"name": "MD036",
|
||||
"desc": "Emphasis used instead of a header",
|
||||
"tags": [ "headers", "emphasis" ],
|
||||
"aliases": [ "no-emphasis-as-header" ],
|
||||
"regexp": null,
|
||||
"func": function MD036(params, errors) {
|
||||
var punctuation = params.options.punctuation || ".,;:!?";
|
||||
var re = new RegExp("[" + punctuation + "]$");
|
||||
function base(token) {
|
||||
if (token.type === "paragraph_open") {
|
||||
return function inParagraph(t) {
|
||||
if ((t.type === "inline") &&
|
||||
(t.children.length === 3) &&
|
||||
((t.children[0].type === "strong_open") ||
|
||||
(t.children[0].type === "em_open")) &&
|
||||
(t.children[1].type === "text") &&
|
||||
!re.test(t.children[1].content)) {
|
||||
errors.addContext(t.lineNumber, t.children[1].content);
|
||||
}
|
||||
};
|
||||
} else if (token.type === "blockquote_open") {
|
||||
return function inBlockquote(t) {
|
||||
if (t.type !== "blockquote_close") {
|
||||
return inBlockquote;
|
||||
}
|
||||
};
|
||||
} else if (token.type === "list_item_open") {
|
||||
return function inListItem(t) {
|
||||
if (t.type !== "list_item_close") {
|
||||
return inListItem;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
var state = base;
|
||||
params.tokens.forEach(function forToken(token) {
|
||||
state = state(token) || base;
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue