Skip to main content

A Sphinx extension to format ANSI colored/formated terminal output

Project description

ANSI-Colored Terminal Output for Sphinx

erbsland-sphinx-ansi is a lightweight Sphinx extension that renders ANSI-colored and formatted terminal output directly in your documentation.

It is useful for command-line tools, build logs, and interactive sessions where terminal colors improve readability.

Installation

pip install erbsland-sphinx-ansi

Quick Start

Enable the extension in conf.py:

extensions = [
    # ...
    "erbsland.sphinx.ansi",
]

Use the erbsland-ansi directive:

.. erbsland-ansi::
    :escape-char: ␛

    ␛[32m[sphinx-autobuild] ␛[36mStarting initial build␛[0m
    ␛[32m[sphinx-autobuild] ␛[34m> python -m sphinx build doc _build␛[0m
    ␛[32m[sphinx-autobuild] ␛[36mServing on http://127.0.0.1:9000␛[0m
    ␛[32m[sphinx-autobuild] ␛[36mWaiting to detect changes...␛[0m

escape-char is optional. If set, this character is replaced with the ANSI escape character (\x1b) when parsing the directive content. If omitted, provide real ANSI escape sequences directly.

Output Behavior

  • HTML output: ANSI sequences are converted into styled output.
  • Non-HTML output: ANSI formatting is stripped, leaving plain text.

Requirements

  • Python 3.10+
  • Sphinx 8.0+ (required by the extension at runtime)

Development

  • Python 3.13+

Install development dependencies:

pip install -r requirements-dev.txt

Run tests:

pytest

Documentation

Project documentation is here: https://sphinx-ansi.erbsland.dev.

License

Copyright (c) 2026 Tobias Erbsland / Erbsland DEV (https://erbsland.dev)

Licensed under the Apache License, Version 2.0. See LICENSE for details.

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

erbsland_sphinx_ansi-1.1.6.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

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

erbsland_sphinx_ansi-1.1.6-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file erbsland_sphinx_ansi-1.1.6.tar.gz.

File metadata

  • Download URL: erbsland_sphinx_ansi-1.1.6.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for erbsland_sphinx_ansi-1.1.6.tar.gz
Algorithm Hash digest
SHA256 26d9c34e6071c9235df2d1ab94a967864e236b13098abd1530f6692acdd38726
MD5 58aeabbe9491ae8be8b7c6c3306b7e5f
BLAKE2b-256 8c1fc8e960c43ec7da8faefa2131badb8b04ddc67ca9d436f50bdfeb7aa9bdbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for erbsland_sphinx_ansi-1.1.6.tar.gz:

Publisher: publish.yml on erbsland-dev/erbsland-sphinx-ansi

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

File details

Details for the file erbsland_sphinx_ansi-1.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for erbsland_sphinx_ansi-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6e0bfaeda2d27260d6833ab8fb7c1851a5a159f5074e2b1f35e614e8104e406a
MD5 1a3282b1db0af1da1d618ebba23c81cd
BLAKE2b-256 5e1f8ea37fac5c508cac9b60dcbf81ce1735b010a90d23045f653acb62480598

See more details on using hashes here.

Provenance

The following attestation bundles were made for erbsland_sphinx_ansi-1.1.6-py3-none-any.whl:

Publisher: publish.yml on erbsland-dev/erbsland-sphinx-ansi

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