mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
23 lines
777 B
JavaScript
23 lines
777 B
JavaScript
// @ts-check
|
|
|
|
"use strict";
|
|
|
|
const { addError, forEachHeading, rangeFromRegExp } = require("../helpers");
|
|
|
|
module.exports = {
|
|
"names": [ "MD026", "no-trailing-punctuation" ],
|
|
"description": "Trailing punctuation in heading",
|
|
"tags": [ "headings", "headers" ],
|
|
"function": function MD026(params, onError) {
|
|
const punctuation = params.config.punctuation || ".,;:!?";
|
|
const trailingPunctuationRe = new RegExp("[" + punctuation + "]$");
|
|
forEachHeading(params, function forHeading(heading, content) {
|
|
const match = trailingPunctuationRe.exec(content);
|
|
if (match) {
|
|
addError(onError, heading.lineNumber,
|
|
"Punctuation: '" + match[0] + "'", null,
|
|
rangeFromRegExp(heading.line, trailingPunctuationRe));
|
|
}
|
|
});
|
|
}
|
|
};
|