-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
fix: update punctuation regex syntax for compatibility #3540
Conversation
change the string to a regular expression. Then babel can transpile it correctly.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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! 💯
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 good. I can't find any docs on which browsers we support but maybe we should add that.
We don't have any browser tests. I think if we are going to list specific browsers we should have some tests to make sure we are compatible. We support node >= 18 so really we support any browsers that have the same APIs as node 18 |
## [15.0.2](v15.0.1...v15.0.2) (2024-11-20) ### Bug Fixes * update punctuation regex syntax for compatibility ([#3540](#3540)) ([fd015f1](fd015f1))
Incompatible with React Native (Hermes Engine) |
It should work with the latest version facebook/hermes#1295 |
15.0.1 can work with the latest version of Hermes, but 15.0.2 introduced in this PR is not compatible. |
@0xDing Can you create a bug at https://github.com/facebook/hermes/ seems like they will have to fix it. |
Same issue with angular 18 but on Firefox only, 15.0.1 works fine, but 15.0.2 tells: "SyntaxError: invalid identity escape in regular expression" at getRegex marked.esm.js:45 on: |
@twistoliver what version of Firefox? |
Usually the last one, mine is 132.0.2 (64-bit), I’m currently investigating my tsconfig file as it’s maybe linked.
|
transpile to es5
|
anyway, the easiest way to fix is dont use edit to dynamic build regexp with _punctuation , just write it raw and babel will transpile it correct.
another way is keep the code struct, then it should be
or use a precompile script to generate regex info so It also ensures the neatness of regular spelling and allows babel to process these regular expressions. @UziTech Before we choose a solution, this PR should first be revert, and I'd love to PR to the solution you choose |
I don't think we need to release a version with this reverted. Just fixing it in the next version should be fine. There are multiple places const _punctuation = /[\p{P}\p{S}]/u
const _punctuationOrSpace = /[\s\p{P}\p{S}]/u
const _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u It would be great if someone could also figure out a way to write a test for babel so this type of thing doesn't break in the future. |
I will stick on 15.0.1 until next release. Thank you both. |
Marked version: 13.0.1
Markdown flavor: Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a
Description
as pr3229 said, the punctuation regex syntax is not supported in some browser
change the string to a regular expression. Then babel can transpile it correctly.
Expectation
Marked should work fine in most cases.
Result
Host environment reports error due to unsupported regex syntax.
What was attempted
-->
Contributor
Committer
In most cases, this should be a different person than the contributor.