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)

CmdTube is a Python CLI library for searching, downloading, and watching YouTube tutorials

CmdTube is a Python CLI library for searching, downloading, and watching YouTube tutorials. This library was made with programmers in mind and it's dedicated to every programmer who watches YouTube v

Samuel Ayomide Ogunleke 2 Aug 22, 2022
Colors in Terminal - Python Lang

🎨 Colorate - Python 🎨 About Colorate is an Open Source project that makes it easy to use Python color coding in your projects. After downloading the

0110 Henrique 1 Dec 01, 2021
3DigitDev 29 Jan 17, 2022
gget is a free and open-source command-line tool and Python package that enables efficient querying of genomic databases.

gget is a free and open-source command-line tool and Python package that enables efficient querying of genomic databases. gget consists of a collection of separate but interoperable modules, each des

Pachter Lab 570 Dec 29, 2022
Conditional Transformer Language Model for Controllable Generation

CTRL - A Conditional Transformer Language Model for Controllable Generation Authors: Nitish Shirish Keskar, Bryan McCann, Lav Varshney, Caiming Xiong,

Salesforce 1.7k Jan 05, 2023
Gamma ion pump QPC ethernet Python library & CLI utility

Unofficial Gamma ion pump ethernet control CLI utility and library This is a mini Python 3 library and utility that exposes some of the functions of t

2 Jul 18, 2022
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 package to display progress of loops to the user

ProgressBars A python package to display progress of loops to the user. Installation This package can be installed using pip. pip install progressbars

Matthias 3 Jan 16, 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
Darkdump - Search The Deep Web Straight From Your Terminal

Darkdump - Search The Deep Web Straight From Your Terminal About Darkdump Darkdump is a simple script written in Python3.9 in which it allows users to

Josh Schiavone 264 Dec 30, 2022
kitty - the fast, feature-rich, cross-platform, GPU based terminal

kitty - the fast, feature-rich, cross-platform, GPU based terminal

Kovid Goyal 17.3k Jan 04, 2023
Chopper: An Automated Security Headers Analyzer

____ _ _ / ___| |__ ___ _ __ _ __ ___ _ __| | | | | '_ \ / _ \| '_ \| '_ \ / _ \ '__| | | |___| | | | (_) |

Kamran Saifullah (Frog Man) 2 Nov 27, 2022
'rl_UK' is an open-source command-line tool in Python for calculating the shortest path between BUS stop sequences in the UK

'rl_UK' is an open-source command-line tool in Python for calculating the shortest path between BUS stop sequences in the UK. As input files, it uses an ATCO-CIF file and 'OS Open Roads' dataset from

Nesh P. 0 Feb 16, 2022
AML Command Transfer. A lightweight tool to transfer any command line to Azure Machine Learning Services

AML Command Transfer (ACT) ACT is a lightweight tool to transfer any command from the local machine to AML or ITP, both of which are Azure Machine Lea

Microsoft 11 Aug 10, 2022
Konsave lets use save your KDE Plasma customizatios and restore them very easily!

Konsave (Save Plasma Customization) A CLI program that will let you save and apply your KDE Plasma customizations with just one command! Als

439 Jan 02, 2023
A python script that enables a raspberry pi sd card through the CLI and automates the process of configuring network details and ssh.

This project is one script (wpa_helper.py) written in python that will allow for the user to automate the proccess of setting up a new boot disk and configuring ssh and network settings for the pi

Theo Kirby 6 Jun 24, 2021
Pymongo based CLI client, to run operation on existing databases and collections

Mongodb-Operations-Console Pymongo based CLI client, to run operation on existing databases and collections Program developed by Gustavo Wydler Azuaga

Gus 1 Dec 01, 2021
Ipylivebash - Run shell script in Jupyter with live output

ipylivebash ipylivebash is a library to run shell script in Jupyter with live ou

Ben Lau 6 Aug 27, 2022
A simple CLI tool for converting logs from Poker Now games to other formats

🂡 Poker Now Log Converter 🂡 A command line utility for converting logs from Poker Now games to other formats. Introduction Poker Now is a free onlin

6 Dec 23, 2022
The command line interface for Gradient - Gradient is an an end-to-end MLOps platform

Gradient CLI Get started: Create Account • Install CLI • Tutorials • Docs Resources: Website • Blog • Support • Contact Sales Gradient is an an end-to

Paperspace 58 Dec 06, 2022