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)

A 3D engine powered by ASCII art

3D engine powered by ASCII art

Lingdong Huang 48 Nov 16, 2022
MasterDuel Image Recognition Translation Command Line Tool

MasterDuelTranslate(Use Ygo Card DataBase,belong win32 window shot & image match)

PatchouliTC 77 Dec 01, 2022
Enlighten Progress Bar is a console progress bar library for Python.

Overview Enlighten Progress Bar is a console progress bar library for Python. The main advantage of Enlighten is it allows writing to stdout and stder

Rockhopper Technologies 265 Dec 28, 2022
Modern line-oriented terminal emulator without support for TUIs.

Modern line-oriented terminal emulator without support for TUIs.

10 Jun 12, 2022
term2048 is a terminal-based version of 2048.

term2048 is a terminal-based version of 2048.

Baptiste Fontaine 798 Nov 21, 2022
TerminalGV is a very simple client to display stats about your SNCF TGV/TER train in your terminal.

TerminalGV So I got bored in the train, TerminalGV is a very simple client to display stats about your SNCF TGV/TER train in your terminal. The "on-tr

Samuel 8 Dec 15, 2022
A command line interface to interact with the Hypixel api allowing the user to get stats, leaderboards, etc

HyConsole is a way to get data on players and leaderboards from the Hypixel Minecraft server from the command line. Keep in mind I have no a

1 Feb 14, 2022
Bear-Shell is a shell based in the terminal or command prompt.

Bear-Shell is a shell based in the terminal or command prompt. You can navigate files, run python files, create files via the BearUtils text editor, and a lot more coming up!

MichaelBear 6 Dec 25, 2021
Tmux Based Dropdown Dashboard For Python

sextans It's a private configuration and an ongoing experiment while I use Archlinux. A simple drop down dashboard based on tmux. It includes followin

秋葉 4 Dec 22, 2021
Python commandline tool for remembering linux/terminal commands

ehh Remember linux commands Commandline tool for remembering linux/terminal commands. It stores your favorite commands in ~/ehh.json in your homedir a

56 Nov 10, 2022
Python3 command-line tool for the inference of Boolean rules and pathway analysis on omics data

BONITA-Python3 BONITA was originally written in Python 2 and tested with Python 2-compatible packages. This version of the packages ports BONITA to Py

1 Dec 22, 2021
A Python3 rewrite of my original PwnedConsole project from almost a decade ago

PwnedConsoleX A CLI shell for performing queries against the HaveIBeenPwned? API to gather breach information for user-supplied email addresses. | wri

1 Jul 23, 2022
Fylm is a wonderful automated command line app for organizing your film media.

Overview Fylm is a wonderful automated command line app for organizing your film media. You can pronounce it Film or File 'em, whichever you like! It

Brandon Shelley 30 Dec 05, 2022
triggercmd is a CLI client for the TRIGGERcmd cloud service.

TriggerCMD CLI client triggercmd is a CLI client for the TRIGGERcmd cloud service. installation the triggercmd package is available in PyPI. to instal

Gustavo Soares 7 Oct 18, 2022
🖍️This is a feature-complete clone of the awesome Chalk (JavaScript) library.

Terminal string styling done right This is a feature-complete clone of the awesome Chalk (JavaScript) library. All credits go to Sindre Sorhus. Highli

Fabian Keller 132 Dec 27, 2022
Official AIdea command line tool

AIdea CLI Official AIdea command line tool for https://aidea-web.tw. Installation Make sure you have installed both Python 3 and pip package manager.

AIdea 5 Dec 15, 2021
A command line tool to hide and reveal information inside images (works for both PNGs and JPGs)

Imgrerite A command line tool to hide and reveal information inside images (works for both PNGs and JPGs) Dependencies Python 3 Git Most of the Linux

Jigyasu 10 Jul 27, 2022
Gitfetch is a simple tool to get github user details

Gitfetch Just a (cli?) tool to get github user details 🙂 Installation 📂 Install Gitfetch via pypi pip install gitfetch or pip install git+https://g

I'm Not A Bot #Left_TG 7 Jan 23, 2022
A very simple OpenContest command line client written in Python

OpenContest Client A very simple OpenContest command line client written in Python. The only dependency is the requests library. Tested with Linux onl

Ladue Computer Science 1 May 25, 2022
A basic molecule viewer written in Python, using curses; Thus, meant for linux terminals

asciiMOL A basic molecule viewer written in Python, using curses; Thus, meant for linux terminals. This is an alpha version, featuring: Opening defaul

Dominik Behrens 328 Dec 11, 2022