-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Markdown does not render "markdown" code blocks correctly! #3128
Comments
What output would you expect? For example, if I take your input document and include it in this comment, which will render it with GitHub's own Markdown rendering engine, it looks pretty much the same: Sure, here is the information in a markdown table: | Rank | River Name | Length (km) |
| --- | --- | --- |
| 1 | Nile | 6,650 |
| 2 | Congo | 4,700 |
| 3 | Niger | 4,180 |
| 4 | Zambezi | 2,574 |
| 5 | Ubangi | 2,270 | Or, if I preview it with the online markdown-it demo, it also appears the same: What incorrect rendering are you seeing? |
I'm pretty sure there's a bit of confusion here between the table that was pasted inside the triple backticks, which is supposed to represent “markdown source ”””code””””, and the pretty table representation one gets from markdown tables. @gagb from rich.panel import Panel
from rich.markdown import Markdown
from rich.console import Console, group, Group
from rich.text import Text
content = "Sure, here is the information in a markdown table:\n\n| Rank | River Name | Length (km) |\n| --- | --- | --- |\n| 1 | Nile | 6,650 |\n| 2 | Congo | 4,700 |\n| 3 | Niger | 4,180 |\n| 4 | Zambezi | 2,574 |\n| 5 | Ubangi | 2,270 |\n"
print(content)
panel_content = Markdown(content)
console = Console()
console.print(panel_content) Notice how I dropped the ```markdown from the beginning of the table and the triple-backtick from the end. |
I hope we solved your problem. If you like using Rich, you might also enjoy Textual |
You are correct @rodrigogiraoserrao -- your response helped clarify my confusion about the semantics of the renderer. Thank you! |
I'm glad I could help. |
Rich's markdown rendering fails on the following example.
Example:
Running this code results in:
Platform
MacOS 13.5.1 (22G90)
Python 3.11.4
rich==13.5.2
iTerm2 (Build 3.4.16)
The text was updated successfully, but these errors were encountered: