summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manual/LaTeX.Rules12
-rwxr-xr-xmanual/latexfilter.pl62
2 files changed, 72 insertions, 2 deletions
diff --git a/manual/LaTeX.Rules b/manual/LaTeX.Rules
index 5a1e58589a..cfe43b055c 100644
--- a/manual/LaTeX.Rules
+++ b/manual/LaTeX.Rules
@@ -119,6 +119,14 @@ OTHER_FILES := $(DOCUMENT).blg $(DOCUMENT).log $(DOCUMENT).out
119INDEX_ARGS := -s mkidx.ist 119INDEX_ARGS := -s mkidx.ist
120LATEXOPTS := -interaction=nonstopmode 120LATEXOPTS := -interaction=nonstopmode
121 121
122# program to pipe stdout through. Note: this needs to start with a pipe symbol
123# to not make the command fail if no filter is defined.
124ifndef V
125LATEXFILTER := | ./latexfilter.pl
126else
127LATEXFILTER := | ./latexfilter.pl -v
128endif
129
122# grab the contents of \bibliograph{} commands 130# grab the contents of \bibliograph{} commands
123ifeq ($(BIB_FILES),) 131ifeq ($(BIB_FILES),)
124 BIB_FILES := $(shell for source in $(TEX_FILES) ; do sed -e '{' -e 'y/,/ /' -e 's?.*\\bibliography[{]\(.*\)[}].*?\1?' -e 't' -e 'd' -e '}' <$$source ; done) 132 BIB_FILES := $(shell for source in $(TEX_FILES) ; do sed -e '{' -e 'y/,/ /' -e 's?.*\\bibliography[{]\(.*\)[}].*?\1?' -e 't' -e 'd' -e '}' <$$source ; done)
@@ -222,7 +230,7 @@ define run-latex
222 makeobsolete() { touch -r $$(ls *.old | tail -n 1) $${1} ; true ; } ; \ 230 makeobsolete() { touch -r $$(ls *.old | tail -n 1) $${1} ; true ; } ; \
223 nochange() { for file ; do [ ! -f $${1} ] || cmp $${1} $${1}.old >/dev/null || return ; done ; true ; } ; \ 231 nochange() { for file ; do [ ! -f $${1} ] || cmp $${1} $${1}.old >/dev/null || return ; done ; true ; } ; \
224 saveold $(MONITOR_FILES) ; \ 232 saveold $(MONITOR_FILES) ; \
225 if $(LATEX) $(LATEXOPTS) $* ; then \ 233 if $(LATEX) $(LATEXOPTS) $* $(LATEXFILTER) ; then \
226 if nochange $(MONITOR_FILES) ; then \ 234 if nochange $(MONITOR_FILES) ; then \
227 echo "$(MAKE): LaTeX auxiliary files did not change (processing is complete)" ; \ 235 echo "$(MAKE): LaTeX auxiliary files did not change (processing is complete)" ; \
228 restoreold $(MONITOR_FILES) ; \ 236 restoreold $(MONITOR_FILES) ; \
@@ -267,7 +275,7 @@ $(PDF_FILE) : %.pdf : $(TEX_FILES) $(MONITOR_FILES) $(GRAPHIC_FILES) $(XFIG_TEX)
267# 275#
268 276
269%.aux %.idx : $(XFIG_TEX) 277%.aux %.idx : $(XFIG_TEX)
270 $(LATEX) $(LATEXOPTS) $* 278 $(LATEX) $(LATEXOPTS) $* $(LATEXFILTER)
271 279
272# 280#
273# Distill xfig .fig files into .fig.tex and either .fig.pdf or .fig.ps 281# Distill xfig .fig files into .fig.tex and either .fig.pdf or .fig.ps
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
11my $verbose = $v;
12my $reflowed = "";
13my $last = "";
14my $currentfile;
15while(<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}
59if($verbose) {
60 print $last;
61}
62