Fixed yet another diff-breaking edge case. This one had to do with
inserting italicized text right before some existing italicized text.
This commit is contained in:
parent
570e0ade77
commit
1095e509de
4
NEWS
4
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
|
||||
<br/> tags didn't parse correctly.
|
||||
|
|
|
@ -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 ):
|
||||
|
|
|
@ -75,6 +75,15 @@ class Test_html_differ( object ):
|
|||
|
||||
assert result == 'foo <del class="diff modified">bar baz </del><ins class="diff modified"><i>bar whee baz</i> </ins>quux'
|
||||
|
||||
def test_diff_with_italics_twice( self ):
|
||||
a = 'foo bar baz quux <i>foo</i>'
|
||||
b = 'foo bar baz quux <i>whee</i><i>foo</i>'
|
||||
|
||||
result = self.differ.diff( a, b )
|
||||
|
||||
# note the screwy placement of the <ins></ins> tags. this is the best the differ can do for now
|
||||
assert result == 'foo bar baz quux <i><ins class="diff">whee</i><i></ins>foo</i>'
|
||||
|
||||
def test_diff_with_link( self ):
|
||||
a = 'foo bar baz quux'
|
||||
b = 'foo bar <a href="whee">baz</a> quux'
|
||||
|
@ -181,6 +190,19 @@ class Test_html_differ( object ):
|
|||
assert new_a == [ 'foo ', 'bar baz ', 'quux' ]
|
||||
assert new_b == [ 'foo ', '<i>bar whee baz</i> ', 'quux' ]
|
||||
|
||||
def test_prepare_lists_with_italics_twice( self ):
|
||||
a = [ 'foo ', 'bar ', 'baz ', 'quux ', '<i>', 'foo', '</i>' ]
|
||||
b = [ 'foo ', 'bar ', 'baz ', 'quux ', '<i>', 'whee', '</i>', '<i>', 'foo', '</i>' ]
|
||||
|
||||
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 ', '<a href="whee">', 'bar ', 'baz', '</a> ', 'quux' ]
|
||||
|
@ -247,6 +269,14 @@ class Test_html_differ( object ):
|
|||
|
||||
assert result == 'foo <del class="diff modified">bar baz </del><ins class="diff modified"><i>bar whee baz</i> </ins>quux'
|
||||
|
||||
def test_diff_lists_with_italics_twice( self ):
|
||||
a = [ 'foo ', 'bar ', 'baz ', 'quux ', '<i>foo</i>' ]
|
||||
b = [ 'foo ', 'bar ', 'baz ', 'quux ', '<i>whee</i>', '<i>foo</i>' ]
|
||||
|
||||
result = self.differ.diff_lists( a, b )
|
||||
|
||||
assert result == 'foo bar baz quux <ins class="diff"><i>whee</i></ins><i>foo</i>'
|
||||
|
||||
def test_diff_lists_with_link( self ):
|
||||
a = [ 'foo ', 'bar baz ', 'quux' ]
|
||||
b = [ 'foo ', '<a href="whee">bar baz</a> ', 'quux' ]
|
||||
|
|
Reference in New Issue