A Python module and command-line utility for converting .ANS format ANSI art to HTML

Overview

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 such as

...
. 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, 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 be cp437.
  • width - the number of columns the text should wrap at
  • strict - If True, the decoder will raise an ansipants.ANSIDecodeError exception 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 [email protected]

You might also like...
Create animated ASCII-art for the command line almost instantly!
Create animated ASCII-art for the command line almost instantly!

clippy Create and play colored πŸŸ₯ 🟩 🟦 or colorless ⬛️ ⬜️ animated, or static, ASCII-art in the command line! clippy can help if you are wanting to;

A command line utility to export Google Keep notes to markdown.

Keep-Exporter A command line utility to export Google Keep notes to markdown files with metadata stored as a frontmatter header. Supports exporting: S

A command line utility for tracking a stock market portfolio. Primarily featuring high resolution braille graphs.
A command line utility for tracking a stock market portfolio. Primarily featuring high resolution braille graphs.

A command line stock market / portfolio tracker originally insipred by Ericm's Stonks program, featuring unicode for incredibly high detailed graphs even in a terminal.

πŸ“¦ A command line utility to put text in a box.
πŸ“¦ A command line utility to put text in a box.

boxie A command line utility to put text in a box. Installation pip install boxie If you are on Linux you may need to use sudo to access this globally

Tiny command-line utility for mapping broken keys to other positions.

brokenkey Tiny command-line utility for mapping broken keys to other positions. Installation Clone this repository using git: git clone https://github

This is a CLI utility that allows you to view RedFlagDeals.com on the command line.
This is a CLI utility that allows you to view RedFlagDeals.com on the command line.

RFD Description Motivation Installation Usage View Hot Deals View and Sort Hot Deals Search Advanced View Posts Shell Completion bash zsh Description

img-proof (IPA) provides a command line utility to test images in the Public Cloud

overview img-proof (IPA) provides a command line utility to test images in the Public Cloud (AWS, Azure, GCE, etc.). With img-proof you can now test c

A command-line utility that, given a markdown file, checks whether all its links work.

A command-line utility written in Python that checks validity of links in a markdown file.

Booky - A command line utility for bookmarking files on your terminal!

Booky A command line utility for bookmarking files for quick access With it you can: Bookmark and delete your (aliases of) files at demand Launch them

Comments
  • Underline control codes not supported

    Underline control codes not supported

    In the new ansi renderer, what I call "Amiga ansi" - escape codes used in Amiga specific text files are not rendered correctly. Even the Windows commandline does a decent job of this, so perhaps it is possible/relatively easy to implement?

    Windows 11 command line:

    image

    Demozoo currently:

    image

    Native Amiga:

    image

    opened by glennlunder 4
  • Something wrong with newlines locations

    Something wrong with newlines locations

    There are some files with mystically wrong newlines locations. Especially, for this board.

    For example, there's a file called HOLIC5.ANS. It currently looks in Demozoo like this: ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅_2021-12-28_223312

    However, BedroomLAN's converter can't render it at all for the unknown reason: HOLIC5

    But there are some images from Defacto2, 16colors and other Ansilove-based resources, included Ansilove itself, where everything is totally fine: image (this image took from Defacto2, there're some extra lines in the end of the file but the other part looks as it should)

    Everything is also OK with the 'type' tool in Windows 10 (I'm sorry for this highlighted 'A'): image

    According on 16colors, this isn't an ansimation. When I'm trying to understand how the code works, there's some code between the latest 'Β·' and 'β–ˆβ–€β–€β–€β–ˆ' which is the top of the word "BBS":   where  is an escape symbol.

    There are some known codes for me -  is a blue text,  and  are something like cursor position manipulations. BUT  is @!#?@!. There are at least 7 matches of [2 in this file, but no one gives me any idea what it should be.

    There are some more examples in the same BBS. All raw files are available in Defacto2 (MAY BE NSFW).

    opened by m100bit 0
Releases(v0.1.2)
  • v0.1.2(Dec 20, 2021)

  • v0.1.1(Dec 6, 2021)

    • Add support for printable characters with codepoints < 0x20
    • Implement escape sequences for save/restore cursor
    • Fix: Use correct colour palette as per http://answers.google.com/answers/threadview/id/126097.html
    • Fix: Bright flag should not apply to background colour
    • Fix: Fix 'move cursor' escape sequence to be 1-based rather than 0-based
    Source code(tar.gz)
    Source code(zip)
  • v0.1(Dec 6, 2021)

Alacritty terminal used with Bash, Tmux, Vim, Mutt, Lynx, etc. and the many different additions added to each configuration file

Alacritty terminal used with Bash, Tmux, Vim, Mutt, Lynx, etc. and the many different additions added to each configuration file

Carter 19 Aug 24, 2022
(BionicLambda Universal SHell) A simple shell made in Python. Docs and possible C port incoming.

blush 😳 (BionicLambda Universal SHell) A simple shell made in Python. Docs and possible C port incoming. Note: The Linux executables were made on Ubu

3 Jun 30, 2021
Dart Version Manager CLI implemented with Python and Typer.

Dart Version Manager Dart Version Manager CLI implemented with Python and Typer Usage: $ dvm [OPTIONS] COMMAND [ARGS]... Options: --install-completion

EducUp 6 Jun 26, 2022
🌈 Lightweight Python package that makes it easy and fast to print terminal messages in colors. 🌈

🌈 Colorist for Python 🌈 Lightweight Python package that makes it easy and fast to print terminal messages in colors. Prerequisites Python 3.9 or hig

Jakob Bagterp 1 Feb 05, 2022
Helping you manage your data science projects sanely.

PyDS CLI Helping you manage your data science projects sanely. Requirements Anaconda/Miniconda/Miniforge/Mambaforge (Mambaforge recommended!) git on y

Eric Ma 16 Apr 25, 2022
πŸ’» Physics2Calculator - A simple and powerful calculator for Physics 2

πŸ’» Physics2Calculator A simple and powerful calculator for Physics 2 πŸ”Œ Predefined constants pi = 3.14159... k = 8988000000 (coulomb constant) e0 = 8.

Dylan Tintenfich 4 Dec 01, 2021
Open-Source Python CLI package for copying DynamoDB tables and items in parallel batch processing + query natural & Global Secondary Indexes (GSIs)

Python Command-Line Interface Package to copy Dynamodb data in parallel batch processing + query natural & Global Secondary Indexes (GSIs).

1 Oct 31, 2021
MiShell is a multi-platform, multi-architecture project based on the first version (MiShell32)

MiShell is a multi-platform, multi-architecture project based on the first version (MiShell32), which offers super super small reverse shell payloads great for injection in buffer overflow vulnerabil

Kamyar Hatamnezhad 0 Oct 27, 2022
Simple tool, to update linux kernel on ubuntu

Kerbswap Simple tool, to update linux kernel on ubuntu Information At the moment, this tool only supports "Ubuntu" distributions, but will be expanded

dword 1 Oct 31, 2021
Terminal-based keyboard testing

kbdtest kbdtest is a simple Python program that tests keyboard input using an interactive, terminal-based, visual keyboard display. It was originally

Ruunyox 12 Jul 19, 2022
YouCompleteMe: a code-completion engine for Vim

YouCompleteMe: a code-completion engine for Vim Help, Advice, Support Looking for help, advice or support? Having problems getting YCM to work? First

24.5k Jan 06, 2023
A command line tool made in Python for the popular rhythm game

osr!name A command line tool made in Python for the popular rhythm game "osu!" that changes the player name of a .osr file (replay file). Example: Not

2 Dec 28, 2021
A Python-based Wordle solver and CLI player

Wordle A Python-based Wordle solver and CLI player This was created using Python 3.9.7. SPOILER ALERT: the data directory contains spoilers for upcomi

Will Fitzgerald 1 Jul 24, 2022
A python-based terminal application that displays current cryptocurrency prices

CryptoAssetPrices A python-based terminal application that displays current cryptocurrency prices. Covered Cryptocurrencies Bitcoin (BTC) Ethereum (ET

3 Apr 21, 2022
A simple python application for running a CI pipeline locally

A simple python application for running a CI pipeline locally This app currently supports GitLab CI scripts

Tom Stowe 0 Jan 11, 2022
LSD (Linux Spotify Downloader) is a command line tool for downloading or rather recording content on Spotify.

LSD (Linux Spotify Downloader) is a command line tool for downloading or rather recording content on Spotify.

Jannis Zahn 7 Jun 21, 2022
TUIFIManager - A cross-platform terminal-based file manager

TUIFI Manager A cross-platform terminal-based file manager (and component), mean

142 Dec 26, 2022
Command line parser for common log format (Nginx default).

Command line parser for common log format (Nginx default).

Lucian Marin 138 Dec 19, 2022
Present - A terminal-based presentation tool with colors and effects.

present A terminal-based presentation tool with colors and effects. You can also play a codio (pre-recorded code block) on a slide. present is built o

Vinayak Mehta 4.2k Jan 03, 2023
Fetch is use to get information about anything on the shell using Wikipedia.

Fetch Search wikipedia article on command line [Why This?] [Support the Project] [Installation] [Configuration] Why this? Fetch helps you to quickly l

Yash Singh 340 Dec 18, 2022