-
-
Notifications
You must be signed in to change notification settings - Fork 702
fix: do not escape newlines #3320
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
Conversation
commit: |
What issue does this PR aim to fix? Could you provide a reproduction sample? |
@farnabaz I added more details and a reproduction link. |
I just encountered this issue myself. The PR fixes the bug for me. Thanks a lot! |
I see What we can do is to change |
Which don't? I tried out the ones available. |
@dword-design You were right, double checked with databases, and all seems fine. |
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
Nice. Possible to have a release? π |
β Type of change
π Description
Currently newlines are escaped when putting strings as fields into @nuxt/content. That means that the newlines that are returned from e.g.
queryCollection
aren't real newlines but slashes followed by an n char. This is clearly visible when converting the field value to JSON, then the output looks something likeline1\\nline2
instead ofline1\nline2
. Concretely this breaks my nuxt-content-body-html module that generates a html for @nuxt/content posts. In the final result e.g. in code blocks, there will just be\n
strings instead of real line breaks.I think there are two issues:
I've fixed them by keeping the newlines in the queries and using JSON.stringify and JSON.parse to communicate the dump between server and client instead of spliting by
\n
.I haven't fixed the tests yet since I don't know yet if the PR gets merged.
Reproduction
https://codesandbox.io/p/devbox/j4yj8k