Skip to content

Commit 44a2a23

Browse files
authored
fix: fix escape characters in links (#2628)
* fix: fix escape characters in links * chore: remove escapes in def * chore: fix lang replace on undefined
1 parent 3d389d5 commit 44a2a23

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/Tokenizer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class Tokenizer {
103103
return {
104104
type: 'code',
105105
raw,
106-
lang: cap[2] ? cap[2].trim() : cap[2],
106+
lang: cap[2] ? cap[2].trim().replace(this.rules.inline._escapes, '$1') : cap[2],
107107
text
108108
};
109109
}
@@ -371,8 +371,8 @@ export class Tokenizer {
371371
type: 'def',
372372
tag,
373373
raw: cap[0],
374-
href: cap[2],
375-
title: cap[3]
374+
href: cap[2] ? cap[2].replace(this.rules.inline._escapes, '$1') : cap[2],
375+
title: cap[3] ? cap[3].replace(this.rules.inline._escapes, '$1') : cap[3]
376376
};
377377
}
378378
}

test/specs/commonmark/commonmark.0.30.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,15 @@
181181
"example": 23,
182182
"start_line": 605,
183183
"end_line": 611,
184-
"section": "Backslash escapes",
185-
"shouldFail": true
184+
"section": "Backslash escapes"
186185
},
187186
{
188187
"markdown": "``` foo\\+bar\nfoo\n```\n",
189188
"html": "<pre><code class=\"language-foo+bar\">foo\n</code></pre>\n",
190189
"example": 24,
191190
"start_line": 614,
192191
"end_line": 621,
193-
"section": "Backslash escapes",
194-
"shouldFail": true
192+
"section": "Backslash escapes"
195193
},
196194
{
197195
"markdown": "&nbsp; &amp; &copy; &AElig; &Dcaron;\n&frac34; &HilbertSpace; &DifferentialD;\n&ClockwiseContourIntegral; &ngE;\n",
@@ -1624,8 +1622,7 @@
16241622
"example": 202,
16251623
"start_line": 3307,
16261624
"end_line": 3313,
1627-
"section": "Link reference definitions",
1628-
"shouldFail": true
1625+
"section": "Link reference definitions"
16291626
},
16301627
{
16311628
"markdown": "[foo]\n\n[foo]: url\n",

test/specs/gfm/commonmark.0.30.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,15 @@
181181
"example": 23,
182182
"start_line": 605,
183183
"end_line": 611,
184-
"section": "Backslash escapes",
185-
"shouldFail": true
184+
"section": "Backslash escapes"
186185
},
187186
{
188187
"markdown": "``` foo\\+bar\nfoo\n```\n",
189188
"html": "<pre><code class=\"language-foo+bar\">foo\n</code></pre>\n",
190189
"example": 24,
191190
"start_line": 614,
192191
"end_line": 621,
193-
"section": "Backslash escapes",
194-
"shouldFail": true
192+
"section": "Backslash escapes"
195193
},
196194
{
197195
"markdown": "&nbsp; &amp; &copy; &AElig; &Dcaron;\n&frac34; &HilbertSpace; &DifferentialD;\n&ClockwiseContourIntegral; &ngE;\n",
@@ -1624,8 +1622,7 @@
16241622
"example": 202,
16251623
"start_line": 3307,
16261624
"end_line": 3313,
1627-
"section": "Link reference definitions",
1628-
"shouldFail": true
1625+
"section": "Link reference definitions"
16291626
},
16301627
{
16311628
"markdown": "[foo]\n\n[foo]: url\n",

0 commit comments

Comments
 (0)