ANSIbump takes texts encoded with ANSI escape codes and transforms it into a HTML fragment for use in a template or webpage.
See the reference documentation for usage, and examples, including changing the character sets and the color palette.
ANSIbump was created for and is in use on the website archive Defacto2, home to thousands of ANSI texts and artworks that are now rendered in HTML.
Some ANSI highlights that are rendered by ANSIbump:
- The Game Gallery BBS ad from 1985 that's an ANSI rendition of Pacman.
- Epsilon Nine BBS ad from 1990 of an orbiting space station.
- Bart Simpson was a popular subject in 1991.
- Comic character drawings were very popular in the 1990s.
package main
import (
"log"
"os"
"github.com/bengarrett/ansibump"
)
func main() {
file, _ := os.Open("file.ans")
defer file.Close()
const columns = 80
_, _ = ansibump.WriteTo(file, os.Stdout, columns)
}ANSIbump will output a <div> "content division" element containing colors, styles, newlines, and text.
- The div element should be used within a
<pre>"preformatted text" element. - Most ANSI text will want a custom monospaced font, Cascadia Mono handles all the CodePage 437 characters.
- Or use the IBM VGA font for a more authentic recreation,
either font will require a CSS
@font-facerule andfont-familyproperty.
<html>
<head>
<title>Quick usage</title>
</head>
<style>
@font-face {
font-family: cascadia-mono;
src: url(CascadiaMono.woff2) format("woff2");
}
pre {
font-family: cascadia-mono, monospace, serif;
}
</style>
<body>
<pre><!--- ansibump output ---><div style="color:#aaa;background-color:#000;"> <span style="color:#a50;background-color:#0a0;">HI‼︎</span> </div>
</pre>
</body>
</html>- ANSI.SYS blinking, for example. CSS blinking uses a lot of boilerplate for each color.
- No auto-detection for system and programming controls, example.
ANSIbump doesn't parse any SAUCE metadata, however this can be done with a separate bengarrett/sauce package.
ANSIbump was initially vibe coded, you can see the original prompt, output, and read of the many needed manual changes.
- Deark is a utility that can output ANSI to HTML or an image.
- ansipants a Python module and utility for converting ANSI art to HTML.
- RetroTxt a web browser extension that renders ANSI as HTML in a tab.
- Ansilove is a collection of tools to convert ANSI to images.
- Ultimate Oldschool PC Font Pack offers various retro DOS and PC fonts.