rich.markdown¶
-
class
rich.markdown.
BlockQuote
[source]¶ A block quote.
-
on_child_close
(context: rich.markdown.MarkdownContext, child: rich.markdown.MarkdownElement) → bool[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
bool
-
-
class
rich.markdown.
CodeBlock
(lexer_name: str, theme: str)[source]¶ A code block with syntax highlighting.
-
classmethod
create
(markdown: rich.markdown.Markdown, node: Any) → rich.markdown.CodeBlock[source]¶ Factory to create markdown element,
- Parameters
markdown (Markdown) – THe parent Markdown object.
node (Any) – A node from Pygments.
- Returns
A new markdown element
- Return type
MarkdownElement
-
classmethod
-
class
rich.markdown.
Heading
(level: int)[source]¶ A heading.
-
classmethod
create
(markdown: rich.markdown.Markdown, node: Any) → rich.markdown.Heading[source]¶ Factory to create markdown element,
- Parameters
markdown (Markdown) – THe parent Markdown object.
node (Any) – A node from Pygments.
- Returns
A new markdown element
- Return type
MarkdownElement
-
on_enter
(context: rich.markdown.MarkdownContext) → None[source]¶ Called when the node is entered.
- Parameters
context (MarkdownContext) – The markdown context.
-
classmethod
-
class
rich.markdown.
ImageItem
(destination: str, hyperlinks: bool)[source]¶ Renders a placeholder for an image.
-
classmethod
create
(markdown: rich.markdown.Markdown, node: Any) → rich.markdown.MarkdownElement[source]¶ Factory to create markdown element,
- Parameters
markdown (Markdown) – THe parent Markdown object.
node (Any) – A node from Pygments.
- Returns
A new markdown element
- Return type
MarkdownElement
-
on_enter
(context: rich.markdown.MarkdownContext) → None[source]¶ Called when the node is entered.
- Parameters
context (MarkdownContext) – The markdown context.
-
classmethod
-
class
rich.markdown.
ListElement
(list_type: str, list_start: Optional[int])[source]¶ A list element.
-
classmethod
create
(markdown: rich.markdown.Markdown, node: Any) → rich.markdown.ListElement[source]¶ Factory to create markdown element,
- Parameters
markdown (Markdown) – THe parent Markdown object.
node (Any) – A node from Pygments.
- Returns
A new markdown element
- Return type
MarkdownElement
-
on_child_close
(context: rich.markdown.MarkdownContext, child: rich.markdown.MarkdownElement) → bool[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
bool
-
classmethod
-
class
rich.markdown.
ListItem
[source]¶ An item in a list.
-
on_child_close
(context: rich.markdown.MarkdownContext, child: rich.markdown.MarkdownElement) → bool[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
bool
-
-
class
rich.markdown.
Markdown
(markup: str, code_theme: str = 'monokai', justify: Optional[typing_extensions.Literal[default, left, center, right, full]] = None, style: Union[str, rich.style.Style] = 'none', hyperlinks: bool = True, inline_code_lexer: Optional[str] = None, inline_code_theme: Optional[str] = None)[source]¶ A Markdown renderable.
- Parameters
markup (str) – A string containing markdown.
code_theme (str, optional) – Pygments theme for code blocks. Defaults to “monokai”.
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, optional): Lexer to use if inline code highlighting is enabled. Defaults to “python”.
inline_code_theme – (Optional[str], optional): Pygments theme for inline code highlighting, or None for no highlighting. Defaults to None.
-
class
rich.markdown.
MarkdownContext
(console: rich.console.Console, options: rich.console.ConsoleOptions, style: rich.style.Style, inline_code_lexer: Optional[str] = None, inline_code_theme: str = 'monokai')[source]¶ Manages the console render state.
-
property
current_style
¶ Current style which is the product of all styles on the stack.
-
enter_style
(style_name: Union[str, rich.style.Style]) → rich.style.Style[source]¶ Enter a style context.
-
leave_style
() → rich.style.Style[source]¶ Leave a style context.
-
property
-
class
rich.markdown.
Paragraph
(justify: typing_extensions.Literal[default, left, center, right, full])[source]¶ A Paragraph.
-
classmethod
create
(markdown: rich.markdown.Markdown, node) → rich.markdown.Paragraph[source]¶ Factory to create markdown element,
- Parameters
markdown (Markdown) – THe parent Markdown object.
node (Any) – A node from Pygments.
- Returns
A new markdown element
- Return type
MarkdownElement
-
classmethod
-
class
rich.markdown.
TextElement
[source]¶ Base class for elements that render text.
-
on_enter
(context: rich.markdown.MarkdownContext) → None[source]¶ Called when the node is entered.
- Parameters
context (MarkdownContext) – The markdown context.
-
on_leave
(context: rich.markdown.MarkdownContext) → None[source]¶ Called when the parser leaves the element.
- Parameters
context (MarkdownContext) – [description]
-
on_text
(context: rich.markdown.MarkdownContext, text: Union[str, rich.text.Text]) → None[source]¶ Called when text is parsed.
- Parameters
context (MarkdownContext) – The markdown context.
-