Skip to content
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

Incomplete list of empty HTML tags leads to invalid HTML #1353

Closed
nicbou opened this issue Jun 29, 2023 · 1 comment · Fixed by #1354
Closed

Incomplete list of empty HTML tags leads to invalid HTML #1353

nicbou opened this issue Jun 29, 2023 · 1 comment · Fixed by #1354
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. core Related to the core parser code.

Comments

@nicbou
Copy link
Contributor

nicbou commented Jun 29, 2023

I have made an extension to replace <img> tags with <figure> and <picture> tags. This is the expected output:

<picture>
    <source ...>
    <img ...>
</picture>

Unfortunately, the <source> element has a closing </source> tag. That's invalid HTML. I traced it to this line in the code. The source element is missing from Python Markdown's internal list of empty elements.

The full list of empty elements includes:

<area>
<base>
<br>
<col>
<embed>
<hr>
<img>
<input>
<link>
<meta>
<param> (deprecated)
<source>
<track>
<wbr>
@nicbou
Copy link
Contributor Author

nicbou commented Jun 29, 2023

Actually, why not use Python's native list of elements?

https://github.com/python/cpython/blob/main/Lib/xml/etree/ElementTree.py#L899

@waylan waylan added bug Bug report. core Related to the core parser code. confirmed Confirmed bug report or approved feature request. labels Jun 30, 2023
waylan pushed a commit that referenced this issue Aug 11, 2023
Use Python standard library's HTML_EMPTY which already contains the new tags. Fixes #1353.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. core Related to the core parser code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants