gh-95953: Add a css class to changed lines of difflib.HtmlDiff make_t… · python/cpython@e642a24

GitHub

Original file line numberDiff line numberDiff line change@@ -1924,8 +1924,11 @@ def _format_line(self,side,flag,linenum,text):

19241924# make space non-breakable so they don't get compressed or line wrapped

19251925text=text.replace(' ',' ').rstrip()

192619261927-return'<td class="diff_header"%s>%s</td><td nowrap="nowrap">%s</td>' \

1928-% (id,linenum,text)

1927+# add a class to the td tag if there is a difference on the line

1928+css_class=' class="diff_changed" 'ifflagelse' '

1929+1930+returnf'<td class="diff_header"{id}>{linenum}</td>' \

1931++f'<td{css_class}nowrap="nowrap">{text}</td>'

1929193219301933def_make_prefix(self):

19311934"""Create unique anchor prefixes"""