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`.
41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
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;
|
|
});
|
|
}
|
|
};
|