Skip to main content

A tiny, hookable reStructuredText-to-text converter

Project description

nanorst

nanorst converts a deliberately small subset of reStructuredText (rST) into readable plain text. A state hook can be used to convert inline formatting to other forms, such as terminal escapes or HTML.

from nanorst import rst_to_text, rst_to_terminal

assert rst_to_text("This is **important**.") == "This is important."
print(rst_to_terminal("This is **important**."))

Supported constructs include emphasis, strong emphasis, inline literals, references supplied by the caller, simple directives, and indented literal blocks. This module is intentionally a loose converter, not a standards-complete reStructuredText implementation.

Development

Create a virtual environment, then install the project and its test dependencies:

python -m pip install -e '.[test]'
pytest

Build both distribution formats and validate their metadata with:

python -m pip install '.[build]'
python -m build
twine check dist/*

Releases are published by the release.yml GitHub Actions workflow when a version tag such as v0.1.0 is pushed. Configure a PyPI Trusted Publisher for the enkore/nanorst repository, workflow release.yml, and environment pypi.

Users

borgbackup has been using nanorst since borg 1.1.0 as a lightweight rST terminal formatter for --help and borg help TOPIC. The same rST sources are also rendered using sphinx-doc for the manual.

License

BSD-3-Clause. See LICENSE.

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

nanorst-1.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

nanorst-1.0.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file nanorst-1.0.0.tar.gz.

File metadata

  • Download URL: nanorst-1.0.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nanorst-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3b1e859a45ae429bfd26573154472b1c16ee2fe08f30fe8c39575dcbce015f4f
MD5 e1c64c38240da8f0c2b12570f0c68921
BLAKE2b-256 aacf0f333e2ec06b7297a3f659fd13b78a247cb2a73f5b6f66248f4895a87b2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanorst-1.0.0.tar.gz:

Publisher: release.yml on enkore/nanorst

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nanorst-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: nanorst-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nanorst-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 290fb7ee26d51bef9de424c1c9a5f3a86af92b1fb32e355b5ce763b922eefffd
MD5 5759b52f2fc014ff02a275cc7b4a1589
BLAKE2b-256 b131fb301acff080fcef7f1dcaf0e94e5215dadea8a92560fc845ae6f298a762

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanorst-1.0.0-py3-none-any.whl:

Publisher: release.yml on enkore/nanorst

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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