diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2019-01-11 13:22:37 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2019-01-11 16:11:39 -0500 |
commit | 1f6e12c63767cc808df2a48568d9b54e06dfe702 (patch) | |
tree | 1c8cec705c28905496a203deedc237519704bd33 /fixupdiff.pl | |
parent | 15b16c198b28a8aa527d71e84f87282ed01efc2e (diff) | |
download | virtio-spec-1f6e12c63767cc808df2a48568d9b54e06dfe702.tar.gz |
edit: diff: color added listings green
Note: does not apply to lstinputlisting .
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'fixupdiff.pl')
-rw-r--r-- | fixupdiff.pl | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/fixupdiff.pl b/fixupdiff.pl index 2844664..f50cf26 100644 --- a/fixupdiff.pl +++ b/fixupdiff.pl @@ -17,18 +17,29 @@ my @protected_labels = ( 'itm:General Initialization And Device Operation / Device Operation / Supplying Buffers to The Device / Place Index', ); my $lstlisting=0; +my $add=undef; while (<>) { my $line = $_; if (m/%DIFDELCMD\s+<\s+\\begin\{lstlisting\}/) { $lstlisting=1; - $line =~s/%DIFDELCMD\s+</{\\lstset{escapechar=\\\$} /; + $add=0; + $line =~s/(\\begin\{lstlisting\})/{\\lstset{escapechar=\\\$} $1/; + } + if (m/\\DIFaddbegin\s*\\begin\{lstlisting\}/) { + $lstlisting=1; + $add=1; + $line =~s/(\\begin\{lstlisting\})/{\\lstset{escapechar=\\\$} $1/; } if ($lstlisting) { $line =~ s/%DIFDELCMD\s+< //; if (not $line =~ m/\\(?:begin|end)\{lstlisting\}/) { $line =~ s/([#&{} ])/\\$1/g; - $line =~ s/(.*)/\$\\DIFdel\{$1\}\$/; + if ($add) { + $line =~ s/(.*)/\$\\DIFdel\{$1\}\$/; + } else { + $line =~ s/(.*)/\$\\DIFadd\{$1\}\$/; + } } #print "%FIXED BY RULE 1\n"; } @@ -73,8 +84,11 @@ while (<>) { } print $line; - if (m/%DIFDELCMD\s+<\s+\\end\{lstlisting\}/) { - print "}\n"; - $lstlisting=0; + if ($lstlisting) { + if (m/\\end\{lstlisting\}/) { + print "}\n"; + $lstlisting=0; + $add=undef; + } } } |