Skip to content

bengarrett/ansibump

Repository files navigation

ANSIbump

Go Reference Go Report Card

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:

Quick usage

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)
}

HTML

ANSIbump will output a <div> "content division" element containing colors, styles, newlines, and text.

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

Not supported or known issues

Sauce metadata

ANSIbump doesn't parse any SAUCE metadata, however this can be done with a separate bengarrett/sauce package.

Important

ANSIbump was initially vibe coded, you can see the original prompt, output, and read of the many needed manual changes.

Similar projects

  • 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.

About

Take ANSI encoded texts and transform them into HTML fragments

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages