Skip to content

Markdown

Markdown

Bases: Widget

LinkClicked

Bases: Message

A link in the document was clicked.

href: str instance-attribute

The link that was selected.

TableOfContentsSelected

Bases: Message

An item in the TOC was selected.

block_id instance-attribute

ID of the block that was selected.

TableOfContentsUpdated

Bases: Message

The table of contents was updated.

table_of_contents: TableOfContentsType instance-attribute

Table of contents.

__init__(markdown=None, *, name=None, id=None, classes=None, parser_factory=None)

A Markdown widget.

Parameters:

Name Type Description Default
markdown str | None

String containing Markdown or None to leave blank for now. Defaults to None.

None
name str | None

The name of the widget.

None
id str | None

The ID of the widget in the DOM.

None
classes str | None

The CSS classes of the widget.

None
parser_factory Callable[[], MarkdownIt] | None

A factory function to return a configured MarkdownIt instance. If None, a "gfm-like" parser is used.

None

load(path) async

Load a new Markdown document.

Parameters:

Name Type Description Default
path Path

Path to the document.

required

Returns:

Type Description
bool

True on success, or False if the document could not be read.

update(markdown) async

Update the document with new Markdown.

Parameters:

Name Type Description Default
markdown str

A string containing Markdown.

required