From f612f689e7e97df615294f090b14d06a31fdabab Mon Sep 17 00:00:00 2001 From: mstsirkin Date: Sun, 15 Mar 2015 11:10:49 +0000 Subject: makediff: work around for lstlisting latexdiff seems to go wild trying to diff lstlisting. But marking lstlisting as picture - so old text is commented out - then removing the comment sign - seems to work, with the only disadvantage being that listing is diffed as a whole. Seems to be the best I can come up with ATM. Signed-off-by: Michael S. Tsirkin git-svn-id: https://tools.oasis-open.org/version-control/svn/virtio/branches/v1.0@484 0c8fb4dd-22a2-4bb5-bc14-6c75a5f43652 --- fixupdiff.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 fixupdiff.pl (limited to 'fixupdiff.pl') diff --git a/fixupdiff.pl b/fixupdiff.pl new file mode 100644 index 0000000..70d4e30 --- /dev/null +++ b/fixupdiff.pl @@ -0,0 +1,14 @@ +my $lstlisting=0; +while (<>) { + my $line = $_; + if (m/%DIFDELCMD\s+<\s+\\begin{lstlisting}/) { + $lstlisting=1; + } + if ($lstlisting) { + $line =~ s/%DIFDELCMD\s+<\s+//; + } + print $line; + if (m/%DIFDELCMD\s+<\s+\\end{lstlisting}/) { + $lstlisting=0; + } +} -- cgit v1.2.3 From e06b2ff405259b3d4a8f49ec83e4ae69f84f75f6 Mon Sep 17 00:00:00 2001 From: mstsirkin Date: Thu, 21 May 2015 10:13:22 +0000 Subject: fixupdiff.pl: more work-arounds for latexdiff work around more latexdiff issues: - force FL style within headers - fix beginFL ending with end and vice versa across begin/end of enum or itemize Signed-off-by: Michael S. Tsirkin git-svn-id: https://tools.oasis-open.org/version-control/svn/virtio/branches/v1.0@534 0c8fb4dd-22a2-4bb5-bc14-6c75a5f43652 --- fixupdiff.pl | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'fixupdiff.pl') diff --git a/fixupdiff.pl b/fixupdiff.pl index 70d4e30..94c5112 100644 --- a/fixupdiff.pl +++ b/fixupdiff.pl @@ -1,3 +1,6 @@ +my $bufferdiff=""; +my $diff=""; +my $buffer=""; my $lstlisting=0; while (<>) { my $line = $_; @@ -6,6 +9,61 @@ while (<>) { } if ($lstlisting) { $line =~ s/%DIFDELCMD\s+<\s+//; + #print "%FIXED BY RULE 1\n"; + } + #In section headings, replace begin/end with begin/endFL, + #but be careful in case some tag spills over to the next + #line + if (m/\\(section|subsection|subsubsection|paragraph)/ and m/DIF/) { + my @list = split(/(\\DIF(?:add|del)(?:begin|end)(?:FL)?)/, $line, -1); + #if there's only one tag, don't touch it: + #matching one is on the other line + if ($#list >= 5) { + #if first tag is end, don't touch it - matching + #begin is on the previous line + if ($list[1] =~ m/begin$/) { + $list[1] .= "FL"; + } + #if last tag is begin, don't touch it - matching + #end is on the next line + if ($list[$#list - 1] =~ m/end$/) { + $list[$#list - 1] .= "FL"; + } + } + for (my $i = 3; $i <= $#list - 3; $i += 2) { + if (not $list[$i] =~ m/FL$/) { + $list[$i] .= "FL"; + } + } + $line = join("", @list); + #print "%FIXED BY RULE 2\n"; + } + #detect where we have DIFbegin/end cross + #enumerate/itemize environments and fix up + if (m/\\DIF(?:add|del)(?:begin|end)/) { + my @list = split(/(\\DIF(?:add|del)(?:begin|end)(?:FL)?)/, $line, -1); + $diff = $list[$#list - 1]; + if ($diff =~ m/begin/) { + $diff =~ s/begin/end/; + } else { + $diff = ""; + } + } + if ($diff ne "" and m/\\(?:begin|end){(?:enumerate|itemize)}$/ and not m/\\DIF/) { + $buffer = $line; + $bufferdiff = $diff; + $line = ""; + #print "%BUFFERED BY RULE 3: $bufferdiff\n"; + } + if ($buffer ne "" and $line ne "") { + if (m/^(\\DIF(?:add|del)end(?:FL)?)/ and $bufferdiff ne $1) { + $line =~ s/^(\\DIF(?:add|del)end(?:FL)?)//; + $buffer =~ s/(\\(?:begin|end){(?:enumerate|itemize)})$/$bufferdiff$1/; + #print "%FIXED BY RULE 3: $bufferdiff\n"; + } + print $buffer; + $buffer = ""; + $bufferdiff = ""; } print $line; if (m/%DIFDELCMD\s+<\s+\\end{lstlisting}/) { -- cgit v1.2.3 From 601882e8907263e0d16cafd934ade9fe6e20f80f Mon Sep 17 00:00:00 2001 From: mstsirkin Date: Thu, 21 May 2015 10:13:40 +0000 Subject: fixupdiff: better diff for lstlisting Actually strike out deleted text. Signed-off-by: Michael S. Tsirkin git-svn-id: https://tools.oasis-open.org/version-control/svn/virtio/branches/v1.0@535 0c8fb4dd-22a2-4bb5-bc14-6c75a5f43652 --- fixupdiff.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'fixupdiff.pl') diff --git a/fixupdiff.pl b/fixupdiff.pl index 94c5112..e557e2b 100644 --- a/fixupdiff.pl +++ b/fixupdiff.pl @@ -1,14 +1,18 @@ my $bufferdiff=""; my $diff=""; my $buffer=""; -my $lstlisting=0; while (<>) { my $line = $_; if (m/%DIFDELCMD\s+<\s+\\begin{lstlisting}/) { $lstlisting=1; + $line =~s/%DIFDELCMD\s+) { } print $line; if (m/%DIFDELCMD\s+<\s+\\end{lstlisting}/) { + print "}\n"; $lstlisting=0; } } -- cgit v1.2.3