Skip to content

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

@btheado

Description

@btheado

As mentioned in this pldb issue, the djot page 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

Object.keys(macroMap).forEach(key => (codeAfterMacroSubstitution = codeAfterMacroSubstitution.replace(new RegExp(key, "g"), macroMap[key])))

According to MDN, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions