mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Update MD011/no-reversed-links to avoid more nested paren scenarios (fixes #572).
This commit is contained in:
parent
56f379b0fc
commit
c333976a44
5 changed files with 69 additions and 25 deletions
|
|
@ -2751,7 +2751,7 @@ module.exports = {
|
||||||
|
|
||||||
const { addError, forEachLine, withinAnyRange } = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js");
|
const { addError, forEachLine, withinAnyRange } = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js");
|
||||||
const { codeBlockAndSpanRanges, lineMetadata } = __webpack_require__(/*! ./cache */ "../lib/cache.js");
|
const { codeBlockAndSpanRanges, lineMetadata } = __webpack_require__(/*! ./cache */ "../lib/cache.js");
|
||||||
const reversedLinkRe = /(^|[^\\])\(([^)]+)\)\[([^\]^][^\]]*)](?!\()/g;
|
const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)](?!\()/g;
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"names": ["MD011", "no-reversed-links"],
|
"names": ["MD011", "no-reversed-links"],
|
||||||
"description": "Reversed link syntax",
|
"description": "Reversed link syntax",
|
||||||
|
|
@ -2768,7 +2768,7 @@ module.exports = {
|
||||||
if (!linkText.endsWith("\\") &&
|
if (!linkText.endsWith("\\") &&
|
||||||
!linkDestination.endsWith("\\") &&
|
!linkDestination.endsWith("\\") &&
|
||||||
!withinAnyRange(exclusions, lineIndex, index, length)) {
|
!withinAnyRange(exclusions, lineIndex, index, length)) {
|
||||||
addError(onError, lineIndex + 1, reversedLink.slice(preChar.length), null, [index + 1, length], {
|
addError(onError, lineIndex + 1, reversedLink.slice(preChar.length), undefined, [index + 1, length], {
|
||||||
"editColumn": index + 1,
|
"editColumn": index + 1,
|
||||||
"deleteCount": length,
|
"deleteCount": length,
|
||||||
"insertText": `[${linkText}](${linkDestination})`
|
"insertText": `[${linkText}](${linkDestination})`
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ const { addError, forEachLine, withinAnyRange } = require("../helpers");
|
||||||
const { codeBlockAndSpanRanges, lineMetadata } = require("./cache");
|
const { codeBlockAndSpanRanges, lineMetadata } = require("./cache");
|
||||||
|
|
||||||
const reversedLinkRe =
|
const reversedLinkRe =
|
||||||
/(^|[^\\])\(([^)]+)\)\[([^\]^][^\]]*)](?!\()/g;
|
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)](?!\()/g;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"names": [ "MD011", "no-reversed-links" ],
|
"names": [ "MD011", "no-reversed-links" ],
|
||||||
|
|
@ -30,7 +30,7 @@ module.exports = {
|
||||||
onError,
|
onError,
|
||||||
lineIndex + 1,
|
lineIndex + 1,
|
||||||
reversedLink.slice(preChar.length),
|
reversedLink.slice(preChar.length),
|
||||||
null,
|
undefined,
|
||||||
[ index + 1, length ],
|
[ index + 1, length ],
|
||||||
{
|
{
|
||||||
"editColumn": index + 1,
|
"editColumn": index + 1,
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,18 @@ text [link](destination)[link](destination)[link](destination) text
|
||||||
|
|
||||||
text (reversed)[link] text (reversed)[link] text {MD011}
|
text (reversed)[link] text (reversed)[link] text {MD011}
|
||||||
|
|
||||||
|
## Nested Parens
|
||||||
|
|
||||||
|
Text (text `func()[index]`) text
|
||||||
|
|
||||||
|
Text (text(reversed)[link] text {MD011}
|
||||||
|
|
||||||
|
## Empty Content
|
||||||
|
|
||||||
|
Text ()[text] text
|
||||||
|
|
||||||
|
Text (text()[text] text
|
||||||
|
|
||||||
<!-- markdownlint-configure-file {
|
<!-- markdownlint-configure-file {
|
||||||
"code-block-style": false,
|
"code-block-style": false,
|
||||||
"line-length": false,
|
"line-length": false,
|
||||||
|
|
|
||||||
|
|
@ -35097,15 +35097,15 @@ Generated by [AVA](https://avajs.dev).
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
errorContext: null,
|
errorContext: null,
|
||||||
errorDetail: '(?:\\["\'\\](?<1>\\[^"\'\\]*)["\']',
|
errorDetail: '(?<1>\\[^"\'\\]*)["\']',
|
||||||
errorRange: [
|
errorRange: [
|
||||||
3,
|
12,
|
||||||
27,
|
18,
|
||||||
],
|
],
|
||||||
fixInfo: {
|
fixInfo: {
|
||||||
deleteCount: 27,
|
deleteCount: 18,
|
||||||
editColumn: 3,
|
editColumn: 12,
|
||||||
insertText: '[?:\\["\'\\](?<1>\\[^"\'\\]*]("\')',
|
insertText: '[?<1>\\[^"\'\\]*]("\')',
|
||||||
},
|
},
|
||||||
lineNumber: 5,
|
lineNumber: 5,
|
||||||
ruleDescription: 'Reversed link syntax',
|
ruleDescription: 'Reversed link syntax',
|
||||||
|
|
@ -35120,7 +35120,7 @@ Generated by [AVA](https://avajs.dev).
|
||||||
␊
|
␊
|
||||||
|Pattern|Description|␊
|
|Pattern|Description|␊
|
||||||
|-------------|-----------------|␊
|
|-------------|-----------------|␊
|
||||||
|\`[?:\\["'\\](?<1>\\[^"'\\]*]("')|(?<1>\\S+))\`|{MD011}|␊
|
|\`(?:\\["'\\][?<1>\\[^"'\\]*]("')|(?<1>\\S+))\`|{MD011}|␊
|
||||||
␊
|
␊
|
||||||
|Pattern|Description|␊
|
|Pattern|Description|␊
|
||||||
|-------------|-----------------|␊
|
|-------------|-----------------|␊
|
||||||
|
|
@ -35296,15 +35296,15 @@ Generated by [AVA](https://avajs.dev).
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
errorContext: null,
|
errorContext: null,
|
||||||
errorDetail: '(([\\/.])[\\w\\-.\\/=]',
|
errorDetail: '([\\/.])[\\w\\-.\\/=]',
|
||||||
errorRange: [
|
errorRange: [
|
||||||
11,
|
12,
|
||||||
18,
|
17,
|
||||||
],
|
],
|
||||||
fixInfo: {
|
fixInfo: {
|
||||||
deleteCount: 18,
|
deleteCount: 17,
|
||||||
editColumn: 11,
|
editColumn: 12,
|
||||||
insertText: '[([\\/.]](\\w\\-.\\/=)',
|
insertText: '[[\\/.]](\\w\\-.\\/=)',
|
||||||
},
|
},
|
||||||
lineNumber: 41,
|
lineNumber: 41,
|
||||||
ruleDescription: 'Reversed link syntax',
|
ruleDescription: 'Reversed link syntax',
|
||||||
|
|
@ -35316,15 +35316,15 @@ Generated by [AVA](https://avajs.dev).
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
errorContext: null,
|
errorContext: null,
|
||||||
errorDetail: '(?:(?:(^|\\/)[!.]',
|
errorDetail: '(^|\\/)[!.]',
|
||||||
errorRange: [
|
errorRange: [
|
||||||
9,
|
15,
|
||||||
16,
|
10,
|
||||||
],
|
],
|
||||||
fixInfo: {
|
fixInfo: {
|
||||||
deleteCount: 16,
|
deleteCount: 10,
|
||||||
editColumn: 9,
|
editColumn: 15,
|
||||||
insertText: '[?:(?:(^|\\/](!.)',
|
insertText: '[^|\\/](!.)',
|
||||||
},
|
},
|
||||||
lineNumber: 45,
|
lineNumber: 45,
|
||||||
ruleDescription: 'Reversed link syntax',
|
ruleDescription: 'Reversed link syntax',
|
||||||
|
|
@ -35394,6 +35394,26 @@ Generated by [AVA](https://avajs.dev).
|
||||||
'no-reversed-links',
|
'no-reversed-links',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
errorContext: null,
|
||||||
|
errorDetail: '(reversed)[link]',
|
||||||
|
errorRange: [
|
||||||
|
11,
|
||||||
|
16,
|
||||||
|
],
|
||||||
|
fixInfo: {
|
||||||
|
deleteCount: 16,
|
||||||
|
editColumn: 11,
|
||||||
|
insertText: '[reversed](link)',
|
||||||
|
},
|
||||||
|
lineNumber: 79,
|
||||||
|
ruleDescription: 'Reversed link syntax',
|
||||||
|
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md011',
|
||||||
|
ruleNames: [
|
||||||
|
'MD011',
|
||||||
|
'no-reversed-links',
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
fixed: `# reversed_link␊
|
fixed: `# reversed_link␊
|
||||||
␊
|
␊
|
||||||
|
|
@ -35435,11 +35455,11 @@ Generated by [AVA](https://avajs.dev).
|
||||||
␊
|
␊
|
||||||
var IDENT_RE = '[[a-zA-Z]|\\\\.[a-zA-Z.]](a-zA-Z0-9._)*'; {MD011}␊
|
var IDENT_RE = '[[a-zA-Z]|\\\\.[a-zA-Z.]](a-zA-Z0-9._)*'; {MD011}␊
|
||||||
␊
|
␊
|
||||||
begin: /\\B[([\\/.]](\\w\\-.\\/=)+)+/, {MD011}␊
|
begin: /\\B([[\\/.]](\\w\\-.\\/=)+)+/, {MD011}␊
|
||||||
␊
|
␊
|
||||||
{begin: '%r\\\\(', end: '\\\\)[a-z]*'}␊
|
{begin: '%r\\\\(', end: '\\\\)[a-z]*'}␊
|
||||||
␊
|
␊
|
||||||
return /[?:(?:(^|\\/](!.))|[*?+()|\\[\\]{}]|[+@]\\()/.test(str); {MD011}␊
|
return /(?:(?:[^|\\/](!.))|[*?+()|\\[\\]{}]|[+@]\\()/.test(str); {MD011}␊
|
||||||
␊
|
␊
|
||||||
## Escaped Parens␊
|
## Escaped Parens␊
|
||||||
␊
|
␊
|
||||||
|
|
@ -35469,6 +35489,18 @@ Generated by [AVA](https://avajs.dev).
|
||||||
␊
|
␊
|
||||||
text [reversed](link) text [reversed](link) text {MD011}␊
|
text [reversed](link) text [reversed](link) text {MD011}␊
|
||||||
␊
|
␊
|
||||||
|
## Nested Parens␊
|
||||||
|
␊
|
||||||
|
Text (text \`func()[index]\`) text␊
|
||||||
|
␊
|
||||||
|
Text (text[reversed](link) text {MD011}␊
|
||||||
|
␊
|
||||||
|
## Empty Content␊
|
||||||
|
␊
|
||||||
|
Text ()[text] text␊
|
||||||
|
␊
|
||||||
|
Text (text()[text] text␊
|
||||||
|
␊
|
||||||
<!-- markdownlint-configure-file {␊
|
<!-- markdownlint-configure-file {␊
|
||||||
"code-block-style": false,␊
|
"code-block-style": false,␊
|
||||||
"line-length": false,␊
|
"line-length": false,␊
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue