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)

Objexplore is an interactive Python object explorer for the terminal.

Objexplore is an interactive Python object explorer for the terminal. Use it while debugging, or exploring a new library, or whatever! 9D1FAC73-B2A5-4

kylepollina 249 Dec 23, 2022
GitFun - A Simplified Automated CLI tool for GIT😃

GitFun A Simplified Automated CLI tool for GIT, It's for Lazy Developers and Newbies 😜 Table of contents GitFun Installation Usage Development Contri

Astaqc 8 Feb 22, 2022
Euporie is a text-based user interface for running and editing Jupyter notebooks

Euporie is a text-based user interface for running and editing Jupyter notebooks

781 Jan 01, 2023
Set of scripts & tools for converting between numbers and major system encoded words.

major-system-converter Set of scripts & tools for converting between numbers and major system encoded words. Uses phonetics instead of letters to conv

4 Aug 09, 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
Display Images in your terminal with python

A python library to display images in the terminal

Pranav Baburaj 57 Dec 30, 2022
A command line tool to remove background from video and image

A command line tool to remove background from video and image, brought to you by BackgroundRemover.app which is an app made by nadermx powered by this tool

Johnathan Nader 1.7k Jan 01, 2023
Write Django management command using the click CLI library

Django Click Project information: Automated code metrics: django-click is a library to easily write Django management commands using the click command

Jonathan Stoppani 215 Dec 19, 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
A CLI Spigot plugin manager that adheres to Unix conventions and Python best practices.

Spud A cross-platform, Spigot plugin manager that adheres to the Unix philosophy and Python best practices. Some focuses of the project are: Easy and

Tommy Dougiamas 9 Dec 02, 2022
tox-server is a command line tool which runs tox in a loop and calls it with commands from a remote CLI.

Tox Server tox-server is a command line tool which runs tox in a loop and calls it with commands from a remote CLI. It responds to commands via ZeroMQ

Alexander Rudy 3 Jan 10, 2022
Automaton - python script to execute bash command based on changes in size of a file.

automaton python script to execute given command = everytime size of a given file changes,hence everytime a file is modified.(almost) download automa

asrar bhat 1 Jan 03, 2022
Convert ACSM files to DRM-free EPUB files with one command on Linux

Knock Convert ACSM files to DRM-free EPUB files using one command. This software does not utilize Adobe Digital Editions nor Wine. It is completely fr

Benton Edmondson 622 Dec 09, 2022
The project help you to quickly build layouts in terminal,cross-platform

The project help you to quickly build layouts in terminal,cross-platform

gojuukaze 133 Nov 30, 2022
QueraToCSV is a simple python CLI project to convert the Quera results file into CSV files.

Quera is an Iranian Learning management system (LMS) that has an online judge for programming languages. Some Iranian universities use it to automate the evaluation of programming assignments.

Amirmahdi Namjoo 16 Nov 11, 2022
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie

HTTPie: human-friendly CLI HTTP client for the API era HTTPie (pronounced aitch-tee-tee-pie) is a command-line HTTP client. Its goal is to make CLI in

HTTPie 25.4k Dec 30, 2022
Cek Username IG Yang Masih Bisa Dipake

Cek Username IG Cara Install $ pkg update && pkg upgrade $ pkg install python $ pkg install git $ git clone https://github.com/Dekusec/ig-checker $ cd

Deku 3 Nov 28, 2021
dsub is a command-line tool that makes it easy to submit and run batch scripts in the cloud.

Open-source command-line tool to run batch computing tasks and workflows on backend services such as Google Cloud.

Data Biosphere 233 Jan 01, 2023
Ntfy - 🖥️📱🔔 A utility for sending notifications, on demand and when commands finish.

About ntfy ntfy brings notification to your shell. It can automatically provide desktop notifications when long running commands finish or it can send

Daniel Schep 4.5k Jan 01, 2023
telescope.nvim is a highly extendable fuzzy finder over lists.

telescope.nvim is a highly extendable fuzzy finder over lists. Built on the latest awesome features from neovim core. Telescope is centered around modularity, allowing for easy customization.

nvim-telescope 8.4k Jan 05, 2023