A beautiful reStructuredText renderer for rich
Actively maintained. Last release 2 months ago, commits in 8 of the last 26 weeks. A safe choice.
pip install rich-rstrich-rst
Render reStructuredText with Rich. This package turns reST documents into Rich renderables so you can preview documentation, docstrings, and snippets directly in the terminal. Also includes a CLI.
Highlights
- Supports all currently documented RST elements.
- Handles common documentation features such as headings, lists, tables, links, images, code blocks, footnotes, and many Sphinx roles.
- Provides both a Python API and a command-line interface.
- Can also export rendered output to HTML from the CLI.
Installation
pip install rich-rst
Python API
from rich import print
from rich_rst import RestructuredText
document = """
rich-rst
========
This is a **test** document.
- Item one
- Item two
.. code-block:: python
print("hello")
"""
print(RestructuredText(document))
The main constructor options are code_theme, show_line_numbers, show_errors, guess_lexer, default_lexer, sphinx_compat, admonition_style, and allow_file_access.
Directives that read other files (include, literalinclude, and raw/csv-table with :file: or :url:) are disabled by default. Pass allow_file_access=True to enable them, but only for markup you trust.