initial ordering of the transforms
[pipstransfo.git] / bin / latex-colorize
1 #!/bin/bash
2
3 COLOR_ERROR='01;31'
4 COLOR_WARNING='01;33'
5 COLOR_OUTPUT='01;32'
6
7 PCRE_ERROR='(^[^:]*:\d+: )|(^l\.\d+ )|(^! LaTeX Error: )'
8 PCRE_WARNING='(LaTeX Warning(:|))|(Package [^\s]+ Warning(:|))'
9 PCRE_OUTPUT='^Output written on .*\.pdf \(.*\)\.$'
10
11 if [ -t 1 ]; then
12 ($* -file-line-error 2>&1) | perl -pe "s/${PCRE_ERROR}/\033[${COLOR_ERROR}m\$&\033[0m/gs;s/${PCRE_WARNING}/\033[${COLOR_WARNING}m\$&\033[0m/gs;s/${PCRE_OUTPUT}/\033[${COLOR_OUTPUT}m\$&\033[0m/gs"
13 else
14 $*
15 fi