mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Move each rule implementation into its own file (fixes #83).
This commit is contained in:
parent
49e36f817c
commit
9ba143555d
42 changed files with 1289 additions and 1028 deletions
29
lib/md034.js
Normal file
29
lib/md034.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
var shared = require("./shared");
|
||||
|
||||
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) {
|
||||
var inLink = false;
|
||||
token.children.forEach(function forChild(child) {
|
||||
var match = null;
|
||||
if (child.type === "link_open") {
|
||||
inLink = true;
|
||||
} else if (child.type === "link_close") {
|
||||
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));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue