Skip to main content

A beautiful reStructuredText renderer for rich

Project description

Logo

rich-rst

Documentation Status Tests Status CodeQL Status Codecov

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, and admonition_style.

Command Line Interface

Render a file:

python -m rich_rst readme.rst

Render from standard input:

python -m rich_rst -

View all available options:

python -m rich_rst --help

Useful flags include --code-theme, --show-line-numbers, --guess-lexer, --default-lexer, --show-errors, --admonition-style, --save-html, --html-theme, --list-html-themes, --output, and --version.

Compatibility

The renderer is designed for terminal output, so not every docutils feature can be represented visually. The current limitations and unsupported elements are documented in ELEMENTS.md.

Documentation

Changelog

See CHANGELOG.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rich_rst-2.0.3.tar.gz (301.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rich_rst-2.0.3-py3-none-any.whl (273.1 kB view details)

Uploaded Python 3

File details

Details for the file rich_rst-2.0.3.tar.gz.

File metadata

  • Download URL: rich_rst-2.0.3.tar.gz
  • Upload date:
  • Size: 301.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for rich_rst-2.0.3.tar.gz
Algorithm Hash digest
SHA256 ffc7d779e594ae5bce1256e1bb95f3b89bf36c6c3566671133ace0603261e76f
MD5 a29c904024b7cc8b4fca4e3ca1eb927f
BLAKE2b-256 6c2bd2f53dedfb4ec4d88a87e5941c9616a3d4261d36d113f86959c27f9c9619

See more details on using hashes here.

File details

Details for the file rich_rst-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: rich_rst-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 273.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for rich_rst-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8de7f59fc9ea38ed01c1be98fc07274a3af282666f7ecf812d05269aec08cda6
MD5 c9eebdf22d185e8333fc15a5753fe4b2
BLAKE2b-256 382d99433ba6e0adbb8a84e90adf0382650c7904e6eec4bafdc55ac691827e7f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page