From e642a24b50fa1ac2fa709cda233d1dc5c90333fe Mon Sep 17 00:00:00 2001
From: Katie Gardner <5213160+KatieLG@users.noreply.github.com>
Date: Mon, 22 Sep 2025 14:19:37 +0100
Subject: [PATCH] gh-95953: Add a css class to changed lines of
difflib.HtmlDiff make_table (#139226)
---
Lib/difflib.py | 7 +-
Lib/test/test_difflib_expect.html | 284 +++++++++---------
Misc/ACKS | 1 +
...5-09-22-11-19-05.gh-issue-95953.7oLoag.rst | 2 +
4 files changed, 150 insertions(+), 144 deletions(-)
create mode 100644 Misc/NEWS.d/next/Library/2025-09-22-11-19-05.gh-issue-95953.7oLoag.rst
diff --git a/Lib/difflib.py b/Lib/difflib.py
index fedc85009aa0..4a0600e4ebb0 100644
--- a/Lib/difflib.py
+++ b/Lib/difflib.py
@@ -1924,8 +1924,11 @@ class HtmlDiff(object):
# make space non-breakable so they don't get compressed or line wrapped
text = text.replace(' ',' ').rstrip()
- return '
| f | | f | |
- | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -75,11 +75,11 @@
| 123 | | 123 |
| 123 | | 123 |
| | | |
- | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -91,11 +91,11 @@
| 123 | | 123 |
| 123 | | 123 |
| | | |
- | t | 1. Beautiful is beTTer than ugly. | t | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | t | 1. Beautiful is beTTer than ugly. | t | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -133,11 +133,11 @@
|
|
| f | | f | |
- | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -150,11 +150,11 @@
| 123 | | 123 |
| 123 | | 123 |
| | | |
- | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -167,11 +167,11 @@
| 123 | | 123 |
| 123 | | 123 |
| | | |
- | t | 1. Beautiful is beTTer than ugly. | t | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | t | 1. Beautiful is beTTer than ugly. | t | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -192,11 +192,11 @@
| 456 | | 456 |
| 456 | | 456 |
| | | |
- | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -209,11 +209,11 @@
| 123 | | 123 |
| 123 | | 123 |
| | | |
- | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -226,11 +226,11 @@
| 123 | | 123 |
| 123 | | 123 |
| | | |
- | t | 1. Beautiful is beTTer than ugly. | t | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | t | 1. Beautiful is beTTer than ugly. | t | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -247,11 +247,11 @@
|
|
| f | | f | |
- | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -263,11 +263,11 @@
| 123 | | 123 |
| 123 | | 123 |
| | | |
- | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | n | 1. Beautiful is beTTer than ugly. | n | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -279,11 +279,11 @@
| 123 | | 123 |
| 123 | | 123 |
| | | |
- | t | 1. Beautiful is beTTer than ugly. | t | 1. Beautiful is better than ugly. |
- | 2. Explicit is better than implicit. | | |
- | 3. Simple is better than complex. | | 3. Simple is better than complex. |
- | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
- | | | 5. Flat is better than nested. |
+ | t | 1. Beautiful is beTTer than ugly. | t | 1. Beautiful is better than ugly. |
+ | 2. Explicit is better than implicit. | | |
+ | 3. Simple is better than complex. | | 3. Simple is better than complex. |
+ | 4. Complex is better than complicated. | | 4. Complicated is better than complex. |
+ | | | 5. Flat is better than nested. |
| 123 | | 123 |
| 123 | | 123 |
| 123 | | 123 |
@@ -300,25 +300,25 @@
|
|
| f | | f | |
- | t | Line 1: preceded by from:[tt] to:[ssss] | t | Line 1: preceded by from:[tt] to:[ssss] |
- | Line 2: preceded by from:[sstt] to:[sssst] | | Line 2: preceded by from:[sstt] to:[sssst] |
- | Line 3: preceded by from:[sstst] to:[ssssss] | | Line 3: preceded by from:[sstst] to:[ssssss] |
- | Line 4: has from:[sst] to:[sss] after : | | Line 4: has from:[sst] to:[sss] after : |
- | Line 5: has from:[t] to:[ss] at end | | Line 5: has from:[t] to:[ss] at end |
+ | t | Line 1: preceded by from:[tt] to:[ssss] | t | Line 1: preceded by from:[tt] to:[ssss] |
+ | Line 2: preceded by from:[sstt] to:[sssst] | | Line 2: preceded by from:[sstt] to:[sssst] |
+ | Line 3: preceded by from:[sstst] to:[ssssss] | | Line 3: preceded by from:[sstst] to:[ssssss] |
+ | Line 4: has from:[sst] to:[sss] after : | | Line 4: has from:[sst] to:[sss] after : |
+ | Line 5: has from:[t] to:[ss] at end | | Line 5: has from:[t] to:[ss] at end |
| f | | f | |
- | t | Line 1: preceded by from:[tt] to:[ssss] | t | Line 1: preceded by from:[tt] to:[ssss] |
- | Line 2: preceded by from:[sstt] to:[sssst] | | Line 2: preceded by from:[sstt] to:[sssst] |
- | Line 3: preceded by from:[sstst] to:[ssssss] | | Line 3: preceded by from:[sstst] to:[ssssss] |
- | Line 4: has from:[sst] to:[sss] after : | | Line 4: has from:[sst] to:[sss] after : |
- | Line 5: has from:[t] to:[ss] at end | | Line 5: has from:[t] to:[ss] at end |
+ | t | Line 1: preceded by from:[tt] to:[ssss] | t | Line 1: preceded by from:[tt] to:[ssss] |
+ | Line 2: preceded by from:[sstt] to:[sssst] | | Line 2: preceded by from:[sstt] to:[sssst] |
+ | Line 3: preceded by from:[sstst] to:[ssssss] | | Line 3: preceded by from:[sstst] to:[ssssss] |
+ | Line 4: has from:[sst] to:[sss] after : | | Line 4: has from:[sst] to:[sss] after : |
+ | Line 5: has from:[t] to:[ss] at end | | Line 5: has from:[t] to:[ss] at end |