As mentioned in this pldb issue, the djot page has messed up output.
I think the issue is the pldb example contains
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.