Skip to content

Commit

Permalink
remark: fix escaping of backslash
Browse files Browse the repository at this point in the history
Closes GH-375.
Related-to GH-376.

Co-authored-by: TitanSnow <sweeto@live.cn>
  • Loading branch information
wooorm and ruihe774 committed Nov 10, 2018
1 parent 78b7aca commit 40ec693
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/remark-parse/lib/unescape.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function factory(ctx, key) {
queue.push(backslash)
}

index = value.indexOf(backslash, prev)
index = value.indexOf(backslash, prev + 1)
}

queue.push(value.slice(prev))
Expand Down
2 changes: 1 addition & 1 deletion packages/remark-stringify/lib/visitors/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function code(node, parent) {
info += space + node.meta
}

info = self.encode(info, node)
info = self.encode(self.escape(info, node))

// Without (needed) fences.
if (!info && !options.fences && value) {
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/input/fenced-code-lang-unescape.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```\\\[awd
dwa
```
39 changes: 39 additions & 0 deletions test/fixtures/tree/fenced-code-lang-unescape.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"type": "root",
"children": [
{
"type": "code",
"lang": "\\[awd",
"meta": null,
"value": "dwa",
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 3,
"column": 4,
"offset": 18
},
"indent": [
1,
1
]
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 4,
"column": 1,
"offset": 19
}
}
}

0 comments on commit 40ec693

Please sign in to comment.