diff --git a/packages/remark-parse/lib/tokenize/link.js b/packages/remark-parse/lib/tokenize/link.js index ab4d3fa3c..e9a0f6dde 100644 --- a/packages/remark-parse/lib/tokenize/link.js +++ b/packages/remark-parse/lib/tokenize/link.js @@ -106,20 +106,6 @@ function link(eat, value, silent) { if (depth) { depth-- } else { - // Allow white-space between content and url in GFM mode. - if (!pedantic) { - while (index < length) { - character = value.charAt(index + 1) - - if (!whitespace(character)) { - break - } - - subqueue += character - index++ - } - } - if (value.charAt(index + 1) !== leftParenthesis) { return } diff --git a/test/fixtures/tree/link-spaces.commonmark.json b/test/fixtures/tree/link-spaces.commonmark.json index 87ded5815..895b8bd2c 100644 --- a/test/fixtures/tree/link-spaces.commonmark.json +++ b/test/fixtures/tree/link-spaces.commonmark.json @@ -137,9 +137,10 @@ "type": "paragraph", "children": [ { - "type": "link", - "title": null, - "url": "http://foxtrot.golf", + "type": "linkReference", + "identifier": "echo", + "label": "echo", + "referenceType": "shortcut", "children": [ { "type": "text", @@ -165,6 +166,77 @@ "column": 1, "offset": 41 }, + "end": { + "line": 6, + "column": 7, + "offset": 47 + }, + "indent": [] + } + }, + { + "type": "text", + "value": "\t(", + "position": { + "start": { + "line": 6, + "column": 7, + "offset": 47 + }, + "end": { + "line": 6, + "column": 9, + "offset": 49 + }, + "indent": [] + } + }, + { + "type": "link", + "title": null, + "url": "http://foxtrot.golf", + "children": [ + { + "type": "text", + "value": "http://foxtrot.golf", + "position": { + "start": { + "line": 6, + "column": 9, + "offset": 49 + }, + "end": { + "line": 6, + "column": 28, + "offset": 68 + }, + "indent": [] + } + } + ], + "position": { + "start": { + "line": 6, + "column": 9, + "offset": 49 + }, + "end": { + "line": 6, + "column": 28, + "offset": 68 + }, + "indent": [] + } + }, + { + "type": "text", + "value": ")", + "position": { + "start": { + "line": 6, + "column": 28, + "offset": 68 + }, "end": { "line": 6, "column": 29, @@ -192,9 +264,10 @@ "type": "paragraph", "children": [ { - "type": "image", - "title": null, - "url": "india.com/juliett", + "type": "imageReference", + "identifier": "hotel", + "label": "hotel", + "referenceType": "shortcut", "alt": "hotel", "position": { "start": { @@ -202,6 +275,23 @@ "column": 1, "offset": 71 }, + "end": { + "line": 8, + "column": 9, + "offset": 79 + }, + "indent": [] + } + }, + { + "type": "text", + "value": " (india.com/juliett)", + "position": { + "start": { + "line": 8, + "column": 9, + "offset": 79 + }, "end": { "line": 8, "column": 31, diff --git a/test/fixtures/tree/link-spaces.json b/test/fixtures/tree/link-spaces.json index 87ded5815..895b8bd2c 100644 --- a/test/fixtures/tree/link-spaces.json +++ b/test/fixtures/tree/link-spaces.json @@ -137,9 +137,10 @@ "type": "paragraph", "children": [ { - "type": "link", - "title": null, - "url": "http://foxtrot.golf", + "type": "linkReference", + "identifier": "echo", + "label": "echo", + "referenceType": "shortcut", "children": [ { "type": "text", @@ -165,6 +166,77 @@ "column": 1, "offset": 41 }, + "end": { + "line": 6, + "column": 7, + "offset": 47 + }, + "indent": [] + } + }, + { + "type": "text", + "value": "\t(", + "position": { + "start": { + "line": 6, + "column": 7, + "offset": 47 + }, + "end": { + "line": 6, + "column": 9, + "offset": 49 + }, + "indent": [] + } + }, + { + "type": "link", + "title": null, + "url": "http://foxtrot.golf", + "children": [ + { + "type": "text", + "value": "http://foxtrot.golf", + "position": { + "start": { + "line": 6, + "column": 9, + "offset": 49 + }, + "end": { + "line": 6, + "column": 28, + "offset": 68 + }, + "indent": [] + } + } + ], + "position": { + "start": { + "line": 6, + "column": 9, + "offset": 49 + }, + "end": { + "line": 6, + "column": 28, + "offset": 68 + }, + "indent": [] + } + }, + { + "type": "text", + "value": ")", + "position": { + "start": { + "line": 6, + "column": 28, + "offset": 68 + }, "end": { "line": 6, "column": 29, @@ -192,9 +264,10 @@ "type": "paragraph", "children": [ { - "type": "image", - "title": null, - "url": "india.com/juliett", + "type": "imageReference", + "identifier": "hotel", + "label": "hotel", + "referenceType": "shortcut", "alt": "hotel", "position": { "start": { @@ -202,6 +275,23 @@ "column": 1, "offset": 71 }, + "end": { + "line": 8, + "column": 9, + "offset": 79 + }, + "indent": [] + } + }, + { + "type": "text", + "value": " (india.com/juliett)", + "position": { + "start": { + "line": 8, + "column": 9, + "offset": 79 + }, "end": { "line": 8, "column": 31, diff --git a/test/fixtures/tree/link-spaces.nogfm.commonmark.json b/test/fixtures/tree/link-spaces.nogfm.commonmark.json index 87ded5815..ceb68281a 100644 --- a/test/fixtures/tree/link-spaces.nogfm.commonmark.json +++ b/test/fixtures/tree/link-spaces.nogfm.commonmark.json @@ -137,9 +137,10 @@ "type": "paragraph", "children": [ { - "type": "link", - "title": null, - "url": "http://foxtrot.golf", + "type": "linkReference", + "identifier": "echo", + "label": "echo", + "referenceType": "shortcut", "children": [ { "type": "text", @@ -165,6 +166,23 @@ "column": 1, "offset": 41 }, + "end": { + "line": 6, + "column": 7, + "offset": 47 + }, + "indent": [] + } + }, + { + "type": "text", + "value": "\t(http://foxtrot.golf)", + "position": { + "start": { + "line": 6, + "column": 7, + "offset": 47 + }, "end": { "line": 6, "column": 29, @@ -192,9 +210,10 @@ "type": "paragraph", "children": [ { - "type": "image", - "title": null, - "url": "india.com/juliett", + "type": "imageReference", + "identifier": "hotel", + "label": "hotel", + "referenceType": "shortcut", "alt": "hotel", "position": { "start": { @@ -202,6 +221,23 @@ "column": 1, "offset": 71 }, + "end": { + "line": 8, + "column": 9, + "offset": 79 + }, + "indent": [] + } + }, + { + "type": "text", + "value": " (india.com/juliett)", + "position": { + "start": { + "line": 8, + "column": 9, + "offset": 79 + }, "end": { "line": 8, "column": 31, diff --git a/test/fixtures/tree/link-spaces.nogfm.json b/test/fixtures/tree/link-spaces.nogfm.json index 87ded5815..ceb68281a 100644 --- a/test/fixtures/tree/link-spaces.nogfm.json +++ b/test/fixtures/tree/link-spaces.nogfm.json @@ -137,9 +137,10 @@ "type": "paragraph", "children": [ { - "type": "link", - "title": null, - "url": "http://foxtrot.golf", + "type": "linkReference", + "identifier": "echo", + "label": "echo", + "referenceType": "shortcut", "children": [ { "type": "text", @@ -165,6 +166,23 @@ "column": 1, "offset": 41 }, + "end": { + "line": 6, + "column": 7, + "offset": 47 + }, + "indent": [] + } + }, + { + "type": "text", + "value": "\t(http://foxtrot.golf)", + "position": { + "start": { + "line": 6, + "column": 7, + "offset": 47 + }, "end": { "line": 6, "column": 29, @@ -192,9 +210,10 @@ "type": "paragraph", "children": [ { - "type": "image", - "title": null, - "url": "india.com/juliett", + "type": "imageReference", + "identifier": "hotel", + "label": "hotel", + "referenceType": "shortcut", "alt": "hotel", "position": { "start": { @@ -202,6 +221,23 @@ "column": 1, "offset": 71 }, + "end": { + "line": 8, + "column": 9, + "offset": 79 + }, + "indent": [] + } + }, + { + "type": "text", + "value": " (india.com/juliett)", + "position": { + "start": { + "line": 8, + "column": 9, + "offset": 79 + }, "end": { "line": 8, "column": 31,