rehype-pretty / rehype-pretty-code

Beautiful code blocks for Markdown or MDX.
https://rehype-pretty.pages.dev
MIT License
1k stars 63 forks source link

Word highlighting breaks in special cases #223

Open ben519 opened 2 months ago

ben519 commented 2 months ago

Check out this example 👇 (It should highlight four characters in total, but it only highlights two of them.)

```shell showLineNumbers title="transformations" /r/1 /b/1 /c/3,6
raccoon -> baccoon # (1)!
baccoon -> babcoon # (2)!
babcoon -> baboon  # (3)!

Here's what this looks like rendered. Notice how the `c`s are not highlighted

<img width="1093" alt="word-highlight-1" src="https://github.com/rehype-pretty/rehype-pretty-code/assets/723099/233eb8fe-c0fb-486b-a3d0-a20b543ff5ca">

... but if I simplify the Markdown to this
raccoon -> baccoon # (1)!
baccoon -> babcoon # (2)!
babcoon -> baboon  # (3)!


the `c`s _are_ highlighted.

<img width="1096" alt="word-highlight-2" src="https://github.com/rehype-pretty/rehype-pretty-code/assets/723099/66e6a56d-5528-4c95-bfdc-7f0858d89b4d">

Is this user error or a bug?