highlight.js icon indicating copy to clipboard operation
highlight.js copied to clipboard

Invalid RegExp when using `highlightAll()`

Open kasvith opened this issue 1 year ago • 2 comments

Describe the issue/behavior that seems buggy Hi, it seems when using highlightAll() the following error throws out

Invalid regular expression: /(?!-)([!#\$%&*+.\\/<=>?@\\\\^~-]|(?!([(),;\\[\\]\`|{}]|[_:"']))(\\p{S}|\\p{P}))--+|--+(?!-)([!#\$%&*+.\\/<=>?@\\\\^~-]|(?!([(),;\\[\\]\`|{}]|[_:"']))(\\p{S}|\\p{P}))/mu: Invalid escape

Sample Code or Instructions to Reproduce

Expected behavior

No regexp errors

Additional context

Im using NextJS 14.1.0 This error only happens in production build

kasvith avatar Feb 04 '24 11:02 kasvith

Does your regex engine support \p. That is a requirement.

joshgoebel avatar Feb 10 '24 17:02 joshgoebel

Is this reproducible in the latest version of desktop Chrome?

joshgoebel avatar Feb 13 '24 01:02 joshgoebel

Closing along with #4013. (lack of response). Current best guess is a broken build system corrupting the JS code.

joshgoebel avatar Mar 19 '24 03:03 joshgoebel

Hi, sorry i didnt notice your replies, will check and get back

kasvith avatar Mar 19 '24 06:03 kasvith

this was fixed by adding highlight.js to transpilePackages in next config

https://nextjs.org/docs/app/api-reference/next-config-js/transpilePackages

kasvith avatar Jun 25 '24 17:06 kasvith

That's a nice little trick until it better supports these regex constructs.

joshgoebel avatar Jun 25 '24 21:06 joshgoebel