Rich reStructuredText Renderer

raw JSON →
1.3.2 verified Tue May 12 auth: no python install: verified quickstart: verified

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.

pip install rich-rst
error ModuleNotFoundError: No module named 'rich_rst'
cause The rich-rst package has not been installed in the current Python environment or the environment is not correctly activated.
fix
pip install rich-rst
error AttributeError: module 'rich_rst' has no attribute 'render'
cause The `rich_rst` module does not provide a top-level `render()` function; rendering is done by instantiating the `RestructuredText` class and printing it with a `rich.console.Console`.
fix
from rich_rst import RestructuredText from rich.console import Console console = Console() rst_content = "Hello *World*!" rst_renderer = RestructuredText(rst_content) console.print(rst_renderer)
error ImportError: cannot import name 'RestructuredTextRenderer' from 'rich_rst'
cause The main class for rendering reStructuredText is named `RestructuredText`, not `RestructuredTextRenderer`, and it is directly importable from the `rich_rst` package.
fix
from rich_rst import RestructuredText # ... then use RestructuredText to render your content
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.
fix Upgrade `rich-rst` to the latest version (`pip install --upgrade rich-rst`) to ensure compatibility with recent `docutils` versions.
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.
fix Upgrade to `rich-rst` version 1.3.0 or newer to mitigate `optparse` deprecation warnings from `docutils`.
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.
fix Simplify complex reStructuredText structures if rendering fidelity in the terminal is critical, or be prepared for minor visual discrepancies in highly advanced documents.
python os / libc status wheel install import disk
3.10 alpine (musl) wheel - 0.33s 34.4M
3.10 alpine (musl) - - 0.37s 34.4M
3.10 slim (glibc) wheel 2.8s 0.27s 35M
3.10 slim (glibc) - - 0.36s 35M
3.11 alpine (musl) wheel - 0.46s 38.2M
3.11 alpine (musl) - - 0.57s 38.1M
3.11 slim (glibc) wheel 2.8s 0.41s 39M
3.11 slim (glibc) - - 0.43s 39M
3.12 alpine (musl) wheel - 0.38s 29.7M
3.12 alpine (musl) - - 0.43s 29.7M
3.12 slim (glibc) wheel 2.8s 0.40s 30M
3.12 slim (glibc) - - 0.46s 30M
3.13 alpine (musl) wheel - 0.32s 29.5M
3.13 alpine (musl) - - 0.40s 29.4M
3.13 slim (glibc) wheel 2.8s 0.34s 30M
3.13 slim (glibc) - - 0.38s 30M
3.9 alpine (musl) wheel - 0.22s 33.6M
3.9 alpine (musl) - - 0.26s 33.6M
3.9 slim (glibc) wheel 3.3s 0.21s 34M
3.9 slim (glibc) - - 0.22s 34M

This quickstart demonstrates how to import `RestructuredText` from `rich_rst` and use it with `rich.print` to render a reStructuredText string directly to your terminal with rich formatting.

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))