mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Move each rule implementation into its own file (fixes #83).
This commit is contained in:
parent
49e36f817c
commit
9ba143555d
42 changed files with 1289 additions and 1028 deletions
23
lib/md026.js
Normal file
23
lib/md026.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
var shared = require("./shared");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD026", "no-trailing-punctuation" ],
|
||||
"description": "Trailing punctuation in header",
|
||||
"tags": [ "headers" ],
|
||||
"function": function MD026(params, onError) {
|
||||
var punctuation = params.config.punctuation || ".,;:!?";
|
||||
var trailingPunctuationRe = new RegExp("[" + punctuation + "]$");
|
||||
shared.forEachHeading(params, function forHeading(heading, content) {
|
||||
var match = trailingPunctuationRe.exec(content);
|
||||
if (match) {
|
||||
shared.addError(onError, heading.lineNumber,
|
||||
"Punctuation: '" + match[0] + "'", null,
|
||||
shared.rangeFromRegExp(heading.line, trailingPunctuationRe));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue