blob: ce67a42e3e1a33df3b5bf8e1e4d02e7968c0d8c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
use strict;
my $lstlisting=0;
while (<>) {
my $line = $_;
if (m/%DIFDELCMD\s+<\s+\\begin\{lstlisting\}/) {
$lstlisting=1;
$line =~s/%DIFDELCMD\s+</{\\lstset{escapechar=\\\$} /;
}
if ($lstlisting) {
$line =~ s/%DIFDELCMD\s+< //;
if (not $line =~ m/\\(?:begin|end)\{lstlisting\}/) {
$line =~ s/([#&{} ])/\\$1/g;
$line =~ s/(.*)/\$\\DIFdel\{$1\}\$/;
}
#print "%FIXED BY RULE 1\n";
}
# Too many \color directives (generated by DIFdel/addbegin/end)
# confuse xetex, producing errors:
# WARNING ** Color stack overflow. Just ignore.
# and resulting in corrupted color in output.
# As a work-around, detect cases where it's safe, and replace \color with
# \textcolor.
# As a result, number of \color directives goes does sufficiently
# enough to avoid the overflow error.
if ($line =~ m/\\drivernormative|\\devicenormative/) {
#3rd argument in normative statements is a label. Don't put it in diffs.
$line =~ s/(normative\{[^{]*\{[^{]*\{[^{\\]*)\\DIFdelbegin \\DIFdel\{([^}]*)\}\\DIFdelend/$1$2/;
$line =~ s/(normative\{[^{]*\{[^{]*\{[^{\\]*)\\DIFaddbegin \\DIFadd\{([^}]*)\}\\DIFaddend/$1$2/;
$line =~ s/(normative\{[^{]*\{[^{]*\{[^{\\]*)\\DIFdel\{([^}]*)\}/$1$2/;
$line =~ s/(normative\{[^{]*\{[^{]*\{[^{\\]*)\\DIFadd\{([^}]*)\}/$1$2/;
} elsif ($line =~ m/section|paragraph/) {
$line =~ s/\\DIFdelbegin \\DIFdel\{([^}]*)\}\\DIFdelend/\\DIFdel{$1}/;
$line =~ s/\\DIFaddbegin \\DIFadd\{([^}]*)\}\\DIFaddend/\\DIFadd{$1}/;
} else {
$line =~ s/\\DIFdelbegin \\DIFdel\{([^}]*)\}\\DIFdelend/\\DIFdeltext{$1}/;
$line =~ s/\\DIFaddbegin \\DIFadd\{([^}]*)\}\\DIFaddend/\\DIFaddtext{$1}/;
}
print $line;
if (m/%DIFDELCMD\s+<\s+\\end\{lstlisting\}/) {
print "}\n";
$lstlisting=0;
}
}
|