mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Fix helpers.referenceLinkRe to handle full and shortcut reference image links inside normal links (fixes #571).
This commit is contained in:
parent
62060aaf21
commit
6974cd6012
5 changed files with 51 additions and 23 deletions
|
@ -56,7 +56,7 @@ const emphasisMarkersRe = /[_*]/g;
|
|||
const blockquotePrefixRe = /^[>\s]*/;
|
||||
module.exports.blockquotePrefixRe = blockquotePrefixRe;
|
||||
// Regular expression for reference links (full, collapsed, and shortcut)
|
||||
const referenceLinkRe = /!?\\?\[((?:\[[^\]\0]*]|[^\]\0])*)](?:(?:\[([^\]\0]*)\])|([^(])|$)/g;
|
||||
const referenceLinkRe = /!?\\?\[((?:\[[^\]\0]*]|[^[\]\0])*)](?:(?:\[([^\]\0]*)\])|([^(])|$)/g;
|
||||
// Regular expression for link reference definitions
|
||||
const linkReferenceDefinitionRe = /^ {0,3}\[([^\]]*[^\\])]:/;
|
||||
module.exports.linkReferenceDefinitionRe = linkReferenceDefinitionRe;
|
||||
|
|
|
@ -36,7 +36,7 @@ module.exports.blockquotePrefixRe = blockquotePrefixRe;
|
|||
|
||||
// Regular expression for reference links (full, collapsed, and shortcut)
|
||||
const referenceLinkRe =
|
||||
/!?\\?\[((?:\[[^\]\0]*]|[^\]\0])*)](?:(?:\[([^\]\0]*)\])|([^(])|$)/g;
|
||||
/!?\\?\[((?:\[[^\]\0]*]|[^[\]\0])*)](?:(?:\[([^\]\0]*)\])|([^(])|$)/g;
|
||||
|
||||
// Regular expression for link reference definitions
|
||||
const linkReferenceDefinitionRe = /^ {0,3}\[([^\]]*[^\\])]:/;
|
||||
|
|
|
@ -102,17 +102,19 @@ Escaped right label: [text][wrong\]
|
|||
|
||||
## Valid Images
|
||||
|
||||
Full style: ![text][image]
|
||||
Full style: ![text][image0]
|
||||
|
||||
Collapsed style: ![image][]
|
||||
Collapsed style: ![image1][]
|
||||
|
||||
Shortcut style: ![image]
|
||||
Shortcut style: ![image2]
|
||||
|
||||
Image in link: [![text][image]][label] [![image][]][label] [![image]][label]
|
||||
Image in link: [![text][image3]](link) [![image4][]](link) [![image5]](link)
|
||||
|
||||
Wrapped in brackets: [![text][unique6]]
|
||||
Image in shortcut link: [![text][image6]][unique6] [![image7][]][unique7] [![image8]][unique8]
|
||||
|
||||
Embedded [in ![text][unique7] brackets]
|
||||
Wrapped in brackets: [![text][unique9]]
|
||||
|
||||
Embedded [in ![text][unique10] brackets]
|
||||
|
||||
## Invalid Images
|
||||
|
||||
|
@ -143,6 +145,15 @@ Missing[^2]
|
|||
[label]: https://example.com/label
|
||||
[ label with spaces ]: https://example.com/label-with-spaces
|
||||
[image]:https://example.com/image
|
||||
[image0]: https://example.com/image0
|
||||
[image1]: https://example.com/image1
|
||||
[image2]: https://example.com/image2
|
||||
[image3]: https://example.com/image3
|
||||
[image4]: https://example.com/image4
|
||||
[image5]: https://example.com/image5
|
||||
[image6]: https://example.com/image6
|
||||
[image7]: https://example.com/image7
|
||||
[image8]: https://example.com/image8
|
||||
[`code`]: https://example.com/code
|
||||
[^1]: https://example.com/footnote
|
||||
[multi line full text]: https://example.com/multi-line-full-text
|
||||
|
@ -165,6 +176,9 @@ https://example.com/multi-line-label
|
|||
[unique5]: https://example.com/unique5
|
||||
[unique6]: https://example.com/unique6
|
||||
[unique7]: https://example.com/unique7
|
||||
[unique8]: https://example.com/unique8
|
||||
[unique9]: https://example.com/unique9
|
||||
[unique10]: https://example.com/unique10
|
||||
|
||||
## Ignored Labels
|
||||
|
||||
|
|
|
@ -33736,7 +33736,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
16,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 119,
|
||||
lineNumber: 121,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
|
@ -33752,7 +33752,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
16,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 121,
|
||||
lineNumber: 123,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
|
@ -33768,7 +33768,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
25,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 202,
|
||||
lineNumber: 216,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
|
@ -33784,7 +33784,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
10,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 216,
|
||||
lineNumber: 230,
|
||||
ruleDescription: 'Reference links and images should use a label that is defined',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md052',
|
||||
ruleNames: [
|
||||
|
@ -33802,7 +33802,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
fixInfo: {
|
||||
deleteCount: -1,
|
||||
},
|
||||
lineNumber: 178,
|
||||
lineNumber: 192,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md053',
|
||||
ruleNames: [
|
||||
|
@ -33820,7 +33820,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
fixInfo: {
|
||||
deleteCount: -1,
|
||||
},
|
||||
lineNumber: 181,
|
||||
lineNumber: 195,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md053',
|
||||
ruleNames: [
|
||||
|
@ -33838,7 +33838,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
fixInfo: {
|
||||
deleteCount: -1,
|
||||
},
|
||||
lineNumber: 184,
|
||||
lineNumber: 198,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md053',
|
||||
ruleNames: [
|
||||
|
@ -33854,7 +33854,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
44,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 186,
|
||||
lineNumber: 200,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md053',
|
||||
ruleNames: [
|
||||
|
@ -33870,7 +33870,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
44,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 189,
|
||||
lineNumber: 203,
|
||||
ruleDescription: 'Link and image reference definitions should be needed',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md053',
|
||||
ruleNames: [
|
||||
|
@ -33983,17 +33983,19 @@ Generated by [AVA](https://avajs.dev).
|
|||
␊
|
||||
## Valid Images␊
|
||||
␊
|
||||
Full style: ![text][image]␊
|
||||
Full style: ![text][image0]␊
|
||||
␊
|
||||
Collapsed style: ![image][]␊
|
||||
Collapsed style: ![image1][]␊
|
||||
␊
|
||||
Shortcut style: ![image]␊
|
||||
Shortcut style: ![image2]␊
|
||||
␊
|
||||
Image in link: [![text][image]][label] [![image][]][label] [![image]][label]␊
|
||||
Image in link: [![text][image3]](link) [![image4][]](link) [![image5]](link)␊
|
||||
␊
|
||||
Wrapped in brackets: [![text][unique6]]␊
|
||||
Image in shortcut link: [![text][image6]][unique6] [![image7][]][unique7] [![image8]][unique8]␊
|
||||
␊
|
||||
Embedded [in ![text][unique7] brackets]␊
|
||||
Wrapped in brackets: [![text][unique9]]␊
|
||||
␊
|
||||
Embedded [in ![text][unique10] brackets]␊
|
||||
␊
|
||||
## Invalid Images␊
|
||||
␊
|
||||
|
@ -34024,6 +34026,15 @@ Generated by [AVA](https://avajs.dev).
|
|||
[label]: https://example.com/label␊
|
||||
[ label with spaces ]: https://example.com/label-with-spaces␊
|
||||
[image]:https://example.com/image␊
|
||||
[image0]: https://example.com/image0␊
|
||||
[image1]: https://example.com/image1␊
|
||||
[image2]: https://example.com/image2␊
|
||||
[image3]: https://example.com/image3␊
|
||||
[image4]: https://example.com/image4␊
|
||||
[image5]: https://example.com/image5␊
|
||||
[image6]: https://example.com/image6␊
|
||||
[image7]: https://example.com/image7␊
|
||||
[image8]: https://example.com/image8␊
|
||||
[\`code\`]: https://example.com/code␊
|
||||
[^1]: https://example.com/footnote␊
|
||||
[multi line full text]: https://example.com/multi-line-full-text␊
|
||||
|
@ -34046,6 +34057,9 @@ Generated by [AVA](https://avajs.dev).
|
|||
[unique5]: https://example.com/unique5␊
|
||||
[unique6]: https://example.com/unique6␊
|
||||
[unique7]: https://example.com/unique7␊
|
||||
[unique8]: https://example.com/unique8␊
|
||||
[unique9]: https://example.com/unique9␊
|
||||
[unique10]: https://example.com/unique10␊
|
||||
␊
|
||||
## Ignored Labels␊
|
||||
␊
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue