Skip to content

Commit

Permalink
Improve color mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
kpj committed Aug 11, 2015
1 parent 1a85ace commit e848ae7
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions lib/LaTeXML/Common/Error.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,22 @@ our @EXPORT = (
$Term::ANSIColor::AUTORESET = 1;
our $COLORIZED_LOGGING = 1;

sub bold_red { BOLD RED shift; }
our %color_scheme = (
details => \&BOLD,
success => \&GREEN,
info => \&BLUE,
warning => \&YELLOW,
error => \&RED,
fatal => \&bold_red
);

sub colorizeString {
my ($string, $alias) = @_;
return $string unless $COLORIZED_LOGGING;

if ($alias eq 'details') {
return BOLD $string; }
elsif ($alias eq 'success') {
return GREEN $string; }
elsif ($alias eq 'info') {
return BLUE $string; }
elsif ($alias eq 'warning') {
return YELLOW $string; }
elsif ($alias eq 'error') {
return RED $string; }
elsif ($alias eq 'fatal') {
return BOLD RED $string; }
else {
return $string; } }
my $spec = $color_scheme{$alias};
return (ref $spec) ? $spec->($string) : &$spec($string); }

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Note: The exported symbols should ultimately be exported as part
Expand Down

0 comments on commit e848ae7

Please sign in to comment.