Skip to content

fix: consume first level of escaping of $ and { characters#46

Merged
JoshuaKGoldberg merged 6 commits intodmnd:mainfrom
G-Rath:escape-more
Jul 27, 2023
Merged

fix: consume first level of escaping of $ and { characters#46
JoshuaKGoldberg merged 6 commits intodmnd:mainfrom
G-Rath:escape-more

Conversation

@G-Rath
Copy link
Copy Markdown
Contributor

@G-Rath G-Rath commented Jul 15, 2023

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 .replace or similar).

Resolves #45

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.
Copy link
Copy Markdown
Collaborator

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. 🚀

@JoshuaKGoldberg
Copy link
Copy Markdown
Collaborator

JoshuaKGoldberg commented Jul 27, 2023

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.

@JoshuaKGoldberg JoshuaKGoldberg mentioned this pull request Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

escaped $ and { characters are not handled correctly

2 participants