You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, rich is great! Maybe you can help me on this here.
I checked yout issue collection and the internet, but found nothing, so I decided to post an issue.
My use case is rendering different colors, icons and markdown using inline Markdown code
The Options I tried is summarized in following ready to run sample code:
# Issue with Markdown Class
# VERSIONS:
# WINDOWS OS in NEW COMMAND LINE EDITO + BASH
# Python 3.11.1
# rich 12.6.0
[Diagnosis_Data.txt](https://github.com/user-attachments/files/18135496/Diagnosis_Data.txt)
# rich-cli 1.8.0
# rich-rst 1.3.1
from rich.console import Console
from rich.markdown import Markdown
from rich.text import Text
from rich.table import Table
from rich.emoji import Emoji
import re
print("------------")
# I also tested Options using color system
console = Console()
# this is my use case: markdown with ,multiple colors and icons in one line
s = f"An [red]APPLE[/red] :apple: keeps the [blue]DOCTOR[/blue] away "
# you might also uncomment emoji conversion / has no effect on issue when deactivated
s = Emoji.replace(s)
s_out = [f"* CASE 1 (print) {s}",
f"* CASE 2 (MARKDOWN inline -error) {s}",
f"* CASE 3 (Using Text with style) {s}",
f"* CASE 4 (Using Text using markup) {s}",
f"* CASE 5 (Using markup fix) {s}",
f"* CASE 6 (MARKDOWN workaround) {s}"]
# CASE 1 Test plain rendering
console.print(s_out[0])
# CASE 2 Using MARKDOWN, ERROR JUST SHOWS BRACKETS
# inline_code_lexer has no effect for my use case
# code_theme has no effect for my use case
console.print(Markdown(s_out[1],inline_code_lexer="python"))
# CASE 3 Try Using Text as intermediate workaround doesn't work
t = Text(s_out[2],style="red")
# this demonstrates the working of markup for print but not in MarkDown format
# console.print(Markdown(t.markup)) # will also lead to non coloring ...
console.print(t.markup)
# CASE 4 Try Using Text with markup
markup = Text(s_out[3]).markup
console.print(markup)
# CASE 5 Try Using rendering with an ugly workaround
# Note markup value in debugger shows up as follows (escaping the brackets "[" "):
# '* CASE 4 (Using Text using markup) An \\[red]APPLE\\[/red] 🍎 keeps the \\[blue]DOCTOR\\[/blue] away '
markup = Text(s_out[4]).markup
markup_fix = re.sub("\\\\\[","[",markup)
console.print(markup_fix)
# CASE 6 Using the fix to get a working Markdown
markup = Text(s_out[5]).markup
markup_fix = re.sub("\\\\\[","[",markup)
console.print(Markdown(markup_fix))
print("------------")
What I get as output
Issue description
Software / OS Versions in sample code
Color rendering is ok for using text, but not markup (Case 1,Case 5)
Code keeps running against the wall ignoring [color]..[/color] inline code when trying to use Markdown(...)
Converting it to Text and getting back str using Markdown(Text(...).markup) / try to fiddle with escaping (= dropping the extra \ escape char in front of [ ) won't also help (Case 6)
Also attached Diagnosis data. Color Rendering works, but not for Markdown.
This is only a pet project, so It's not a pressing issue ...
Thanks @willmcgugan that was a quicl response. Will consider adapting.
However it "looks" for me like it would be natural to use Markdown("[color]...") to link both system together. Ok, will close the issue. Thanks and have good week end.
- [X] I've checked docs and closed issues for possible solutions.
Hi, rich is great! Maybe you can help me on this here.
I checked yout issue collection and the internet, but found nothing, so I decided to post an issue.
My use case is rendering different colors, icons and markdown using inline Markdown code
The Options I tried is summarized in following ready to run sample code:
What I get as output
Issue description
\
escape char in front of[
) won't also help (Case 6)This is only a pet project, so It's not a pressing issue ...
Thanks !
Platform / Installation information
Click to expand
The text was updated successfully, but these errors were encountered: