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

word highlighting highlights half words #163

Open o-az opened 7 months ago

o-az commented 7 months ago

Using the following snippet where I'm highlighting onRecvPacket and noticed onRecvPacketProcessing is getting highlighted too:

```solidity /onRecvPacket/#g


![CleanShot 2024-01-17 at 22 32 56@2x](https://github.com/atomiks/rehype-pretty-code/assets/23618431/cb492bb1-0cc4-41c9-b11b-a25d05f7609c)

Here's a stackblitz playground to see it in action: https://stackblitz.com/edit/github-j3wpz9?file=src%2Fpages%2Findex.mdx

We should discuss if this behavior is desirable or considered a bug.

cc @atomiks 
atomiks commented 7 months ago

Workaround is to use a range to scope it:

```solidity /onRecvPacket/1#g

I'm not sure we should auto-implement breaking on boundaries (e.g. punctuation, spaces) or not. We could maybe add a flag to do that? Kind of like regex flags which fits with the syntax...

`b` for `break`:

````md
```solidity /onRecvPacket/b#g
o-az commented 7 months ago

I think regex is the way to go! Will do that