Skip to main content

ansi2micron

Convert ANSI escape sequences to Nomadnet MicronMU markup.

Supports 8-colour (+ bright), 256-colour, and 24-bit ANSI sequences. Formatting codes are only emitted when state actually changes, minimising output size for bandwidth-constrained transport.

Installation

From PyPI (once published):

pip install ansi2micron

From GitHub (current method):

pip install git+https://github.com/JamesM92/Ansi2MicronMU.git

From a local clone:

git clone https://github.com/JamesM92/Ansi2MicronMU.git
pip install ./Ansi2MicronMU

Quick start

from ansi2micron import MicronConverter

mc = MicronConverter()

ansi_text = "\x1b[1;32mHello\x1b[0m, world!"
print(mc.convert(ansi_text))
# `!`F0f0Hello``, world!

API

MicronConverter.convert(text, *, triple_quotes=False, trailing_newline=True, literal_mode=False)

Convert an ANSI-formatted string to MicronMU markup.

Parameter Type Default Description
text str — Input string containing ANSI escape sequences
triple_quotes bool False Wrap each output line in """...""" blocks
trailing_newline bool True Append \n to the result
literal_mode bool False Strip all ANSI and wrap output in `= literal blocks (safe for ASCII art)

Utility helpers

These produce MicronMU markup directly and do not require ANSI input.

MicronConverter.heading(text, level=1)       # >text, >>text, >>>text
MicronConverter.divider(char=None)           # - or -<char>
MicronConverter.link(label, url, fields=None) # `[label`url] or `[label`url`fields]
MicronConverter.colored(text, fg=None, bg=None) # `Fff0text``
MicronConverter.aligned(text, alignment='center') # `ctext`a
MicronConverter.strip_ansi(text)             # Remove all ANSI sequences

MicronConverter.ansi_256_to_3hex(n)

Convert a 256-colour palette index to a 3-char hex string (e.g. 'f80'). Static method — can be called without an instance.

Colour support

ANSI type Example Notes
8-colour \x1b[31m Maps to fixed MicronMU hex values
8-colour bright \x1b[91m Bright variants
256-colour \x1b[38;5;202m Quantised to nearest 3-hex
24-bit truecolor \x1b[38;2;255;128;0m Quantised to nearest 3-hex

MicronMU uses 3-hex colours where each hex digit is doubled for rendering (e.g. f80 → #ff8800). Quantisation uses a divisor of 17 (not 16) to minimise perceptual error.

License

GNU General Public License v3.0 — see LICENSE.

Metadata

Release files for ansi2micron 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ansi2micron 1.0.2
File Size Uploaded Provenance Actions
ansi2micron-1.0.2.tar.gz 48.5 kB With provenance Details for ansi2micron-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ansi2micron 1.0.2
File Interpreter ABI Platform Actions
ansi2micron-1.0.2-py3-none-any.whl Python 3 none any Details for ansi2micron-1.0.2-py3-none-any.whl

Total release size: 81.4 kB

Release files / ansi2micron-1.0.2.tar.gz

Download URL ansi2micron-1.0.2.tar.gz
Size 48.5 kB
Tags Source
SHA-256 checksum
How to use checksums
12e243809d974f38e016615f535be5486c23f0b38c77b29aaae472bae4d5db7e
BLAKE2b-256 checksum
How to use checksums
2d9f281dcb8b6889864f8f642e6d5fcfcb890bc7de4a2b9a3dbc29b7f25bcdb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 25, 2026.

Transparency log

Release files / ansi2micron-1.0.2-py3-none-any.whl

Download URL ansi2micron-1.0.2-py3-none-any.whl
Size 32.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74cae49ade71fd322267e4095642d86c54792ec06b87648a6bada4d6d8f5ad25
BLAKE2b-256 checksum
How to use checksums
d01ece78cac4b5107ef9c52d8442b93ddbbf1dc3d84eeaa0b5a446fb43f8d54f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 25, 2026.

Transparency log

Security for ansi2micron 1.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ansi2micron-1.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 25, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page