rich
rich copied to clipboard
[BUG] "0x1080" is highlighted in "1920x1080". Need a word boundary for "0x" pattern
- [X] I've checked docs and closed issues for possible solutions.
- [X] I can't find my issue in the FAQ.
Perhaps there's a reason there isn't a \b in the regex already. My impression is that all valid hexadecimal numbers would have a space before the "0x".
Here's my monkey patch to work around it:
Monkey patch the highlighter pattern to not highlight "0x1080" in 1920x1080 as a hex number
from rich.highlighter import ReprHighlighter for i, regex in enumerate(ReprHighlighter.highlights): if '0x' in regex: parts = regex.split('0x') ReprHighlighter.highlights[i] = r'\b0x'.join(parts)
Thank you for your issue. Give us a little time to review it.
PS. You might want to check the FAQ if you haven't done so already.
Rich was created by Will McGugan. Consider sponsoring Will's work on Rich.
This is an automated reply, generated by FAQtory