Markdown¶
A widget to display a Markdown document.
- Focusable
- Container
Tip
See MarkdownViewer for a widget that adds additional features such as a Table of Contents.
Example¶
The following example displays Markdown from a string.
from textual.app import App, ComposeResult
from textual.widgets import Markdown
EXAMPLE_MARKDOWN = """\
# Markdown Document
This is an example of Textual's `Markdown` widget.
## Features
Markdown syntax and extensions are supported.
- Typography *emphasis*, **strong**, `inline code` etc.
- Headers
- Lists (bullet and ordered)
- Syntax highlighted code blocks
- Tables!
"""
class MarkdownExampleApp(App):
def compose(self) -> ComposeResult:
yield Markdown(EXAMPLE_MARKDOWN)
if __name__ == "__main__":
app = MarkdownExampleApp()
app.run()
Messages¶
TableOfContentsUpdated
¶
TableOfContentsSelected
¶
LinkClicked
¶
See Also¶
- Markdown code reference
- MarkdownViewer code reference