Rich reStructuredText Renderer
A Python library that provides a beautiful reStructuredText renderer, integrating with the `rich` library to display reStructuredText documents with syntax highlighting and rich formatting directly in the terminal. It's currently at version 1.3.2 and maintains an active release cadence with regular updates and bug fixes.
Warnings
- gotcha Compatibility with `docutils` versions can be sensitive. `rich-rst` is regularly updated to track `docutils` changes (e.g., v1.3.2 updated for Docutils 0.22). Ensure your `docutils` version is compatible to avoid rendering issues.
- gotcha Older versions of `rich-rst` (pre-1.3.0) might have exposed `docutils`' internal `optparse` deprecation warnings. While fixed in newer releases, this indicates potential for upstream dependency deprecations impacting users.
- gotcha While `rich-rst` supports many reStructuredText elements and common Sphinx roles (since v1.3.2), highly complex or obscure directives/roles might not render perfectly in the terminal environment as they would in Sphinx-generated HTML documentation. Test complex documents thoroughly.
Install
-
pip install rich-rst
Imports
- RestructuredText
from rich_rst import RestructuredText
- print
from rich import print
Quickstart
from rich_rst import RestructuredText
from rich import print
rst_content = """
My Document
===========
This is a *simple* reStructuredText document.
.. code:: python
print('Hello, Rich RST!')
- Item 1
- Item 2
.. note:: This is a note.
"""
# Render the reStructuredText to the console
print(RestructuredText(rst_content))