mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Update tests and documentation for MD034/no-bare-urls to explain edge case behavior.
This commit is contained in:
parent
b990b3ea77
commit
ddb71ed1e8
6 changed files with 106 additions and 3 deletions
|
|
@ -19,11 +19,24 @@ Not a clickable link: `https://www.example.com`
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: The following scenario does not trigger this rule because it could be a
|
Note: The following scenario does not trigger this rule because it could be a
|
||||||
valid shortcut link:
|
shortcut link:
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
[https://www.example.com]
|
[https://www.example.com]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: The following syntax triggers this rule because the nested link could be
|
||||||
|
a shortcut link (which takes precedence):
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
[text [shortcut] text](https://example.com)
|
||||||
|
```
|
||||||
|
|
||||||
|
To avoid this, escape both inner brackets:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
[link \[text\] link](https://example.com)
|
||||||
|
```
|
||||||
|
|
||||||
Rationale: Without angle brackets, a bare URL or email isn't converted into a
|
Rationale: Without angle brackets, a bare URL or email isn't converted into a
|
||||||
link by some Markdown parsers.
|
link by some Markdown parsers.
|
||||||
|
|
|
||||||
15
doc/Rules.md
15
doc/Rules.md
|
|
@ -1431,12 +1431,25 @@ Not a clickable link: `https://www.example.com`
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: The following scenario does not trigger this rule because it could be a
|
Note: The following scenario does not trigger this rule because it could be a
|
||||||
valid shortcut link:
|
shortcut link:
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
[https://www.example.com]
|
[https://www.example.com]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: The following syntax triggers this rule because the nested link could be
|
||||||
|
a shortcut link (which takes precedence):
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
[text [shortcut] text](https://example.com)
|
||||||
|
```
|
||||||
|
|
||||||
|
To avoid this, escape both inner brackets:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
[link \[text\] link](https://example.com)
|
||||||
|
```
|
||||||
|
|
||||||
Rationale: Without angle brackets, a bare URL or email isn't converted into a
|
Rationale: Without angle brackets, a bare URL or email isn't converted into a
|
||||||
link by some Markdown parsers.
|
link by some Markdown parsers.
|
||||||
|
|
||||||
|
|
|
||||||
15
doc/md034.md
15
doc/md034.md
|
|
@ -27,11 +27,24 @@ Not a clickable link: `https://www.example.com`
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: The following scenario does not trigger this rule because it could be a
|
Note: The following scenario does not trigger this rule because it could be a
|
||||||
valid shortcut link:
|
shortcut link:
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
[https://www.example.com]
|
[https://www.example.com]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: The following syntax triggers this rule because the nested link could be
|
||||||
|
a shortcut link (which takes precedence):
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
[text [shortcut] text](https://example.com)
|
||||||
|
```
|
||||||
|
|
||||||
|
To avoid this, escape both inner brackets:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
[link \[text\] link](https://example.com)
|
||||||
|
```
|
||||||
|
|
||||||
Rationale: Without angle brackets, a bare URL or email isn't converted into a
|
Rationale: Without angle brackets, a bare URL or email isn't converted into a
|
||||||
link by some Markdown parsers.
|
link by some Markdown parsers.
|
||||||
|
|
|
||||||
|
|
@ -76,3 +76,15 @@ Links with spaces inside angle brackets are okay: [blue jay](<https://en.wikiped
|
||||||
Email addresses are treated similarly: user@example.com {MD034}
|
Email addresses are treated similarly: user@example.com {MD034}
|
||||||
|
|
||||||
Angle brackets work the same for email: <user@example.com>
|
Angle brackets work the same for email: <user@example.com>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
[is-a-valid]: https://example.com
|
||||||
|
|
||||||
|
Links bind to the innermost [link that [is-a-valid] link](https://example.com) {MD034}
|
||||||
|
|
||||||
|
But not if the [link [is-not-a-valid] link](https://example.com) {MD034}
|
||||||
|
HOWEVER this scenario could have an invalid shortcut and IS reported
|
||||||
|
|
||||||
|
Escaping both inner square brackets avoids the unwanted report:
|
||||||
|
[link \[is-not-a-valid\] link](https://example.com)
|
||||||
|
|
|
||||||
|
|
@ -3164,6 +3164,46 @@ Generated by [AVA](https://avajs.dev).
|
||||||
'no-bare-urls',
|
'no-bare-urls',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
errorContext: 'https://example.com',
|
||||||
|
errorDetail: null,
|
||||||
|
errorRange: [
|
||||||
|
59,
|
||||||
|
19,
|
||||||
|
],
|
||||||
|
fixInfo: {
|
||||||
|
deleteCount: 19,
|
||||||
|
editColumn: 59,
|
||||||
|
insertText: '<https://example.com>',
|
||||||
|
},
|
||||||
|
lineNumber: 84,
|
||||||
|
ruleDescription: 'Bare URL used',
|
||||||
|
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md034.md',
|
||||||
|
ruleNames: [
|
||||||
|
'MD034',
|
||||||
|
'no-bare-urls',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
errorContext: 'https://example.com',
|
||||||
|
errorDetail: null,
|
||||||
|
errorRange: [
|
||||||
|
45,
|
||||||
|
19,
|
||||||
|
],
|
||||||
|
fixInfo: {
|
||||||
|
deleteCount: 19,
|
||||||
|
editColumn: 45,
|
||||||
|
insertText: '<https://example.com>',
|
||||||
|
},
|
||||||
|
lineNumber: 86,
|
||||||
|
ruleDescription: 'Bare URL used',
|
||||||
|
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md034.md',
|
||||||
|
ruleNames: [
|
||||||
|
'MD034',
|
||||||
|
'no-bare-urls',
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
fixed: `# Detailed Results Bare URLs␊
|
fixed: `# Detailed Results Bare URLs␊
|
||||||
␊
|
␊
|
||||||
|
|
@ -3243,6 +3283,18 @@ Generated by [AVA](https://avajs.dev).
|
||||||
Email addresses are treated similarly: <user@example.com> {MD034}␊
|
Email addresses are treated similarly: <user@example.com> {MD034}␊
|
||||||
␊
|
␊
|
||||||
Angle brackets work the same for email: <user@example.com>␊
|
Angle brackets work the same for email: <user@example.com>␊
|
||||||
|
␊
|
||||||
|
---␊
|
||||||
|
␊
|
||||||
|
[is-a-valid]: https://example.com␊
|
||||||
|
␊
|
||||||
|
Links bind to the innermost [link that [is-a-valid] link](<https://example.com>) {MD034}␊
|
||||||
|
␊
|
||||||
|
But not if the [link [is-not-a-valid] link](<https://example.com>) {MD034}␊
|
||||||
|
HOWEVER this scenario could have an invalid shortcut and IS reported␊
|
||||||
|
␊
|
||||||
|
Escaping both inner square brackets avoids the unwanted report:␊
|
||||||
|
[link \\[is-not-a-valid\\] link](https://example.com)␊
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue