-
Notifications
You must be signed in to change notification settings - Fork 57
Escape quotes #98
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
Escape quotes #98
Conversation
@lorcan Bumping this for a review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR @Jaden-Giordano! It looks great to me! I have a couple of questions there, mainly if we need to do this for locales and sys.contentType.sys.id
😃 Let me know what you think!
I'm also investigating why the CircleCI build didn't kick off 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks perfect, just one tiny unused import! I'm still actively working on the CircleCI issue. Hope to get it fixed during this week.
Co-authored-by: Gabriel Anca Corral <GabrielAnca@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great! The CircleCI support said the issue should be sorted so if you make an empty push (or a rebase) it should kick off the CI build
Rebased the PR myself and now the build is not passing 😬 It seems it's a small thing. I'm working on a change in our NPM config and I'm happy to approve and merge this PR as soon as that's ready, hopefully before the end of the week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All green, looks perfect 👌🏻 Thanks a lot for the contribution @Jaden-Giordano
🎉 This PR is included in version 3.2.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This aims to fix #34.
Prettier, in some cases, is annoyingly opinionated and doesnt seem to want to preserve escaped quotes and instead just switch to use double quotes or single quotes if the string contains one or the other (this seems like its going to be the case forever (prettier/prettier#973). In order for prettier to correctly decide this we need to escape them inside strings.
In contentful an array of strings that contain apostrophe's will break the output:
Where as if the quote is escaped it properly reformats to:
This PR specifically adds the
escapeSingleQuote
function to autils.ts
in the renderer directory. It then uses this function to escape apostrophes used in contentful data (specifically text) that we drop in.