rich.markdown
- class rich.markdown.BlockQuote[source]
A block quote.
- on_child_close(context, child)[source]
Called when a child element is closed.
This method allows a parent element to take over rendering of its children.
- Parameters:
context (MarkdownContext) – The markdown context.
child (MarkdownElement) – The child markdown element.
- Returns:
Return True to render the element, or False to not render the element.
- Return type:
- class rich.markdown.Heading(tag)[source]
A heading.
- Parameters:
tag (str)
- classmethod create(markdown, token)[source]
Factory to create markdown element,
- Parameters:
markdown (Markdown) – The parent Markdown object.
token (Token) – A node from markdown-it.
- Returns:
A new markdown element
- Return type:
MarkdownElement
- on_enter(context)[source]
Called when the node is entered.
- Parameters:
context (MarkdownContext) – The markdown context.
- Return type:
None
- class rich.markdown.ImageItem(destination, hyperlinks)[source]
Renders a placeholder for an image.
- classmethod create(markdown, token)[source]
Factory to create markdown element,
- Parameters:
markdown (Markdown) – The parent Markdown object.
token (Any) – A token from markdown-it.
- Returns:
A new markdown element
- Return type:
MarkdownElement
- on_enter(context)[source]
Called when the node is entered.
- Parameters:
context (MarkdownContext) – The markdown context.
- Return type:
None
- class rich.markdown.ListElement(list_type, list_start)[source]
A list element.
- classmethod create(markdown, token)[source]
Factory to create markdown element,
- Parameters:
markdown (Markdown) – The parent Markdown object.
token (Token) – A node from markdown-it.
- Returns:
A new markdown element
- Return type:
MarkdownElement
- on_child_close(context, child)[source]
Called when a child element is closed.
This method allows a parent element to take over rendering of its children.
- Parameters:
context (MarkdownContext) – The markdown context.
child (MarkdownElement) – The child markdown element.
- Returns:
Return True to render the element, or False to not render the element.
- Return type:
- class rich.markdown.ListItem[source]
An item in a list.
- on_child_close(context, child)[source]
Called when a child element is closed.
This method allows a parent element to take over rendering of its children.
- Parameters:
context (MarkdownContext) – The markdown context.
child (MarkdownElement) – The child markdown element.
- Returns:
Return True to render the element, or False to not render the element.
- Return type:
- class rich.markdown.Markdown(markup, code_theme='monokai', justify=None, style='none', hyperlinks=True, inline_code_lexer=None, inline_code_theme=None)[source]
A Markdown renderable.
- Parameters:
markup (str) – A string containing markdown.
code_theme (str, optional) – Pygments theme for code blocks. Defaults to “monokai”. See https://pygments.org/styles/ for code themes.
justify (JustifyMethod, optional) – Justify value for paragraphs. Defaults to None.
style (Union[str, Style], optional) – Optional style to apply to markdown.
hyperlinks (bool, optional) – Enable hyperlinks. Defaults to
True.inline_code_lexer (str | None) – (str, optional): Lexer to use if inline code highlighting is enabled. Defaults to None.
inline_code_theme (str | None) – (Optional[str], optional): Pygments theme for inline code highlighting, or None for no highlighting. Defaults to None.
- class rich.markdown.MarkdownContext(console, options, style, inline_code_lexer=None, inline_code_theme='monokai')[source]
Manages the console render state.
- Parameters:
console (Console)
options (ConsoleOptions)
style (Style)
inline_code_lexer (str | None)
inline_code_theme (str)
- class rich.markdown.Paragraph(justify)[source]
A Paragraph.
- Parameters:
justify (Literal['default', 'left', 'center', 'right', 'full'])
- class rich.markdown.TableBodyElement[source]
MarkdownElement corresponding to tbody_open and tbody_close.
- on_child_close(context, child)[source]
Called when a child element is closed.
This method allows a parent element to take over rendering of its children.
- Parameters:
context (MarkdownContext) – The markdown context.
child (MarkdownElement) – The child markdown element.
- Returns:
Return True to render the element, or False to not render the element.
- Return type:
- class rich.markdown.TableDataElement(justify)[source]
MarkdownElement corresponding to td_open and td_close and th_open and th_close.
- Parameters:
justify (JustifyMethod)
- classmethod create(markdown, token)[source]
Factory to create markdown element,
- Parameters:
markdown (Markdown) – The parent Markdown object.
token (Token) – A node from markdown-it.
- Returns:
A new markdown element
- Return type:
MarkdownElement
- on_text(context, text)[source]
Called when text is parsed.
- Parameters:
context (MarkdownContext) – The markdown context.
- Return type:
None
- class rich.markdown.TableElement[source]
MarkdownElement corresponding to table_open.
- on_child_close(context, child)[source]
Called when a child element is closed.
This method allows a parent element to take over rendering of its children.
- Parameters:
context (MarkdownContext) – The markdown context.
child (MarkdownElement) – The child markdown element.
- Returns:
Return True to render the element, or False to not render the element.
- Return type:
- class rich.markdown.TableHeaderElement[source]
MarkdownElement corresponding to thead_open and thead_close.
- on_child_close(context, child)[source]
Called when a child element is closed.
This method allows a parent element to take over rendering of its children.
- Parameters:
context (MarkdownContext) – The markdown context.
child (MarkdownElement) – The child markdown element.
- Returns:
Return True to render the element, or False to not render the element.
- Return type:
- class rich.markdown.TableRowElement[source]
MarkdownElement corresponding to tr_open and tr_close.
- on_child_close(context, child)[source]
Called when a child element is closed.
This method allows a parent element to take over rendering of its children.
- Parameters:
context (MarkdownContext) – The markdown context.
child (MarkdownElement) – The child markdown element.
- Returns:
Return True to render the element, or False to not render the element.
- Return type:
- class rich.markdown.TextElement[source]
Base class for elements that render text.
- on_enter(context)[source]
Called when the node is entered.
- Parameters:
context (MarkdownContext) – The markdown context.
- Return type:
None
- on_leave(context)[source]
Called when the parser leaves the element.
- Parameters:
context (MarkdownContext) – [description]
- Return type:
None
- on_text(context, text)[source]
Called when text is parsed.
- Parameters:
context (MarkdownContext) – The markdown context.
- Return type:
None