-
Notifications
You must be signed in to change notification settings - Fork 39
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
Transform HTML entities to unicode #15
Comments
Will need to investigate what's possible! |
Even if it isn't possible to transform strings via PPX, another possibility would be to include the entities as values like Still a bit clunky, but it seems preferable to having to write the unicode by hand. |
@johnridesabike I just asked Ricky and Maxim if it makes sense to first-class this into the syntax / ppx, and its hard to say if this particular feature would be justifiable from a complexity POV... e.g. if it mixes well with compiler internal escaping / if it makes the syntax logic way more complicated than necessary. So, would it be an option to create some independent I personally created my own entity bindings in user-space, but having more guidance on the topic in the docs would be great. |
That seems like a reasonable compromise. IMO the fact that there is no documentation on the topic, combined with people being used to HTML entities "just working" in Babel JSX, is the main issue. Even a unicode table in the docs that people can copy/paste from would be useful. For the hypothetical |
For anyone interested in copying entities into their own project, I just pushed a commit with an |
Thanks Jon! |
Yes! It was very easy to adapt from the Babel file, so feel free to link, copy, or do whatever with it. |
@ryyppy Actually why put it into an "extra folder" and not make it a direct part of /cc @cristianoc |
I don't see a problem with including it in |
The Babel JSX compiler converts HTML entities into the unicode characters they represent. In ReScript, we have to use the actual unicode directly. For some characters, like
this isn't always convenient.Would it be possible for the React PPX to do the same transformation that Babel does? See their entity map for reference: https://github.com/babel/babel/blob/b3e2bcda73dea7d68b4c82bfabb92acb11b1ed90/packages/babel-parser/src/plugins/jsx/xhtml.js
Babel example
Input
output
ReScript example
Input
Output
Note that
"
will render as-is, not as an actual nonbreaking space character.The text was updated successfully, but these errors were encountered: