mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-24 09:50:13 +01:00
Update MD034/no-bare-urls to report multiple instances on the same line.
This commit is contained in:
parent
a75f1ecf2a
commit
737126cf93
5 changed files with 37 additions and 23 deletions
45
lib/md034.js
45
lib/md034.js
|
|
@ -18,28 +18,29 @@ module.exports = {
|
|||
inLink = true;
|
||||
} else if (type === "link_close") {
|
||||
inLink = false;
|
||||
} else if ((type === "text") && !inLink &&
|
||||
(match = bareUrlRe.exec(content))) {
|
||||
const [ bareUrl ] = match;
|
||||
const index = line.indexOf(content);
|
||||
const range = (index === -1) ? null : [
|
||||
line.indexOf(content) + match.index + 1,
|
||||
bareUrl.length
|
||||
];
|
||||
const fixInfo = range ? {
|
||||
"editColumn": range[0],
|
||||
"deleteCount": range[1],
|
||||
"insertText": `<${bareUrl}>`
|
||||
} : null;
|
||||
addErrorContext(
|
||||
onError,
|
||||
lineNumber,
|
||||
bareUrl,
|
||||
null,
|
||||
null,
|
||||
range,
|
||||
fixInfo
|
||||
);
|
||||
} else if ((type === "text") && !inLink) {
|
||||
while ((match = bareUrlRe.exec(content)) !== null) {
|
||||
const [ bareUrl ] = match;
|
||||
const index = line.indexOf(content);
|
||||
const range = (index === -1) ? null : [
|
||||
line.indexOf(content) + match.index + 1,
|
||||
bareUrl.length
|
||||
];
|
||||
const fixInfo = range ? {
|
||||
"editColumn": range[0],
|
||||
"deleteCount": range[1],
|
||||
"insertText": `<${bareUrl}>`
|
||||
} : null;
|
||||
addErrorContext(
|
||||
onError,
|
||||
lineNumber,
|
||||
bareUrl,
|
||||
null,
|
||||
null,
|
||||
range,
|
||||
fixInfo
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue