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

Support for trailing whitespaces & newlines #34

Merged
merged 6 commits into from
May 28, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clean up quote section
  • Loading branch information
complected committed May 27, 2022
commit ce69dd9645315d25e40b2f5905a9984d53f25083
4 changes: 2 additions & 2 deletions jams.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const _jams =ast=> {
}
case 'bare':
case 'quote': {
// This assumes the string is a well-formed JSON string e.g. newlines should be escaped as '\\n' (JS string representation).
const json = JSON.parse(String.raw`"${ast.text}"`)
const quoted = String.raw`"${ast.text}"`
const json = JSON.parse(quoted)
Copy link
Owner

Choose a reason for hiding this comment

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

Did we verify json strings escape unicode and not utf16?

Copy link
Contributor Author

@complected complected May 27, 2022

Choose a reason for hiding this comment

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

Did we verify json strings escape unicode...?

Yep.

Longer answer is, I verified that a file of \n needs to transform to String.raw"\n"` (note the quotes) for JSON.parse to parse, otherwise it's a parsing exception. Did I answer your question?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and not utf16?

I think I am not understanding the question. Could you please break it down a bit?
JSON strings ----can transform to---> JS Objects ---> UTF-8 encoded files.

Could you please let me know if this and the comment in the diff test.js helps?

Copy link
Owner

Choose a reason for hiding this comment

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

I’m talking about escape sequences, how you specify them like \uff vs U+FF etc, json spec encodes utf16 I’m 99% sure and I want it to be unicode instead
Will merge this but investigate some more later

return String.raw`${json}`
}
case 'arr': {
Expand Down