Update MD054/link-image-style handling of url_inline to ensure link and destination match and that the destination is autolink-able (fixes #1040).

This commit is contained in:
David Anson 2023-11-14 19:56:23 -08:00
parent ff465262c9
commit 41bc8465d2
7 changed files with 86 additions and 2 deletions

View file

@ -29,6 +29,11 @@
"strict": true,
"code_blocks": false
},
"link-image-style": {
"collapsed": false,
"shortcut": false,
"url_inline": false
},
"no-duplicate-heading": {
"siblings_only": true
},

View file

@ -6673,7 +6673,7 @@ module.exports = {
if (destination) {
// link kind is an inline link
var title = getTokenTextByType(descendents, "resourceTitleString");
isError = !inline || !urlInline && autolink && !title && !image;
isError = !inline || !urlInline && autolink && !image && !title && label === destination && autolinkAble(destination);
} else {
// link kind is a full/collapsed/shortcut reference link
var isShortcut = !children.some(function (t) {

View file

@ -64,7 +64,14 @@ module.exports = {
if (destination) {
// link kind is an inline link
const title = getTokenTextByType(descendents, "resourceTitleString");
isError = !inline || (!urlInline && autolink && !title && !image);
isError = !inline || (
!urlInline &&
autolink &&
!image &&
!title &&
(label === destination) &&
autolinkAble(destination)
);
} else {
// link kind is a full/collapsed/shortcut reference link
const isShortcut = !children.some((t) => t.type === "reference");

View file

@ -29,6 +29,24 @@ Text <https://example.com> text {MD054}
[url]: https://example.com
[url-title]: https://example.com "title"
Text [link](https://example.com) text
Text ![link](https://example.com) text
Text [link][url] text
Text ![link][url] text
Text [url][] text
Text ![url][] text
Text [url] text
Text ![url] text
Text [file.md](file.md) text
<!-- markdownlint-configure-file {
"link-image-style": {
"autolink": false,

View file

@ -29,6 +29,24 @@ Text <https://example.com> text
[url]: https://example.com
[url-title]: https://example.com "title"
Text [link](https://example.com) text
Text ![link](https://example.com) text
Text [link][url] text
Text ![link][url] text
Text [url][] text
Text ![url][] text
Text [url] text
Text ![url] text
Text [file.md](file.md) text
<!-- markdownlint-configure-file {
"link-image-style": {
"url_inline": false

View file

@ -27049,6 +27049,24 @@ Generated by [AVA](https://avajs.dev).
[url]: https://example.com␊
[url-title]: https://example.com "title"␊
Text [link](https://example.com) text␊
Text ![link](https://example.com) text␊
Text [link][url] text␊
Text ![link][url] text␊
Text [url][] text␊
Text ![url][] text␊
Text [url] text␊
Text ![url] text␊
Text [file.md](file.md) text␊
<!-- markdownlint-configure-file {␊
"link-image-style": {␊
"autolink": false,␊
@ -27136,6 +27154,24 @@ Generated by [AVA](https://avajs.dev).
[url]: https://example.com␊
[url-title]: https://example.com "title"␊
Text [link](https://example.com) text␊
Text ![link](https://example.com) text␊
Text [link][url] text␊
Text ![link][url] text␊
Text [url][] text␊
Text ![url][] text␊
Text [url] text␊
Text ![url] text␊
Text [file.md](file.md) text␊
<!-- markdownlint-configure-file {␊
"link-image-style": {␊
"url_inline": false␊