fix: consume first level of escaping of $ and { characters#46
fix: consume first level of escaping of $ and { characters#46JoshuaKGoldberg merged 6 commits intodmnd:mainfrom G-Rath:escape-more
$ and { characters#46Conversation
These characters are special in template string literals, so it should be assumed if they're escaped it's to avoid them being interpolated. If it desired to have the escaping slash for these characters, then an escaped slash can be used.
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
OK! Thanks again for reporting and now sending this @G-Rath - the code changes look great and I appreciate your persistence in getting them in.
I'll post some more context about why I took so long to ponder this in #26. To summarize, I worry about going against the default behavior of template literals. But I think you're right that the expected behavior by users would generally be to just dedent text, not add \s the way template literals do.
I can fix up merge conflicts and release this as a new minor. 🚀
|
I just sent #65 - and am thinking I'll wait to release this in a new minor version till that option is in. That way people can opt out of the new behavior if they want. An aside on versioning: theoretically this is a breaking change to behavior... but in practice basically every behavior change is technically breaking. The fact that this doesn't change the public API means I'm comfortable releasing in a minor version. But having the options in #65 available is a nicety for users. |
These characters are special in template string literals, so it should be assumed if they're escaped it's to avoid them being interpolated.
If it desired to have the escaping slash for these characters, then an escaped slash can be used.
Without this it's not possible to dedent strings that reassemble template string literal interpolations without a follow-up transformation (i.e. calling
.replaceor similar).Resolves #45