Skip to content

Commit

Permalink
a .del and an adjacent <ins> can still be a diff pair
Browse files Browse the repository at this point in the history
this makes the common case of "(a)" being turned into a link
"<ref>(a)</ref>" work better as a diff pair
  • Loading branch information
longhotsummer committed Feb 12, 2025
1 parent 10c5a9e commit e05313d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion indigo/analysis/differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def repl(match):
return '\xA0' * (b - a)
del_.text = ws_re.sub(repl, del_.text)

if ins is None or ins.tag != 'ins' or del_.tail:
if del_.tail or ins is None or (ins.tag != 'ins' and not (ins.get('class') or '').startswith('ins ')):
ins = del_.makeelement('ins')
# non-breaking space
ins.text = '\xA0'
Expand Down
2 changes: 1 addition & 1 deletion indigo/tests/test_differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_inline_tag_added(self):
)

self.assertEqual(
'<p>Some text <span class="diff-pair"><del>bold text and a tail.</del><ins>&#xA0;</ins></span><b class="ins ">bold text</b><ins> and a tail.</ins></p>',
'<p>Some text <span class="diff-pair"><del>bold text and a tail.</del><b class="ins ">bold text</b></span><ins> and a tail.</ins></p>',
diff,
)

Expand Down

0 comments on commit e05313d

Please sign in to comment.