diff options
Diffstat (limited to 'manual/latexfilter.pl')
-rwxr-xr-x | manual/latexfilter.pl | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/manual/latexfilter.pl b/manual/latexfilter.pl new file mode 100755 index 0000000000..45d7cedbdc --- /dev/null +++ b/manual/latexfilter.pl | |||
@@ -0,0 +1,62 @@ | |||
1 | #!/usr/bin/perl -s | ||
2 | # | ||
3 | # __________ __ ___. | ||
4 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
5 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
6 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
7 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
8 | # \/ \/ \/ \/ \/ | ||
9 | # | ||
10 | |||
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 | ||
20 | } | ||
21 | elsif(/^!/) { | ||
22 | # collapse lines indicating an error with next one and append a space. | ||
23 | $reflowed .= " "; | ||
24 | } | ||
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; | ||
31 | } | ||
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"; | ||
38 | } | ||
39 | print "LaTeX processing $_\n"; | ||
40 | $currentfile = $_; | ||
41 | } | ||
42 | if($verbose) { | ||
43 | print $last; | ||
44 | } | ||
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"; | ||
50 | } | ||
51 | # restart for next reflowed line | ||
52 | $last = $reflowed; | ||
53 | } | ||
54 | } | ||
55 | # restart reflowing. | ||
56 | $reflowed = ""; | ||
57 | } | ||
58 | } | ||
59 | if($verbose) { | ||
60 | print $last; | ||
61 | } | ||
62 | |||