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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file erbsland_sphinx_ansi-1.1.2.tar.gz.
File metadata
- Download URL: erbsland_sphinx_ansi-1.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4f6086ade4fedb8d776701c94e0780ea8794dbe0c6292e70c46fb638bd48d6f
|
|
| MD5 |
6bab3ac1a7a0f4f8ca6adcb1a0815580
|
|
| BLAKE2b-256 |
7e0988889c55d0c18a1385a1d7a546653ef9f51007e09e94aac869ea36253be6
|
Provenance
The following attestation bundles were made for erbsland_sphinx_ansi-1.1.2.tar.gz:
Publisher:
publish.yml on erbsland-dev/erbsland-sphinx-ansi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
erbsland_sphinx_ansi-1.1.2.tar.gz -
Subject digest:
e4f6086ade4fedb8d776701c94e0780ea8794dbe0c6292e70c46fb638bd48d6f - Sigstore transparency entry: 1173301659
- Sigstore integration time:
-
Permalink:
erbsland-dev/erbsland-sphinx-ansi@02d869de8b4d4b4188be0a30aa3c630bc6d6e7e9 -
Branch / Tag:
refs/tags/v1.1.2 - Owner: https://github.com/erbsland-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@02d869de8b4d4b4188be0a30aa3c630bc6d6e7e9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file erbsland_sphinx_ansi-1.1.2-py3-none-any.whl.
File metadata
- Download URL: erbsland_sphinx_ansi-1.1.2-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cedee21d68cdfb67655cc1f5bc9ee7893c6ae7c804d74615f4f1f9675f80b9b
|
|
| MD5 |
0c06837d8527bc1bdef648294a08ae19
|
|
| BLAKE2b-256 |
64ae7f25b4fef1972c708184204ae3b209a116aaab7c8ec9727e8965060c2b97
|
Provenance
The following attestation bundles were made for erbsland_sphinx_ansi-1.1.2-py3-none-any.whl:
Publisher:
publish.yml on erbsland-dev/erbsland-sphinx-ansi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
erbsland_sphinx_ansi-1.1.2-py3-none-any.whl -
Subject digest:
6cedee21d68cdfb67655cc1f5bc9ee7893c6ae7c804d74615f4f1f9675f80b9b - Sigstore transparency entry: 1173301713
- Sigstore integration time:
-
Permalink:
erbsland-dev/erbsland-sphinx-ansi@02d869de8b4d4b4188be0a30aa3c630bc6d6e7e9 -
Branch / Tag:
refs/tags/v1.1.2 - Owner: https://github.com/erbsland-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@02d869de8b4d4b4188be0a30aa3c630bc6d6e7e9 -
Trigger Event:
release
-
Statement type: