GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-134580: Modernizing `difflib.HtmlDiff` for HTML Output by Wulian233 · Pull Request #134581 · python/cpython

Conversation

@Wulian233

@Wulian233 Wulian233 commented May 23, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Improved the styling of HTML diff pages generated by the difflib.HtmlDiff` class, and migrated the output to the HTML5 standard.
And all browser warnings have been eliminated.

details see: #134580

Request review @hugovk thanks!

Screenshot:

Details Before:

屏幕截图 2025-05-22 204245

After:
屏幕截图 2025-05-22 204257

Before:
屏幕截图 2025-05-22 204628

After:
屏幕截图 2025-05-22 210619

  • Issue: Modernizing difflib.HtmlDiff for HTML Output #134580

📚 Documentation preview 📚: https://cpython-previews--134581.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Wulian233
Improved the styling of HTML diff pages generated by the `difflib.Htm…
c022435
…lDiff`
@bedevere-app bedevere-app Bot mentioned this pull request May 23, 2025
Modernizing difflib.HtmlDiff for HTML Output #134580
Closed
@bedevere-app bedevere-app Bot added the awaiting review label May 23, 2025
@hugovk

hugovk commented May 23, 2025

Copy link
Copy Markdown
Member

Thanks, I think this is an improvement.

Before

image

After

image

And

Here's a GitHub diff:

image

Similarly, I think we should keep the lines a bit tighter together.

Here's the PR with the vertical padding removed:

image

Shall we remove that padding?

And shall we centre the table on the page?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wulian233
vertical padding removed
1288aa1
@Wulian233

Wulian233 commented May 23, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Similarly, I think we should keep the lines a bit tighter together.
Here's the PR with the vertical padding removed:

It's a good improvement, and this is what it looks like now
屏幕截图 2025-05-23 211103

And shall we centre the table on the page?

I before thought about this, but the table width is determined based on the length of the content and the code specified, like

cpython/Lib/test/test_difflib.py

Line 227 in 1288aa1

'<h2>tabsize=2</h2>',

             '<h2>tabsize=2</h2>',
             j.make_table(f2,t2),
             '<h2>tabsize=default</h2>',

屏幕截图 2025-05-23 211452

If we center the table, there will be a lot of space on both sides of the screen, and it may not be as easy to distinguish as if the table is narrow. So I didn't do that, and my opinion is also to keep the left alignment the way :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk
hugovk approved these changes May 27, 2025
View reviewed changes
Comment thread Lib/difflib.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels May 27, 2025
@hugovk
Casing
66cdcb5
@hugovk
hugovk enabled auto-merge (squash) May 27, 2025 14:23
@Wulian233
casting
102a544
auto-merge was automatically disabled May 27, 2025 22:23

Head branch was pushed to by a user without write access

@hugovk
hugovk merged commit 7ca6d79 into python:main May 28, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label May 28, 2025
@Wulian233
Wulian233 deleted the difflib-html branch May 28, 2025 04:55
@Wulian233 Wulian233 mentioned this pull request May 28, 2025
gh-133722: Add Difflib theme to _colorize and 'color' option to difflib.unified_diff #133725
Merged
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
@Wulian233 @hugovk @Pranjal095
pythongh-134580: Modernizing difflib.HtmlDiff for HTML Output (pyth…
985c156
…on#134581)

Co-authored-by: Hugo van Kemenade <[email protected]>
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
@Wulian233 @hugovk @taegyunkim
pythongh-134580: Modernizing difflib.HtmlDiff for HTML Output (pyth…
dda6c8d
…on#134581)

Co-authored-by: Hugo van Kemenade <[email protected]>
gostak-dd pushed a commit to gostak-dd/cpython that referenced this pull request Jun 2, 2026
@Wulian233 @hugovk @gostak-dd
pythongh-134580: Modernizing difflib.HtmlDiff for HTML Output (pyth…
08bcc5f
…on#134581)

Co-authored-by: Hugo van Kemenade <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hugovk hugovk hugovk approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Wulian233 @hugovk
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.