Imagine you want to read some logfiles from a UNIX or Linux based program and you get the following:
This is a text file containing ANSI codes, which are used to output formatted text
in UNIX or Linux terminals. This is nice as long as your terminal supports these
codes, but what to do if you use a Windows editor? What to do if the developer
adjusted the colours of the logging output to suit his yellow-on-green coloured terminal, but you
have a black-on-white setup?
You can't solve all problems by installing Cygwin, so ansifilter comes to the rescue:
These screenshots show the Windows and Linux versions of the GUI, which displays a ANSI cluttered file.
Ansifilter strips ANSI codes or converts them to HTML, TeX, LaTeX or RTF, if you want to preserve the formatting information.
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
These are the options of the command line interface:
File handling:
-i, --input=<file> Input file (optional)
-o, --output=<file> Output file (optional)
-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
-L, --latex Output LaTeX
-P, --tex Output Plain TeX
-R, --rtf Output RTF
Formatted text options:
-d, --doc-title Set HTML/LaTeX document title
-e, --encoding Set HTML encoding (must match input file encoding)
-F, --font=<font> Set HTML/RTF font face
-s, --font-size=<fs> Set HTML/RTF font size
-f, --fragment Omit HTML header and footer
-p, --plain Ignore formatting information
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.
Formatting:
Bold, Underline, Italic, Blink
Colors:
Black, Red, Green, Yellow, Blue, Magenta, Cyan, White
Other:
Conceal/Reveal, Image positive/negative