diff --git a/NEWS b/NEWS
index f1fa141..52a19e1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+1.3.12: May 3, 2008:
+ * Fixed yet another diff-breaking edge case. This one had to do with
+ inserting italicized text right before some existing italicized text.
+
1.3.11: May 2, 2008
* Fixed another bug that prevented diffs from working. This time, those with
tags didn't parse correctly.
diff --git a/controller/Html_differ.py b/controller/Html_differ.py
index 01d84eb..b735598 100644
--- a/controller/Html_differ.py
+++ b/controller/Html_differ.py
@@ -182,6 +182,11 @@ class Html_differ( HTMLParser ):
open_del_items = []
open_ins_items = []
+ if len( open_del_items ):
+ result_a.extend( open_del_items )
+ if len( open_ins_items ):
+ result_b.extend( open_ins_items )
+
return ( result_a, result_b )
def diff_lists( self, a, b ):
diff --git a/controller/test/Test_html_differ.py b/controller/test/Test_html_differ.py
index 455e953..647e7b6 100644
--- a/controller/test/Test_html_differ.py
+++ b/controller/test/Test_html_differ.py
@@ -75,6 +75,15 @@ class Test_html_differ( object ):
assert result == 'foo bar baz bar whee baz quux'
+ def test_diff_with_italics_twice( self ):
+ a = 'foo bar baz quux foo'
+ b = 'foo bar baz quux wheefoo'
+
+ result = self.differ.diff( a, b )
+
+ # note the screwy placement of the tags. this is the best the differ can do for now
+ assert result == 'foo bar baz quux wheefoo'
+
def test_diff_with_link( self ):
a = 'foo bar baz quux'
b = 'foo bar baz quux'
@@ -181,6 +190,19 @@ class Test_html_differ( object ):
assert new_a == [ 'foo ', 'bar baz ', 'quux' ]
assert new_b == [ 'foo ', 'bar whee baz ', 'quux' ]
+ def test_prepare_lists_with_italics_twice( self ):
+ a = [ 'foo ', 'bar ', 'baz ', 'quux ', '', 'foo', '' ]
+ b = [ 'foo ', 'bar ', 'baz ', 'quux ', '', 'whee', '', '', 'foo', '' ]
+
+ result = self.differ.prepare_lists( a, b )
+
+ assert len( result ) == 2
+ ( new_a, new_b ) = result
+
+ # there should be no change, because prepare_lists() doesn't know how to merge a complex case like this
+ assert new_a == a
+ assert new_b == b
+
def test_prepare_lists_with_link( self ):
a = [ 'foo ', 'bar ', 'baz ', 'quux' ]
b = [ 'foo ', '', 'bar ', 'baz', ' ', 'quux' ]
@@ -247,6 +269,14 @@ class Test_html_differ( object ):
assert result == 'foo bar baz bar whee baz quux'
+ def test_diff_lists_with_italics_twice( self ):
+ a = [ 'foo ', 'bar ', 'baz ', 'quux ', 'foo' ]
+ b = [ 'foo ', 'bar ', 'baz ', 'quux ', 'whee', 'foo' ]
+
+ result = self.differ.diff_lists( a, b )
+
+ assert result == 'foo bar baz quux wheefoo'
+
def test_diff_lists_with_link( self ):
a = [ 'foo ', 'bar baz ', 'quux' ]
b = [ 'foo ', 'bar baz ', 'quux' ]