Skip to content

Markdown

markdown

Functionality for working with Markdown in Notion.

MD_STYLES = ('bold', 'italic', 'strikethrough', 'code', 'link') module-attribute

Markdown styles supported by Notion.

MD_STYLE_MAP = {'bold': '**', 'italic': '*', 'strikethrough': '~~', 'code': '`'} module-attribute

Mapping from markdown style to markdown symbol.

render_md = get_md_renderer() module-attribute

Convert Markdown to HTML.

get_md_renderer() -> Markdown

Create a markdown renderer.

md_comment(text: str) -> str

Create a markdown comment.

md_spans(rich_texts: Sequence[RichTextBase]) -> np.ndarray

Convert rich text to markdown spans.

An span is a sequence of rich texts with the same markdown style expressed as a row in the returned array. The value k of the j-th array column corresponds to the length of the current span richt_texts[j-k:j].

rich_texts_to_markdown(rich_texts: Sequence[RichTextBase]) -> str

Convert a list of rich texts to markdown.

sorted_md_spans(md_spans: np.ndarray) -> Iterator[tuple[int, int, str]]

Sort the spans of the given markdown spans in the right order.

We have to iterate from the smallest spans to the largest spans and from left to right.