# site: http://www.geek-blog.de/projekte/bash2html
# copyright: licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
# (see http://creativecommons.org/licenses/by-nc-sa/3.0/)
# version: 0.1
# convert alternative represantation of the escape code to
s/\[\\033//g
# get rid of unnecessary closing brackets
s/\\\?\]//g
# get rid of all remaining escape backslashes
s/\\//g
# start conversion to html
s/^\[00m/\n/;
# set foreground colors and insert markers for background and brightness
s/\[\(0[10]\)\?;\?30;\?\([0-9][0-9]\)\?m//g;
s/\[\(0[10]\)\?;\?31;\?\([0-9][0-9]\)\?m//g;
s/\[\(0[10]\)\?;\?32;\?\([0-9][0-9]\)\?m//g;
s/\[\(0[10]\)\?;\?33;\?\([0-9][0-9]\)\?m//g;
s/\[\(0[10]\)\?;\?34;\?\([0-9][0-9]\)\?m//g;
s/\[\(0[10]\)\?;\?35;\?\([0-9][0-9]\)\?m//g;
s/\[\(0[10]\)\?;\?36;\?\([0-9][0-9]\)\?m//g;
s/\[\(0[10]\)\?;\?37;\?\([0-9][0-9]\)\?m//g;
s/\[00m/<\/span>/g;
# replace markers for background colors
s/MARK_BG:40//g
s/MARK_BG:41/background-color: Red;/g
s/MARK_BG:42/background-color: Lime;/g
s/MARK_BG:43/background-color: Yellow;/g
s/MARK_BG:44/background-color: Blue;/g
s/MARK_BG:45/background-color: Fuchsia;/g
s/MARK_BG:46/background-color: Aqua;/g
s/MARK_BG:47/background-color: White;/g
# replace markers for bright/dull
s/MARK_BRIGHT:00//g
s/MARK_BRIGHT:01Black/Gray/g
s/MARK_BRIGHT:01Maroon/Red/g
s/MARK_BRIGHT:01Green/Lime/g
s/MARK_BRIGHT:01Olive/Yellow/g
s/MARK_BRIGHT:01Navy/Blue/g
s/MARK_BRIGHT:01Purple/Fuchsia/g
s/MARK_BRIGHT:01Teal/Aqua/g
s/MARK_BRIGHT:01Silver/White/g
# remove leftovers
s/MARK_BRIGHT://g
s/MARK_BG://g
s/ \"/\"/g
s/^\[m/<\/pre>\n/;
p;