rehype-pretty / rehype-pretty-code

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

Overlapping multi chars highlighting #169

Open atomiks opened 7 months ago

atomiks commented 7 months ago

Two separate issues:

  1. There's no way to add "sub" highlights. Both getStringLength and get should be separately highlighted.
```js /getStringLength/ /get/
const getStringLength = str => str.length;

2. Chars can inherit a range incorrectly, even when not encompassed by a different chars highlight (such as with the above overlapping scenario).

````md
```js /get/1 /Length/
const getStringLength = str => str.length;
const getStringLength = str => str.length;


The first `get` is correctly highlighted, but `Length` incorrectly inherits the range from `get` because it's within the same textContent of the node (`getStringLength`) and also only ends up highlighting the first `Length`.
juji commented 3 months ago

This is also weird:

Screenshot 2024-05-25 at 20 08 57

Also this one:

Screenshot 2024-05-25 at 20 11 41