Repository navigation
🐛 fix(markdown): keep block content in headings - #1214
Merged
gaborbernat merged 2 commits intoOct 8, 2026
Merged
Conversation
gaborbernat
force-pushed
the
fix/markdown-heading-blocks
branch
2 times, most recently
from
October 7, 2026 23:47
fe45efa to
105118a
Compare
Merging this PR will regress 3 benchmarks
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | test_feature[phone-ucs4-prose] |
1.3 ms | 1.4 ms | -7.65% |
| ❌ | test_feature[phone-ucs2-prose] |
2.1 ms | 2.2 ms | -6.55% |
| ❌ | test_feature[select-relative-sibling] |
42.7 µs | 45 µs | -5.29% |
| ⚡ | test_feature[shadow-slot-comments] |
137.9 µs | 83.4 µs | +65.28% |
| ⚡ | test_feature[form-data-fieldsets] |
32.5 µs | 30.9 µs | +5.18% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing gaborbernat:fix/markdown-heading-blocks (3cfb39f) with main (2ffa2f0)
Footnotes
-
32 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
to_markdown let a block inside a heading break out of it. <h3><p>x</p> </h3> became an empty "### " followed by a paragraph, and in <h2>a<p>b</p>c</h2> the text after the block left the heading too. A Markdown heading is one line, so blocks inside it now flatten onto that line, the way link text already flattens them. The end of a flattened block reads as a space as well as its start, so words on either side of a block stay apart in headings and link text alike.
The Markdown meaning check compared the blocks nested in a heading as blocks. A CommonMark heading holds one line of inline content, so no conversion can keep those blocks, and the flattened heading this branch writes still failed the check. The check now flattens heading content onto one line, reading each block edge and each <br> as a space, which is the heading a reader rebuilds from the converted Markdown.
gaborbernat
force-pushed
the
fix/markdown-heading-blocks
branch
from
October 8, 2026 01:27
982954c to
3cfb39f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
to_markdownlet a block inside a heading break out of it.<h3><p>x</p></h3>became an empty###followed by a paragraphx, and in<h2>a<p>b</p>c</h2>thebandcleft the heading as a separate paragraphbc. 🐛An ATX heading holds one line of inline content, so blocks inside a heading now flatten onto that line, the way link text already flattens them: the two examples give
### xand## a b c. The end of a flattened block now reads as a space as well as its start, so link text over<div><i>a</i><i>b</i></div>xkeeps a space beforexwhere thebandxused to fuse.markdownify 1.2.3 flattens the same way and gives
### x; html2text 2025.4.15 writes the empty###and moves the content out, as turbohtml did. A heading nested in a heading now joins the outer heading's line, since Markdown has no nested headings.The Markdown meaning check that runs over the #1018 fuzz consumers now compares heading content as one line too, with each block edge and
<br>read as a space, since that is the only heading a reader can rebuild.