gh-95953: Add a css class to changed lines of difflib.HtmlDiff make_table (#139226)

This commit is contained in:
Katie Gardner 2025-09-22 14:19:37 +01:00 committed by GitHub
parent 72d5ee0511
commit e642a24b50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 150 additions and 144 deletions

View file

@ -1924,8 +1924,11 @@ def _format_line(self,side,flag,linenum,text):
# make space non-breakable so they don't get compressed or line wrapped
text = text.replace(' ',' ').rstrip()
return '<td class="diff_header"%s>%s</td><td nowrap="nowrap">%s</td>' \
% (id,linenum,text)
# add a class to the td tag if there is a difference on the line
css_class = ' class="diff_changed" ' if flag else ' '
return f'<td class="diff_header"{id}>{linenum}</td>' \
+ f'<td{css_class}nowrap="nowrap">{text}</td>'
def _make_prefix(self):
"""Create unique anchor prefixes"""