mkimxboot: add partial support for the Zen X-Fi Style
[maemo-rb.git] / manual / latexfilter.pl
blob45d7cedbdc3ca764e15b048dd3f5f286d46d9d34
1 #!/usr/bin/perl -s
3 # __________ __ ___.
4 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
5 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 # \/ \/ \/ \/ \/
11 my $verbose = $v;
12 my $reflowed = "";
13 my $last = "";
14 my $currentfile;
15 while(<STDIN>) {
16 chomp $_;
17 $reflowed .= $_;
18 if(/^.{79,}$/) {
19 # collapse all "full" lines
21 elsif(/^!/) {
22 # collapse lines indicating an error with next one and append a space.
23 $reflowed .= " ";
25 else {
26 # skip empty lines
27 if(length($reflowed) > 0) {
28 # collapse with previous line if it continues some "area".
29 if($reflowed =~ /^\s*(\]|\[|\\|\)|<)/) {
30 $last .= $reflowed;
32 else {
33 # find current input file
34 my @inputfile = $last =~ /\(([a-zA-Z_\-\/\.]+\.tex)/g;
35 foreach(@inputfile) {
36 if($verbose) {
37 print "\n";
39 print "LaTeX processing $_\n";
40 $currentfile = $_;
42 if($verbose) {
43 print $last;
45 # check for error
46 if($reflowed =~ /^!\s*(.*)/) {
47 my $l = $reflowed;
48 $l =~ s/^!\s*(.*)l.(\d+) /$2: $1/;
49 print "$currentfile:$l\n";
51 # restart for next reflowed line
52 $last = $reflowed;
55 # restart reflowing.
56 $reflowed = "";
59 if($verbose) {
60 print $last;