Replies: 1 comment
-
|
Thanks for the PR! Do you want to submit a PR with the fix? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
When using
rich_markup_mode="rich"in a Typer application, any help text that contains both a<and a>character causes all text between them to be highlighted as ametavar(typically yellow), even if they are just being used as mathematical operators or standard punctuation.This happens because
typer.rich_utils.OptionHighlighterincludes the following regex in itshighlightslist:r"(?P<metavar>\<[^\>]+\>)"If a user writes a help string like:
Operators include <= and >, the regex captures"= and "as a metavar, bleeding the yellow highlight across the text.Operating System
Linux / macOS / Windows
Operating System Details
Irrelevant, applies to all OS environments.
Typer Version
0.12.0 (or whatever your current version is)
Python Version
3.10+
Steps to Reproduce
Run the following minimal reproducible example. Notice how the text between
<and>is highlighted yellow in the terminal, breaking the intended formatting.Proposed Solution
Currently, the only way to bypass this without altering the help text is to monkey-patch the
OptionHighlighterbefore initializing the app:Potential fixes:
typer.Typer()ortyper.Option()to disable the automaticOptionHighlighteron specific help strings where raw mathematical operators are required.\<and\>) correctly bypasses the Typer-specific regex highlighter.Operating System
macOS
Operating System Details
MacOS M4
Typer Version
0.24.0
Python Version
3.13.12
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions