WebSafe 3.7github.com
|
|
🏠
Skip to content

gh-134580: Modernizing difflib.HtmlDiff for HTML Output#134581

Merged
hugovk merged 4 commits intopython:mainfrom
Wulian233:difflib-html
May 28, 2025
Merged

gh-134580: Modernizing difflib.HtmlDiff for HTML Output#134581
hugovk merged 4 commits intopython:mainfrom
Wulian233:difflib-html

Conversation

@Wulian233
Copy link
Contributor

@Wulian233 Wulian233 commented May 23, 2025

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


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

@hugovk
Copy link
Member

hugovk commented May 23, 2025

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?

@Wulian233
Copy link
Contributor Author

Wulian233 commented May 23, 2025

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

'<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 :)

@hugovk hugovk enabled auto-merge (squash) May 27, 2025 14:23
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
39 checks passed
@Wulian233 Wulian233 deleted the difflib-html branch May 28, 2025 04:55
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
…on#134581)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
…on#134581)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants

Comments