markdownlint/lib/md026.js
Milos Levacic 45424cf459 Change "header" to "heading" across the library
This should be backward compatible, as all "header" aliases are still
available, though documented as discouraged for future use.
2018-04-18 22:27:48 -07:00

23 lines
749 B
JavaScript

// @ts-check
"use strict";
var shared = require("./shared");
module.exports = {
"names": [ "MD026", "no-trailing-punctuation" ],
"description": "Trailing punctuation in heading",
"tags": [ "headings", "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));
}
});
}
};