#!/usr/bin/perl -w

my $escape = !@ARGV;

# fg: 3x bg: 4x
# black: 0
# red:   1
# green: 2
# yellow:3
# blue:  4
# purple:5
# cyan:  6
# white: 7

#            en dis able
# bold:      1  22
# underline: 4  24
# flash:     5  25
# inverse:   7  27

#%coltab_orig = qw(m 2  p 2  M 1  U 5  D 3);
  
# using bold and fgcolor==bgcolor causes ugly colors on OSX Terminal.app

%coltab = qw(m 2  p 2  M 1  U 5  D 4);
while (<DATA>) {
  if ($. < 6 or $. > 8) {
    s/\b([mpMUD])(\1*)\b/\c[[3$coltab{$1}m$1$2\c[[0m/g;
  } else {
    s/\b([mpMUD])(\1*)\b/\c[[3$coltab{$1};4$coltab{$1}m$1$2\c[[0m/g;
  }
  s/\c[/\\c[/g if $escape;
  s/\@/\\\@/g if $escape;
  print;
}
#2345678901234567890123456789012345678901234567890123456789012345678901234567890
__DATA__
 _________________________________ Welcome To _________________________________
 
                                   MMMM       MMMM UUUU      UUUU DDDDDDDDDD
                                   MMMMM     MMMMM UUUU      UUUU DDDDDDDDDDD
 mmmmmmmmmmmmmmmmm   pppppppppp    MMMMMM   MMMMMM UUUU      UUUU DDDD    DDDD
 mmmmmmmmmmmmmmmmmm  ppppppppppp   MMM MMM MMM MMM UUUU      UUUU DDDD     DDDD
 mmmm   mmmm   mmmm  pppp    pppp  MMM  MMMMM  MMM UUUU      UUUU DDDD     DDDD
 mmmm   mmmm   mmmm  pppp    pppp  MMM   MMM   MMM UUUU      UUUU DDDD     DDDD
 mmmm   mmmm   mmmm  pppp    pppp  MMM    M    MMM  UUUU    UUUU  DDDD    DDDD
 mmmm   mmmm   mmmm  ppppppppppp   MMM         MMM   UUUUUUUUUU   DDDDDDDDDDD
 mmmm   mmmm   mmmm  pppppppppp    MMM         MMM     UUUUUU     DDDDDDDDDD
                     pppp
                     pppp                               Created by Kevin Reid
                     pppp                                   <kpreid@kagi.com>
 ______________________________________________________________________________
