text processing utilities

Ansifilter documentation

Ansifilter documentation

ANSI codes are commands embedded in a text stream to add formatting instructions into this text. These codes are interpreted by terminal emulators like xterm or Putty.

An example of the colordiff output:

ANSI sample

Ansifilter parses common ANSI codes to remove them or to convert them to another colored text file format (HTML, TeX, LaTeX, RTF, Pango or BBCode)

Ansifilter GUI Linux

The utility is also available as command line interface:

ansifilter ansifile.txt will give:

Several ANSI codes:
Bold
Underline
Black
Red
Green
Red Background
Green Background
Image inverted and back

ansifilter --html ansifile.txt will give:

Several ANSI codes:
Bold
Underline
Black
Red
Green
Red Background
Green Background
Image inverted and back

Features

These are the options of the command line interface:

File handling:
  -i, --input=<file>     name of single input file
  -o, --output=<file>    name of single output file
  -O, --outdir<dir>      name of output directory
  -t, --tail             Continue reading after end-of-file (like tail -f)
                         Use system tail if available

Output text formats:
  -T, --text (default)   Output text
  -H, --html             Output HTML
  -M, --pango            Output Pango Markup
  -L, --latex            Output LaTeX
  -P, --tex              Output Plain TeX
  -R, --rtf              Output RTF
  -B, --bbcode           Output BBCode

Formatted text options:
  -a, --anchors          add HTML line anchors (assumes -l)
  -d, --doc-title        Set HTML/LaTeX document title
  -e, --encoding         Set HTML encoding (must match input file encoding)
  -f, --fragment         Omit HTML header and footer
  -F, --font=<font>      Set HTML/RTF font face
  -l, --line-numbers     print line numbers in output file
  -m, --map=<path>       read color mapping file (see README)
  -r, --style-ref=<rf>   Set HTML/TeX/LaTeX stylesheet path
  -s, --font-size=<fs>   Set HTML/RTF font size
  -p, --plain            Ignore ANSI formatting information
  -w, --wrap<len>        wrap long lines
      --wrap-no-numbers  omit line numbers of wrapped lines (assumes -l)

Other options:
  -h, --help             Print help
  -v, --version          Print version and license info

Examples:

ansifilter -i text_with_ansi.txt -o text_without_ansi.txt
ansifilter *.txt
tail -f server.log | ansifilter

The GUI version also accepts the first command line argument as input file name.
Ansifilter may simulate tail -f functionality in Windows.

Supported control sequences

Formatting:
Bold, Underline, Italic, Blink

Colors:
Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, xterm 256 color codes

Other:
Conceal/Reveal, Image positive/negative

Color mapping

The basic ANSI color set can be adjusted with a color map file (--map option).
This text configuration overrides these color codes:

Normal: Black (0), Red (1), Green (2), Yellow (3), Blue (4), Magenta (5), 
        Cyan (6), Gray (7)
Bright: DarkGray (8), Red (9), Green (10), Yellow (11), Blue (12), Magenta (13),
        Cyan (14), White (15)

File format: <0..15> = <HTML color code>

Example file content

0 = #0000dd -- set black value to dark blue
1 = #ffff00 -- set red value to yellow
Tupel7