mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
30 lines
912 B
JavaScript
30 lines
912 B
JavaScript
// @ts-check
|
|
|
|
"use strict";
|
|
|
|
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) {
|
|
filterTokens(params, "inline", function forToken(token) {
|
|
let inLink = false;
|
|
token.children.forEach(function forChild(child) {
|
|
let match = null;
|
|
if (child.type === "link_open") {
|
|
inLink = true;
|
|
} else if (child.type === "link_close") {
|
|
inLink = false;
|
|
} else if ((child.type === "text") &&
|
|
!inLink &&
|
|
(match = bareUrlRe.exec(child.content))) {
|
|
addErrorContext(onError, child.lineNumber, match[0], null,
|
|
null, rangeFromRegExp(child.line, bareUrlRe));
|
|
}
|
|
});
|
|
});
|
|
}
|
|
};
|