highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.3k stars 3.52k forks source link

Invalid RegExp when using `highlightAll()` #3982

Closed kasvith closed 3 months ago

kasvith commented 4 months ago

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

joshgoebel commented 4 months ago

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

joshgoebel commented 4 months ago

Is this reproducible in the latest version of desktop Chrome?

joshgoebel commented 3 months ago

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

kasvith commented 3 months ago

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

kasvith commented 1 week ago

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

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

joshgoebel commented 1 week ago

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