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.1.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.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nanorst-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 f4e8d36cadf59d4d953cb40a9e588e0314112c5520bc9fe3a50ba1c0adfbf2a1
MD5 3a5577c94fcbbbe5382e7849bc2ad3e0
BLAKE2b-256 e0270b50200fab6086c962f2de509467af1b0b444c9fb69a23ebdcd6025a41f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanorst-1.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: nanorst-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b5039a5975d0f443e451b8e75bec7856a76869c4ac640480ee929233dd00edb0
MD5 02971dca3178e5569544b8f15a98300b
BLAKE2b-256 d6d15a6bc2a6d4b402fd2a31ef85151f4b3582dd39211262e2d813dc93aa980c

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanorst-1.0.1-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