breck7 / breck7/scroll

scroll root parser evalMacros should escape dollar signs in the replacement string

Open
#157 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
484
Forks
21
PR merge metrics
No merged PRs in 30d

Description

As mentioned in this [pldb issue](https://issues.pldb.io/edit.html?folderName=issues.pldb.io&fileName=djot-example-issue.scroll), the [djot page](https://pldb.io/concepts/djot.html) has messed up output.

I think the issue is the pldb example contains

```
$`p = mv`
```
and this line is using that in the regexp replacement string
https://github.com/breck7/scroll/blob/b8555981ad6bd39cb16b1ab766daf129ec0305b8/parsers/root.parsers#L835

According to [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement), the dollar sign followed by backtick has special meaning in the replacment string.

I think prior to using the replacement string (i.e. `macroMap[key]`), any dollar sign should be replaced with a double dollar sign.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.