Skip to content

Commit

Permalink
fix: fix escape characters in links (#2628)
Browse files Browse the repository at this point in the history
* fix: fix escape characters in links

* chore: remove escapes in def

* chore: fix lang replace on undefined
  • Loading branch information
UziTech committed Nov 5, 2022
1 parent 3d389d5 commit 44a2a23
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/Tokenizer.js
Expand Up @@ -103,7 +103,7 @@ export class Tokenizer {
return {
type: 'code',
raw,
lang: cap[2] ? cap[2].trim() : cap[2],
lang: cap[2] ? cap[2].trim().replace(this.rules.inline._escapes, '$1') : cap[2],
text
};
}
Expand Down Expand Up @@ -371,8 +371,8 @@ export class Tokenizer {
type: 'def',
tag,
raw: cap[0],
href: cap[2],
title: cap[3]
href: cap[2] ? cap[2].replace(this.rules.inline._escapes, '$1') : cap[2],
title: cap[3] ? cap[3].replace(this.rules.inline._escapes, '$1') : cap[3]
};
}
}
Expand Down
9 changes: 3 additions & 6 deletions test/specs/commonmark/commonmark.0.30.json
Expand Up @@ -181,17 +181,15 @@
"example": 23,
"start_line": 605,
"end_line": 611,
"section": "Backslash escapes",
"shouldFail": true
"section": "Backslash escapes"
},
{
"markdown": "``` foo\\+bar\nfoo\n```\n",
"html": "<pre><code class=\"language-foo+bar\">foo\n</code></pre>\n",
"example": 24,
"start_line": 614,
"end_line": 621,
"section": "Backslash escapes",
"shouldFail": true
"section": "Backslash escapes"
},
{
"markdown": "&nbsp; &amp; &copy; &AElig; &Dcaron;\n&frac34; &HilbertSpace; &DifferentialD;\n&ClockwiseContourIntegral; &ngE;\n",
Expand Down Expand Up @@ -1624,8 +1622,7 @@
"example": 202,
"start_line": 3307,
"end_line": 3313,
"section": "Link reference definitions",
"shouldFail": true
"section": "Link reference definitions"
},
{
"markdown": "[foo]\n\n[foo]: url\n",
Expand Down
9 changes: 3 additions & 6 deletions test/specs/gfm/commonmark.0.30.json
Expand Up @@ -181,17 +181,15 @@
"example": 23,
"start_line": 605,
"end_line": 611,
"section": "Backslash escapes",
"shouldFail": true
"section": "Backslash escapes"
},
{
"markdown": "``` foo\\+bar\nfoo\n```\n",
"html": "<pre><code class=\"language-foo+bar\">foo\n</code></pre>\n",
"example": 24,
"start_line": 614,
"end_line": 621,
"section": "Backslash escapes",
"shouldFail": true
"section": "Backslash escapes"
},
{
"markdown": "&nbsp; &amp; &copy; &AElig; &Dcaron;\n&frac34; &HilbertSpace; &DifferentialD;\n&ClockwiseContourIntegral; &ngE;\n",
Expand Down Expand Up @@ -1624,8 +1622,7 @@
"example": 202,
"start_line": 3307,
"end_line": 3313,
"section": "Link reference definitions",
"shouldFail": true
"section": "Link reference definitions"
},
{
"markdown": "[foo]\n\n[foo]: url\n",
Expand Down

1 comment on commit 44a2a23

@vercel
Copy link

@vercel vercel bot commented on 44a2a23 Nov 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.