0
# Markdown
1
2
CommonMark-compliant markdown rendering with syntax highlighting and Rich formatting. Rich provides comprehensive markdown support for displaying formatted documents in the terminal.
3
4
## Capabilities
5
6
### Markdown Class
7
8
Main markdown rendering component with full CommonMark support.
9
10
```python { .api }
11
class Markdown:
12
"""
13
Markdown document renderer.
14
15
Args:
16
markup: Markdown text to render
17
code_theme: Theme for code blocks
18
justify: Text justification
19
style: Base style for markdown
20
hyperlinks: Enable hyperlink rendering
21
inline_code_lexer: Lexer for inline code
22
inline_code_theme: Theme for inline code
23
"""
24
def __init__(
25
self,
26
markup: str,
27
*,
28
code_theme: Union[str, SyntaxTheme] = "monokai",
29
justify: Optional[JustifyMethod] = None,
30
style: StyleType = "none",
31
hyperlinks: bool = True,
32
inline_code_lexer: Optional[str] = None,
33
inline_code_theme: Optional[Union[str, SyntaxTheme]] = None,
34
): ...
35
```
36
37
**Usage Examples:**
38
39
```python
40
from rich.console import Console
41
from rich.markdown import Markdown
42
43
console = Console()
44
45
markdown_text = """
46
# My Document
47
48
This is **bold** and *italic* text.
49
50
## Code Example
51
52
```python
53
def hello():
54
print("Hello, World!")
55
```
56
57
- List item 1
58
- List item 2
59
- List item 3
60
"""
61
62
md = Markdown(markdown_text)
63
console.print(md)
64
```