Skip to content

[BUG] "0x1080" is highlighted in "1920x1080". Need a word boundary for "0x" pattern #3854

@coppit

Description

@coppit

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions