mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Expose shared.js helper code for custom rule authors (fixes #134).
This commit is contained in:
parent
f614f3e1ce
commit
7e980401b8
52 changed files with 283 additions and 184 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { addError, forEachHeading, rangeFromRegExp } = require("../helpers");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD026", "no-trailing-punctuation" ],
|
||||
|
|
@ -11,12 +11,12 @@ module.exports = {
|
|||
"function": function MD026(params, onError) {
|
||||
const punctuation = params.config.punctuation || ".,;:!?";
|
||||
const trailingPunctuationRe = new RegExp("[" + punctuation + "]$");
|
||||
shared.forEachHeading(params, function forHeading(heading, content) {
|
||||
forEachHeading(params, function forHeading(heading, content) {
|
||||
const match = trailingPunctuationRe.exec(content);
|
||||
if (match) {
|
||||
shared.addError(onError, heading.lineNumber,
|
||||
addError(onError, heading.lineNumber,
|
||||
"Punctuation: '" + match[0] + "'", null,
|
||||
shared.rangeFromRegExp(heading.line, trailingPunctuationRe));
|
||||
rangeFromRegExp(heading.line, trailingPunctuationRe));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue