diff --git a/NEWS b/NEWS index 42ab0e0..5a0310e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +1.3.10: May 2, 2008 + * Fixed a bug that prevented diffs from working for notes with links. + 1.3.9: May 2, 2008 * When viewing a note's revision, changes since the previous revision are now shown in red strikeout (deletions/modifications) and green text diff --git a/controller/Html_differ.py b/controller/Html_differ.py index 0777c7f..8838cb2 100644 --- a/controller/Html_differ.py +++ b/controller/Html_differ.py @@ -82,8 +82,8 @@ class Html_differ( HTMLParser ): ( a, b ) = self.prepare_lists( a, b ) return self.diff_lists( a, b ) - START_TAG_PATTERN = re.compile( "<([^/][^>]*)>" ) - END_TAG_PATTERN = re.compile( "]+)>" ) + START_TAG_PATTERN = re.compile( "<(\w+)(\s+[^>]*)*>" ) + END_TAG_PATTERN = re.compile( "" ) @staticmethod def track_open_tags( item, open_tags ): diff --git a/controller/test/Test_html_differ.py b/controller/test/Test_html_differ.py index 254505a..7594434 100644 --- a/controller/test/Test_html_differ.py +++ b/controller/test/Test_html_differ.py @@ -75,6 +75,14 @@ class Test_html_differ( object ): assert result == 'foo bar baz bar whee baz quux' + def test_diff_with_link( self ): + a = 'foo bar baz quux' + b = 'foo bar baz quux' + + result = self.differ.diff( a, b ) + + assert result == 'foo bar baz baz quux' + def test_track_open_tags( self ): open_tags = [] @@ -84,11 +92,11 @@ class Test_html_differ( object ): assert open_tags == [ u"i" ] self.differ.track_open_tags( u"bar ", open_tags ) assert open_tags == [ u"i" ] - self.differ.track_open_tags( u"", open_tags ) - assert open_tags == [ u"i", u"b" ] + self.differ.track_open_tags( u'', open_tags ) + assert open_tags == [ u"i", u"a" ] self.differ.track_open_tags( u"baz", open_tags ) - assert open_tags == [ u"i", u"b" ] - self.differ.track_open_tags( u"", open_tags ) + assert open_tags == [ u"i", u"a" ] + self.differ.track_open_tags( u"", open_tags ) assert open_tags == [ u"i" ] self.differ.track_open_tags( u"", open_tags ) assert open_tags == [] @@ -160,6 +168,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_link( self ): + a = [ 'foo ', 'bar ', 'baz ', 'quux' ] + b = [ 'foo ', '', 'bar ', 'baz', ' ', 'quux' ] + + result = self.differ.prepare_lists( a, b ) + + assert len( result ) == 2 + ( new_a, new_b ) = result + + # the elements within italics should be merged + assert new_a == [ 'foo ', 'bar baz ', 'quux' ] + assert new_b == [ 'foo ', 'bar baz ', 'quux' ] + def test_diff_lists_with_insert( self ): a = [ 'foo ', 'bar ', 'baz ', 'quux' ] b = [ 'foo ', 'bar ', 'whee ', 'baz ', 'quux' ] @@ -199,3 +220,12 @@ class Test_html_differ( object ): result = self.differ.diff_lists( a, b ) assert result == 'foo bar baz bar whee baz quux' + + def test_diff_lists_with_link( self ): + a = [ 'foo ', 'bar baz ', 'quux' ] + b = [ 'foo ', 'bar baz ', 'quux' ] + + result = self.differ.diff_lists( a, b ) + + assert result == 'foo bar baz bar baz quux' + diff --git a/static/css/note.css b/static/css/note.css index 2139446..107910a 100644 --- a/static/css/note.css +++ b/static/css/note.css @@ -27,11 +27,19 @@ ins { text-decoration: none; } +ins a { + color: green; +} + del { color: red; text-decoration: line-through; } +del a { + color: red; +} + .button { border-style: outset; border-width: 0px;