Skip to content

Treat picture as a block-level HTML element - #1645

Closed
00200200 wants to merge 1 commit into
Python-Markdown:masterfrom
00200200:fix-picture-html-comment-blocks
Closed

00200200 wants to merge 1 commit into
Python-Markdown:masterfrom
00200200:fix-picture-html-comment-blocks

Conversation

@00200200

Copy link
Copy Markdown

Description

A line-started <picture> with an HTML comment inside it was split across paragraphs, because picture was treated as inline HTML while comments are raw blocks. That produced invalid markup such as <p><picture>…<!-- … --></p><p><source>…</picture></p>.

Treat picture as a block-level HTML element, matching video and other media tags whose contents Markdown should not rewrite. A <picture> that appears mid-paragraph remains inline.

Fixes #1643.

AI Assistance Disclosure

  • No AI tools were used in preparing this PR.
  • If AI tools were used, I have disclosed which ones, and fully reviewed and verified their output.

AI tools (Cursor) were used to locate the issue, draft the change, and write tests. I reviewed the parser behavior, confirmed the test fails on master and passes after the change, and ran the unit suite.

Checklist

HTML comments are stored as raw blocks. When picture was treated as
inline, a comment inside a line-started picture split the element
across paragraphs and produced invalid HTML.

picture belongs with video and other media tags whose contents
Markdown should not rewrite. An inline picture in mid-paragraph is
unchanged.

Fixes Python-Markdown#1643.
@facelessuser

Copy link
Copy Markdown
Collaborator

<picture> is an inline element, though. That is how it is treated by default in browsers.

@waylan

waylan commented Sep 29, 2026

Copy link
Copy Markdown
Member

As the HTML spec clearly identifies <picture> as an inline element, we will not be making this change.

@waylan waylan closed this Sep 29, 2026
@waylan waylan added the rejected The pull request is rejected for the stated reasons. label Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rejected The pull request is rejected for the stated reasons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTML comment inside inline raw HTML creates malformed output

3 participants