LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

aha

Convert ANSI escape sequences to HTML

TLDR

Convert colored terminal output to HTML
$ ls --color=always | aha > ls.html
copy
Convert a man page (preserving formatting) to HTML
$ MAN_KEEP_FORMATTING=1 man command | ul | aha > man.html
copy
Convert from a file with black background and title
$ aha -f input.txt --black --title "My Log" > output.html
copy
Handle cursor-position sequences (e.g. htop)
$ echo q | htop | aha --black --line-fix > htop.html
copy
Add custom CSS and enable word wrap
$ command | aha --css style.css --word-wrap > output.html
copy
Use pink background
$ command | aha --pink > output.html
copy

SYNOPSIS

aha [options] [-f file]

DESCRIPTION

aha (Ansi HTML Adapter) reads text containing ANSI SGR escape sequences (colors, bold, underline, etc.) from a file or stdin and writes a complete, standards-compliant HTML document to stdout.It is commonly used to publish colored terminal sessions, diffs, logs, or interactive tool output (htop, git, ls --color, etc.) on the web while preserving the original appearance.aha supports several output customizations such as forcing a black or pink background, setting the HTML document title, injecting an external CSS stylesheet, enabling word-wrap, and emitting stylesheet-based styles instead of inline styles.

PARAMETERS

-f, --file file

Read input from file instead of stdin.
-b, --black
Use a black background with white text.
-p, --pink
Use a pink background.
-t, --title title
Set the HTML `<title>` (default: stdin or the input filename).
-c, --css file
Link an external CSS stylesheet (`<link rel="stylesheet" href="...">`).
-s, --stylesheet
Use a stylesheet instead of inline styles.
-w, --word-wrap
Enable word wrapping to avoid horizontal scrollbars.
-l, --line-fix
Fix inputs that use control sequences to change the cursor position (needed for tools like htop). Hot fix; may not work with every program.
-n, --no-header
Do not wrap output in `<html>`, `<head>`, and `<body>` tags.
-r, --ignore-cr
Ignore carriage returns (`\r`), which may otherwise produce double newlines in HTML.
-i, --iso X
Use ISO-8859-X (1–16) instead of UTF-8 for the output.
-y, --style STYLE
Append STYLE to the `<body>` element style after other style parameters.
-L, --lang LANG
Set the document language to ISO-639-1 code LANG.
-x, --no-xml
Use HTML doctype instead of XML (may help older browsers).
-v, --version
Print version number and exit.
-h, --help
Show help.

CAVEATS

For tools that change output based on whether stdout is a tty (e.g. `ls`, `grep`), you must force color with flags such as `--color=always`.Some programs (htop, man) emit additional control sequences; piping through `ul` or using `--line-fix` may be required for best results. Blinking text needs `--stylesheet` and a custom `.blink` CSS class on modern browsers.

SEE ALSO

ul(1)

RESOURCES

Copied to clipboard
Kai