Skip to content

What's New in Python 3.14 (copyediting) #123299

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

Open
AA-Turner opened this issue Aug 24, 2024 · 3 comments
Open

What's New in Python 3.14 (copyediting) #123299

AA-Turner opened this issue Aug 24, 2024 · 3 comments
Labels
docs Documentation in the Doc dir

Comments

@AA-Turner AA-Turner added the docs Documentation in the Doc dir label Aug 24, 2024
hugovk added a commit that referenced this issue Sep 27, 2024
hugovk added a commit that referenced this issue May 2, 2025
hugovk added a commit that referenced this issue May 6, 2025
@merwok
Copy link
Member

merwok commented May 7, 2025

I noticed a pet peeve in the what’s new (which is great otherwise — what a release!)

   attributes = {"src": "shrubbery.jpg", "alt": "looks nice"}
   template = t"<img {attributes} />"
   assert html(template) == '<img src="shrubbery.jpg" alt="looks nice" class="looks-nice" />'

HTML has some elements defined to not require a closing tag: <img src="..." alt="..."> is valid.

XML has a short form to condense opening and closing tags together: <img src="..." alt="..."/> is equivalent to <img src="..." alt="..."></img>. All opening tags need a matching closing tag, or the self-closing form.

A decade ago, to ensure compatibility with SGML and XML parsers, the best practice was to add a space before the slash. It was taking advantage of an SGML feature where / was actually closing the tag and > was ignored as garbage. It was ugly but compatible with the two kinds of parsers existing at the time.

Modern HTML does not require this, and has also abandoned XML rules (except for SVG that can be embedded directly, but that’s defined in the HTML spec I think).

So the easy, simple, correct form should be:

   attributes = {"src": "shrubbery.jpg", "alt": "looks nice"}
   template = t"<img {attributes}>"
   assert html(template) == '<img src="shrubbery.jpg" alt="looks nice" class="looks-nice">'

Thanks for coming to my TED talk.

@hugovk
Copy link
Member

hugovk commented May 7, 2025

@merwok Would you like to open a PR to fix it?

@merwok
Copy link
Member

merwok commented May 7, 2025

Fine #133622

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

3 participants