Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Jul 27, 2023
Merged

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

merged 6 commits into from
Jul 27, 2023

Conversation

G-Rath
Copy link
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
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
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