mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-20 16:00: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,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { addErrorContext, filterTokens, rangeFromRegExp } =
|
||||
require("../helpers");
|
||||
|
||||
const emptyLinkRe = /\[[^\]]*](?:\((?:#?|(?:<>))\))/;
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ module.exports = {
|
|||
"description": "No empty links",
|
||||
"tags": [ "links" ],
|
||||
"function": function MD042(params, onError) {
|
||||
shared.filterTokens(params, "inline", function forToken(token) {
|
||||
filterTokens(params, "inline", function forToken(token) {
|
||||
let inLink = false;
|
||||
let linkText = "";
|
||||
let emptyLink = false;
|
||||
|
|
@ -27,9 +28,9 @@ module.exports = {
|
|||
} else if (child.type === "link_close") {
|
||||
inLink = false;
|
||||
if (emptyLink) {
|
||||
shared.addErrorContext(onError, child.lineNumber,
|
||||
addErrorContext(onError, child.lineNumber,
|
||||
"[" + linkText + "]()", null, null,
|
||||
shared.rangeFromRegExp(child.line, emptyLinkRe));
|
||||
rangeFromRegExp(child.line, emptyLinkRe));
|
||||
}
|
||||
} else if (inLink) {
|
||||
linkText += child.content;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue