-
Notifications
You must be signed in to change notification settings - Fork 647
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 ES2018 Unicode character class escapes #1027
Comments
Is this new-contributor friendly? I'd be happy to implement it. Need it in my app |
@mandrade2 It's difficult to gauge exactly how new-contributor friendly it is. It requires good C++, understanding of Unicode, regular expressions in general, and the Hermes regex implementation. It is not strongly coupled to the rest of the runtime, but likely requires calling internal APIs in ways that they are already used in the internal implementation. I would say that this is a moderately complex task that would require non-trivial time commitment. |
Thanks @tmikov! I'll start looking around the Hermes repo to find out if I can do it. Will post any doubts here if that works out |
@tmikov unfortunately I don't think I'll be available complete this. Hope I get more time to contribute in the future! |
Contributes to #139 This PR uses the [`remarkable`][remarkable] library to transform Markdown into HTML instead of `marked`. While `marked` is a competent library, it uses regular expressions to parse Markdown which include a [syntax currently unsupported by the Hermes JS engine](facebook/hermes#1027). In contrast, `remarkable` does use any regular expressions to parse so it seems to work just fine in React Native. After switching to `remarkable`, using `<FhirValue>` in an Expo application to display Markdown content in HTML resulted in a new error. This turned to be a straightforward issue that the `dompurify` library cannot sanitize an HTML string with access to the DOM. Thus, this PR narrows HTML sanitizing to only be done when `dompurify` can do so. ## How can I test this change? Create a new Expo app using the bonfhir template for it. Add a `<FhirValue>` with some example Markdown content styled as HTML and validate that the HTML shows up literally on the Android screen. ```tsx const exampleMarkdown = "# Footer\n\nThis is a footer"; function ExampleScreen() { return <FhirValue options={{ style: "html" }} type="markdown" value={exampleMarkdown} /> } ``` The above should show something like: ```html <h1>Footer</h1> <p>This is a footer</p> ``` ## Caveat This helps make `@bonfhir/core` and `@bonfhir/react` more compatible with React Native configured with Hermes by addressing specific issues. Full Hermes compatibility is not confirmed yet however as testing the complete surface of Bonfhir libraries and APIs is out of scope of this fix. We welcome the community finding more compatibility issues however that we can prioritize and address as needed! [remarkable]: https://github.com/jonschlinkert/remarkable
Summary: Original Author: [email protected] Original Git: dcf8e7b Original Reviewed By: avp Original Revision: D56493540 Extends RegExp to handle `\p` and `\P` Unicode property escapes, standalone and within character classes, for Unicode mode. The implementation extends the existing idea of tables of codepoint ranges to cover all of the properties explicitly required by ES262. The `genUnicodeTable.py` script was updated to generate code related to the binary and non-binary Unicode properties explicitly mentioned in ES262 ([ref](https://tc39.es/ecma262/multipage/text-processing.html#sec-runtime-semantics-unicodematchproperty-p)); based on the Unicode 15.1.0 data files. Closes #1027 Pull Request resolved: #1295 Pulled By: neildhar Reviewed By: neildhar Differential Revision: D60361619 fbshipit-source-id: 70d7293114576d4b05f1dbc2d9b22e553bec089f
Bug Description
new RegExp(/\p{P}/, 'u')
in JS code crashes React Native when using Hermes, throwingSyntaxError: Invalid RegExp: Invalid escape
; and it works fine with JSC.\p{P}
is the Unicode character class escape for punctuation.gradle clean
and confirmed this bug does not occur with JSCHermes version: the one bundled with RN 0.71.10
React Native version (if any): 0.71.10
OS version (if any):
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64):
The text was updated successfully, but these errors were encountered: