-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
The current output of make_table method in difflib.HtmlDiff, doesn't add a CSS class when the content in a cell is changed.
Sample input:
from difflib import HtmlDiff
diff = HtmlDiff()
fromlines = "f oo bar"
tolines = "f 00 bar"
diff.make_table(fromlines, tolines)Current output:
<tr>
<td class="diff_next"><a href="#difflib_chg_to0__top">t</a></td>
<td class="diff_header" id="from0_2">2</td>
<td nowrap="nowrap">f <span class="diff_chg">oo</span> bar</td>
<td class="diff_next"><a href="#difflib_chg_to0__top">t</a></td>
<td class="diff_header" id="to0_2">2</td>
<td nowrap="nowrap">f <span class="diff_chg">00</span> bar</td>
</tr>Add a new class (for example, diff_changed) to the 3rd and 6th cells when they have changed content.
Proposed output:
<tr>
<td class="diff_next"><a href="#difflib_chg_to0__top">t</a></td>
<td class="diff_header" id="from0_2">2</td>
<td class="diff_changed" nowrap="nowrap">f <span class="diff_chg">oo</span> bar</td>
<td class="diff_next"><a href="#difflib_chg_to0__top">t</a></td>
<td class="diff_header" id="to0_2">2</td>
<td class="diff_changed" nowrap="nowrap">f <span class="diff_chg">00</span> bar</td>
</tr>Pitch
This will allow more customizations to be done for applications that make use of this library.
For example, when required whole line can have a background colour when content is changed.
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement