dedent
dedent copied to clipboard
🐛 Bug: Escape handling is not correct
Bug Report Checklist
- [X] I have tried restarting my IDE and the issue persists.
- [X] I have pulled the latest
mainbranch of the repository. - [X] I have searched for related issues and found none that matched my issue.
Expected
This should twice show the same string:
import dedent from "dedent"
console.log(dedent`
This is broken:
\\\$`);
console.log(`This is correct:
\\\$`);
Actual
It shows:
This is broken:
\\$
This is correct:
\$
Additional Info
See also: https://playcode.io/2050574
Fun. This is the case in all dedent string versions I've tried, including the latest (1.5.3), 1.0.0, 0.6.0, and 0.1.0.
Digging into how the the tagged templates work internally:
const tagger = (strings) => strings;
console.log(tagger`From tagger:
\\\$`);
[ 'From tagger:\n\\$' ]
Seems like a bug in escapeSpecialCharacters. cc @G-Rath, what do you think?
isn't this what #69 is about? dedent is escaping the $ automatically even though it doesn't need to
👍 Fair. Since this issue has the cleaner repro, I'll mark that one as a duplicate of this. Thanks!