Merge pull request #1791 from Textualize/textual-markdown

Textual markdown
This commit is contained in:
Will McGugan
2023-02-15 09:23:19 +00:00
committed by GitHub
21 changed files with 1752 additions and 123 deletions

40
docs/widgets/markdown.md Normal file
View File

@@ -0,0 +1,40 @@
# Markdown
A widget to display a Markdown document.
- [x] Focusable
- [ ] Container
!!! tip
See [MarkdownViewer](./markdown_viewer.md) for a widget that adds additional features such as a Table of Contents.
## Example
The following example displays Markdown from a string.
=== "Output"
```{.textual path="docs/examples/widgets/markdown.py"}
```
=== "markdown.py"
~~~python
--8<-- "docs/examples/widgets/markdown.py"
~~~
## Messages
### ::: textual.widgets.Markdown.TableOfContentsUpdated
### ::: textual.widgets.Markdown.TableOfContentsSelected
### ::: textual.widgets.Markdown.LinkClicked
## See Also
* [Markdown][textual.widgets.Markdown] code reference
* [MarkdownViewer][textual.widgets.MarkdownViewer] code reference

View File

@@ -0,0 +1,37 @@
# Markdown Viewer
A Widget to display Markdown content with an optional Table of Contents.
- [x] Focusable
- [ ] Container
!!! note
This Widget adds browser-like functionality on top of the [Markdown](./markdown.md) widget.
## Example
The following example displays Markdown from a string and a Table of Contents.
=== "Output"
```{.textual path="docs/examples/widgets/markdown_viewer.py" columns="100" lines="42"}
```
=== "markdown.py"
~~~python
--8<-- "docs/examples/widgets/markdown_viewer.py"
~~~
## Reactive Attributes
| Name | Type | Default | Description |
| ------------------------ | ---- | ------- | ----------------------------------------------------------------- |
| `show_table_of_contents` | bool | True | Wether a Table of Contents should be displayed with the Markdown. |
## See Also
* [MarkdownViewer][textual.widgets.MarkdownViewer] code reference
* [Markdown][textual.widgets.Markdown] code reference