ansipants
A Python module and command-line utility for converting .ANS format ANSI art to HTML.
Installation
pip install ansipants
Command-line usage
python -m ansipants input.ans > output.html
For additional options, run python -m ansipants --help.
The output is a fragment of HTML, in UTF-8 encoding, intended to be inserted into a preformatted text element (<pre>...</pre>). Further styling is up to you - for the proper MS-DOS experience, The Ultimate Oldschool PC Font Pack by VileR is recommended.
Python API
Example code:
from ansipants import ANSIDecoder
with open('input.ans', 'rt', encoding='cp437') as f:
decoder = ANSIDecoder(f)
print(decoder.as_html())
class ansipants.ANSIDecoder(stream=None, palette='vga', width=80, strict=False)
Parameters:
stream- the ANSI input data as a file-like object. This should be opened for reading in text mode, which means you'll need to specify the appropriate encoding - for ANSI art created for DOS this will most likely becp437.palette- the colour palette to use; either'vga'or'workbench'width- the number of columns the text should wrap atstrict- If True, the decoder will raise anansipants.ANSIDecodeErrorexception on any unrecognised or malformed escape codes; if False, it will skip past them.
ANSIDecoder.as_html()
Returns the HTML output as a string.
ANSIDecoder.as_html_lines()
Returns the HTML output as an iterator, yielding one line at a time.
Author
Matt Westcott matt@west.co.tt
Metadata
Release files for ansipants 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ansipants-0.2.tar.gz | 6.5 kB | Without provenance | Details for ansipants-0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ansipants-0.2-py3-none-any.whl | Python 3 | none | any | Details for ansipants-0.2-py3-none-any.whl |
Total release size: 13.1 kB
Release files / ansipants-0.2.tar.gz
| Download URL | ansipants-0.2.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ae78c7499736addf9e8f36db960ff99a96750ba4adff9d0eac10e598bebd1b3
|
|
BLAKE2b-256 checksum How to use checksums |
7b05a7426de91fb305d3eb3295d711a3b575d15dd6fbe09fe23ade46bbff73b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0
|
Release files / ansipants-0.2-py3-none-any.whl
| Download URL | ansipants-0.2-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c634504122a23846969ec51bb5991455e87f33043c9765ea5324277a0dd3ba1d
|
|
BLAKE2b-256 checksum How to use checksums |
5f6a95a9c210791e9493113b0b1795c1f3c40460d253d3ecb82ac572fd9028bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0
|
Security for ansipants 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.