Convert ANSI escape sequences to Nomadnet MicronMU markup
Project description
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.
Project details
Release history Release notifications | RSS feed
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 ansi2micron-1.0.2.tar.gz.
File metadata
- Download URL: ansi2micron-1.0.2.tar.gz
- Upload date:
- Size: 48.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12e243809d974f38e016615f535be5486c23f0b38c77b29aaae472bae4d5db7e
|
|
| MD5 |
d1a83e6352d5e07cbc0ecd3194f62aa4
|
|
| BLAKE2b-256 |
2d9f281dcb8b6889864f8f642e6d5fcfcb890bc7de4a2b9a3dbc29b7f25bcdb2
|
Provenance
The following attestation bundles were made for ansi2micron-1.0.2.tar.gz:
Publisher:
publish.yml on JamesM92/Ansi2MicronMU
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ansi2micron-1.0.2.tar.gz -
Subject digest:
12e243809d974f38e016615f535be5486c23f0b38c77b29aaae472bae4d5db7e - Sigstore transparency entry: 1630977402
- Sigstore integration time:
-
Permalink:
JamesM92/Ansi2MicronMU@e3d895a563cce258dceab965b9aa30196de349fa -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/JamesM92
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e3d895a563cce258dceab965b9aa30196de349fa -
Trigger Event:
push
-
Statement type:
File details
Details for the file ansi2micron-1.0.2-py3-none-any.whl.
File metadata
- Download URL: ansi2micron-1.0.2-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74cae49ade71fd322267e4095642d86c54792ec06b87648a6bada4d6d8f5ad25
|
|
| MD5 |
af1e6cba5a7a82c854e9a8e9762ec625
|
|
| BLAKE2b-256 |
d01ece78cac4b5107ef9c52d8442b93ddbbf1dc3d84eeaa0b5a446fb43f8d54f
|
Provenance
The following attestation bundles were made for ansi2micron-1.0.2-py3-none-any.whl:
Publisher:
publish.yml on JamesM92/Ansi2MicronMU
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ansi2micron-1.0.2-py3-none-any.whl -
Subject digest:
74cae49ade71fd322267e4095642d86c54792ec06b87648a6bada4d6d8f5ad25 - Sigstore transparency entry: 1630977413
- Sigstore integration time:
-
Permalink:
JamesM92/Ansi2MicronMU@e3d895a563cce258dceab965b9aa30196de349fa -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/JamesM92
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e3d895a563cce258dceab965b9aa30196de349fa -
Trigger Event:
push
-
Statement type: