Move each rule implementation into its own file (fixes #83).

This commit is contained in:
David Anson 2018-01-21 21:44:25 -08:00
parent 49e36f817c
commit 9ba143555d
42 changed files with 1289 additions and 1028 deletions

26
lib/md025.js Normal file
View file

@ -0,0 +1,26 @@
// @ts-check
"use strict";
var shared = require("./shared");
module.exports = {
"names": [ "MD025", "single-h1" ],
"description": "Multiple top level headers in the same document",
"tags": [ "headers" ],
"function": function MD025(params, onError) {
var level = params.config.level || 1;
var tag = "h" + level;
var hasTopLevelHeading = false;
shared.filterTokens(params, "heading_open", function forToken(token) {
if (token.tag === tag) {
if (hasTopLevelHeading) {
shared.addErrorContext(onError, token.lineNumber,
token.line.trim());
} else if (token.lineNumber === 1) {
hasTopLevelHeading = true;
}
}
});
}
};