mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Handle parser inconsistency for "u@.com" to avoid repeatedly wrapping with "<>" when fixing the bare URL (email) (fixes #1140).
This commit is contained in:
parent
902783df21
commit
2b73095ebd
5 changed files with 49 additions and 3 deletions
|
@ -5090,7 +5090,28 @@ module.exports = {
|
|||
const literalAutolinks = (tokens) => (
|
||||
filterByPredicate(
|
||||
tokens,
|
||||
(token) => (token.type === "literalAutolink") && !inHtmlFlow(token),
|
||||
(token) => {
|
||||
if ((token.type === "literalAutolink") && !inHtmlFlow(token)) {
|
||||
// Detect and ignore https://github.com/micromark/micromark/issues/164
|
||||
const siblings = token.parent?.children;
|
||||
// Commented-out due to not being able to exercise in test/code coverage
|
||||
// || micromarkTokens;
|
||||
const index = siblings?.indexOf(token);
|
||||
// @ts-ignore
|
||||
const prev = siblings?.at(index - 1);
|
||||
// @ts-ignore
|
||||
const next = siblings?.at(index + 1);
|
||||
return !(
|
||||
prev &&
|
||||
next &&
|
||||
(prev.type === "data") &&
|
||||
(next.type === "data") &&
|
||||
prev.text.endsWith("<") &&
|
||||
next.text.startsWith(">")
|
||||
);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
(token) => {
|
||||
const { children } = token;
|
||||
const result = [];
|
||||
|
|
23
lib/md034.js
23
lib/md034.js
|
@ -21,7 +21,28 @@ module.exports = {
|
|||
const literalAutolinks = (tokens) => (
|
||||
filterByPredicate(
|
||||
tokens,
|
||||
(token) => (token.type === "literalAutolink") && !inHtmlFlow(token),
|
||||
(token) => {
|
||||
if ((token.type === "literalAutolink") && !inHtmlFlow(token)) {
|
||||
// Detect and ignore https://github.com/micromark/micromark/issues/164
|
||||
const siblings = token.parent?.children;
|
||||
// Commented-out due to not being able to exercise in test/code coverage
|
||||
// || micromarkTokens;
|
||||
const index = siblings?.indexOf(token);
|
||||
// @ts-ignore
|
||||
const prev = siblings?.at(index - 1);
|
||||
// @ts-ignore
|
||||
const next = siblings?.at(index + 1);
|
||||
return !(
|
||||
prev &&
|
||||
next &&
|
||||
(prev.type === "data") &&
|
||||
(next.type === "data") &&
|
||||
prev.text.endsWith("<") &&
|
||||
next.text.startsWith(">")
|
||||
);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
(token) => {
|
||||
const { children } = token;
|
||||
const result = [];
|
||||
|
|
|
@ -97,6 +97,8 @@ Email addresses are treated similarly: user@example.com {MD034}
|
|||
|
||||
Angle brackets work the same for email: <user@example.com>
|
||||
|
||||
Unusual email addresses are handled: <user@.com>
|
||||
|
||||
---
|
||||
|
||||
[is-a-valid]: https://example.com
|
||||
|
|
|
@ -3539,7 +3539,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 59,
|
||||
insertText: '<https://example.com>',
|
||||
},
|
||||
lineNumber: 104,
|
||||
lineNumber: 106,
|
||||
ruleDescription: 'Bare URL used',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md034.md',
|
||||
ruleNames: [
|
||||
|
@ -3647,6 +3647,8 @@ Generated by [AVA](https://avajs.dev).
|
|||
␊
|
||||
Angle brackets work the same for email: <user@example.com>␊
|
||||
␊
|
||||
Unusual email addresses are handled: <user@.com>␊
|
||||
␊
|
||||
---␊
|
||||
␊
|
||||
[is-a-valid]: https://example.com␊
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue