Disable highlighting globally in console.print() #3433
Unanswered
scottb5612
asked this question in
Q&A
Replies: 5 comments 3 replies
-
Second paragraph. https://rich.readthedocs.io/en/latest/highlighting.html#highlighting |
Beta Was this translation helpful? Give feedback.
0 replies
-
Is there a way to achieve the effect with the print method alone?
E.g. the following highlights the email address
print("[b red]Hi![/] [italic yellow] python", "tree.py ***@***.***>")
…On Thu, Jul 18, 2024 at 4:24 PM Will McGugan ***@***.***> wrote:
Second paragraph.
https://rich.readthedocs.io/en/latest/highlighting.html#highlighting
—
Reply to this email directly, view it on GitHub
<#3433 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACP6BHK5NBC7UJEP2JCP2FLZM7FZPAVCNFSM6AAAAABLCZHGY6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAMBYGU2DGMA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Surely.
In this program, I see the following output.
What I want is to disable highlight for the call to print() at line 2 as
well
(and for any other calls to print())
console = Console(highlight=False)
print("[b red]Hi![/] [italic yellow] python", "tree.py ***@***.***>")
console.print("[b red]Hi![/] [italic yellow] python", "tree.py ***@***.***
")
[image: Screenshot 2024-07-18 at 8.53.47 PM.png]
…On Thu, Jul 18, 2024 at 8:52 PM TomJGooding ***@***.***> wrote:
Could you try clarifying your question? Do you mean you are still seeing
highlighting after disabling everywhere in the console?
—
Reply to this email directly, view it on GitHub
<#3433 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACP6BHIDI7CM3UJ33GKXPM3ZNAFGDAVCNFSM6AAAAABLCZHGY6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAMBYHAZDANQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Since rich is intercepting print(), and adding highlighighting, isn't there
a global function
that could be defined via a function provided by rich? I had tried using
the constructor
in the hope that this might work, but no it didn't
console = Console(highlight=False)
The output appeared as follows for the program (I changed the font color in
the mail
so you can see tha catual output
Here is the code:
rom rich import print
from rich.console import Console
console = Console(highlight=False)
highlight=False
print("[b red]Hi![/] ***@***.***>")
console.print("[b red]Hi![/] ***@***.***>")
Here is the output
*Hi!* ***@***.***>
*Hi!* ***@***.***>
…On Thu, Jul 18, 2024 at 9:09 PM TomJGooding ***@***.***> wrote:
Sorry but I can't see the screenshot you posted.
But if you're talking about Python's print function, Rich obviously has no
control over that.
If you're seeing highlighting just using the plain print function, that's
likely applied by your terminal.
—
Reply to this email directly, view it on GitHub
<#3433 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACP6BHN6NWNV65XDR65WAHTZNAHH3AVCNFSM6AAAAABLCZHGY6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAMBYHAZTIMI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Got it.. thanks.
…On Fri, Jul 19, 2024 at 12:19 PM Will McGugan ***@***.***> wrote:
from rich import reconfigurereconfigure(highlight=False)
—
Reply to this email directly, view it on GitHub
<#3433 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACP6BHOPVGDL3EUYX5H543DZNDR3LAVCNFSM6AAAAABLCZHGY6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAMBZGQZTEOI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
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
-
Is there a way to disable automatic highlighting globally,
to avoid the need to include "highlight=False" on each call to console.print()?
Beta Was this translation helpful? Give feedback.
All reactions