mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Update MD034/no-bare-urls to restore per-sibling scan (vs. all-element scan) and ignore tokens inside an htmlFlow context.
This commit is contained in:
parent
a084c2525c
commit
739cfb6fe2
6 changed files with 123 additions and 56 deletions
|
|
@ -5155,6 +5155,7 @@ var _require2 = __webpack_require__(/*! ../helpers/micromark.cjs */ "../helpers/
|
|||
filterByPredicate = _require2.filterByPredicate,
|
||||
filterByTypes = _require2.filterByTypes,
|
||||
getHtmlTagInfo = _require2.getHtmlTagInfo,
|
||||
inHtmlFlow = _require2.inHtmlFlow,
|
||||
parse = _require2.parse;
|
||||
module.exports = {
|
||||
"names": ["MD034", "no-bare-urls"],
|
||||
|
|
@ -5162,36 +5163,36 @@ module.exports = {
|
|||
"tags": ["links", "url"],
|
||||
"function": function MD034(params, onError) {
|
||||
var literalAutolinks = function literalAutolinks(tokens) {
|
||||
var flattened = filterByPredicate(tokens, function () {
|
||||
return true;
|
||||
});
|
||||
var result = [];
|
||||
for (var i = 0; i < flattened.length; i++) {
|
||||
var current = flattened[i];
|
||||
var openTagInfo = getHtmlTagInfo(current);
|
||||
if (openTagInfo && !openTagInfo.close) {
|
||||
var count = 1;
|
||||
for (var j = i + 1; j < flattened.length; j++) {
|
||||
var candidate = flattened[j];
|
||||
var closeTagInfo = getHtmlTagInfo(candidate);
|
||||
if (closeTagInfo && openTagInfo.name === closeTagInfo.name) {
|
||||
if (closeTagInfo.close) {
|
||||
count--;
|
||||
if (count === 0) {
|
||||
i = j;
|
||||
break;
|
||||
return filterByPredicate(tokens, function (token) {
|
||||
return token.type === "literalAutolink" && !inHtmlFlow(token);
|
||||
}, function (token) {
|
||||
var children = token.children;
|
||||
var result = [];
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var current = children[i];
|
||||
var openTagInfo = getHtmlTagInfo(current);
|
||||
if (openTagInfo && !openTagInfo.close) {
|
||||
var count = 1;
|
||||
for (var j = i + 1; j < children.length; j++) {
|
||||
var candidate = children[j];
|
||||
var closeTagInfo = getHtmlTagInfo(candidate);
|
||||
if (closeTagInfo && openTagInfo.name === closeTagInfo.name) {
|
||||
if (closeTagInfo.close) {
|
||||
count--;
|
||||
if (count === 0) {
|
||||
i = j;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result.push(current);
|
||||
}
|
||||
} else {
|
||||
result.push(current);
|
||||
}
|
||||
}
|
||||
return result.filter(function (token) {
|
||||
return token.type === "literalAutolink";
|
||||
return result;
|
||||
});
|
||||
};
|
||||
var autoLinks = filterByTypes(params.parsers.micromark.tokens, ["literalAutolink"]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue