Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 28, 2025

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:

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

Lib/difflib.py Outdated Show resolved Hide resolved
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.