mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +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
11
lib/md034.js
11
lib/md034.js
|
|
@ -2,14 +2,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { addErrorContext, bareUrlRe, filterTokens, rangeFromRegExp } =
|
||||
require("../helpers");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD034", "no-bare-urls" ],
|
||||
"description": "Bare URL used",
|
||||
"tags": [ "links", "url" ],
|
||||
"function": function MD034(params, onError) {
|
||||
shared.filterTokens(params, "inline", function forToken(token) {
|
||||
filterTokens(params, "inline", function forToken(token) {
|
||||
let inLink = false;
|
||||
token.children.forEach(function forChild(child) {
|
||||
let match = null;
|
||||
|
|
@ -19,9 +20,9 @@ module.exports = {
|
|||
inLink = false;
|
||||
} else if ((child.type === "text") &&
|
||||
!inLink &&
|
||||
(match = shared.bareUrlRe.exec(child.content))) {
|
||||
shared.addErrorContext(onError, child.lineNumber, match[0], null,
|
||||
null, shared.rangeFromRegExp(child.line, shared.bareUrlRe));
|
||||
(match = bareUrlRe.exec(child.content))) {
|
||||
addErrorContext(onError, child.lineNumber, match[0], null,
|
||||
null, rangeFromRegExp(child.line, bareUrlRe));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue