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 5a1e585..cfe43b0 100644
--- a/manual/LaTeX.Rules
+++ b/manual/LaTeX.Rules
@@ -119,6 +119,14 @@ OTHER_FILES := $(DOCUMENT).blg $(DOCUMENT).log $(DOCUMENT).out
INDEX_ARGS := -s mkidx.ist
LATEXOPTS := -interaction=nonstopmode
+# program to pipe stdout through. Note: this needs to start with a pipe symbol
+# to not make the command fail if no filter is defined.
+ifndef V
+LATEXFILTER := | ./latexfilter.pl
+else
+LATEXFILTER := | ./latexfilter.pl -v
+endif
+
# grab the contents of \bibliograph{} commands
ifeq ($(BIB_FILES),)
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
makeobsolete() { touch -r $$(ls *.old | tail -n 1) $${1} ; true ; } ; \
nochange() { for file ; do [ ! -f $${1} ] || cmp $${1} $${1}.old >/dev/null || return ; done ; true ; } ; \
saveold $(MONITOR_FILES) ; \
- if $(LATEX) $(LATEXOPTS) $* ; then \
+ if $(LATEX) $(LATEXOPTS) $* $(LATEXFILTER) ; then \
if nochange $(MONITOR_FILES) ; then \
echo "$(MAKE): LaTeX auxiliary files did not change (processing is complete)" ; \
restoreold $(MONITOR_FILES) ; \
@@ -267,7 +275,7 @@ $(PDF_FILE) : %.pdf : $(TEX_FILES) $(MONITOR_FILES) $(GRAPHIC_FILES) $(XFIG_TEX)
#
%.aux %.idx : $(XFIG_TEX)
- $(LATEX) $(LATEXOPTS) $*
+ $(LATEX) $(LATEXOPTS) $* $(LATEXFILTER)
#
# 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 0000000..45d7ced
--- /dev/null
+++ b/manual/latexfilter.pl
@@ -0,0 +1,62 @@
+#!/usr/bin/perl -s
+#
+# __________ __ ___.
+# Open \______ \ ____ ____ | | _\_ |__ _______ ___
+# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+# \/ \/ \/ \/ \/
+#
+
+my $verbose = $v;
+my $reflowed = "";
+my $last = "";
+my $currentfile;
+while(<STDIN>) {
+ chomp $_;
+ $reflowed .= $_;
+ if(/^.{79,}$/) {
+ # collapse all "full" lines
+ }
+ elsif(/^!/) {
+ # collapse lines indicating an error with next one and append a space.
+ $reflowed .= " ";
+ }
+ else {
+ # skip empty lines
+ if(length($reflowed) > 0) {
+ # collapse with previous line if it continues some "area".
+ if($reflowed =~ /^\s*(\]|\[|\\|\)|<)/) {
+ $last .= $reflowed;
+ }
+ else {
+ # find current input file
+ my @inputfile = $last =~ /\(([a-zA-Z_\-\/\.]+\.tex)/g;
+ foreach(@inputfile) {
+ if($verbose) {
+ print "\n";
+ }
+ print "LaTeX processing $_\n";
+ $currentfile = $_;
+ }
+ if($verbose) {
+ print $last;
+ }
+ # check for error
+ if($reflowed =~ /^!\s*(.*)/) {
+ my $l = $reflowed;
+ $l =~ s/^!\s*(.*)l.(\d+) /$2: $1/;
+ print "$currentfile:$l\n";
+ }
+ # restart for next reflowed line
+ $last = $reflowed;
+ }
+ }
+ # restart reflowing.
+ $reflowed = "";
+ }
+}
+if($verbose) {
+ print $last;
+}
+