shuding / nextra

Simple, powerful and flexible site generation framework with everything you love from Next.js.
https://nextra.site
MIT License
11.66k stars 1.26k forks source link

Syntax highlighting hangs when using a substring pattern with ' #2792

Open kpietak opened 6 months ago

kpietak commented 6 months ago

I have come across a problem with highlighting sections of source code using a pattern/substring (as described in the https://nextra.site/docs/guide/syntax-highlighting#highlighting-substrings documentation).

I am presenting code in Rust that implements lifetimes annotations marked with ' , for example: fn longer<'a>(a : &'a [i32], b : &'a [i32]) -> &'a [i32].

I am trying to highlight the annotation itself ('a) using the code:

    ```rust /'a/
    fn longer_array<'a>(a : &'a [i32], b : &'a [i32]) -> &'a [i32] {
        ...
    }```

This syntax causes the page rendering to crash (even terminating the process causes the node to remain on). The question is do we not allow the use of this type of characters in the pattern or is this a bug?

The page rendering is running locally using pnpm dev on macOS. I would appreciate a reply.

dimaMachina commented 6 months ago

seems like an upstream issue from rehype-pretty-code (package who add syntax highlighting for code-blocks) https://github.com/rehype-pretty/rehype-pretty-code

Please submit failling test there!

kpietak commented 6 months ago

Thank you for a quick reply. I've just created a new issue in retype-pretty-code: https://github.com/rehype-pretty/rehype-pretty-code/issues/185