markdown: Fix heading sizes and spacing in preview#54374
markdown: Fix heading sizes and spacing in preview#54374ChristopherBiscardi merged 2 commits intozed-industries:mainfrom
Conversation
d8a2013 to
7f6cff1
Compare
7f6cff1 to
53560b9
Compare
|
@danilo-leal, looking for feedback, @miguelraz suggested parity with VSCode might be needed in the issue #54358 The difference I found so far is the line under Heading 1 and 2, and the font is bolder in VSCode, as you see below. Should I add those? Screenshots for reference below. Zed screenshot
VScode screenshot
|
We don't need to exactly match everything vscode or another software does, especially with respect to bold or horizontal rules. Let's keep this scoped to the heading size differences so that headings like h1 vs h2 can be differentiated in the preview. |
|
Hi @ChristopherBiscardi noticed you just merged this, I've also updated the markdown rendering, any chance you could help find someone to review? #54003 |
|
@robinojw yes, I'm already looking at it. That's the PR I meant when I mentioned one above |
Follow up to zed-industries#54374 as that removed the custom heading styles that were mostly tailored to the agent panel. It makes sense for those values not to be the ones used for general markdown rendering, but I think it's just too big for the agent panel. So I'm sort of hijacking the `MarkdownFont::Agent` enum here so that we can set it conditionally to just the agent context. Release Notes: - N/A
|
Finally on this one. Thought I was taking crazy pills. Thanks for the quick turn around |
Follow up to zed-industries#54374 as that removed the custom heading styles that were mostly tailored to the agent panel. It makes sense for those values not to be the ones used for general markdown rendering, but I think it's just too big for the agent panel. So I'm sort of hijacking the `MarkdownFont::Agent` enum here so that we can set it conditionally to just the agent context. Release Notes: - N/A



Context
Heading sizes in the markdown preview were nearly identical to body text, making
# H1,## H2, and### H3visually indistinguishable. The root cause was inMarkdownStyle::themed(): it set aheading_level_stylesoverride with font sizes ofrems(1.05–1.15), which silently replaced the correct sizes applied byapply_heading_style(via GPUI'stext_3xl/text_2xl/text_xlutilitiesrems(1.875/1.5/1.25)). Removing that override restores the intended hierarchy. Amt_4()top margin was also added so consecutive headings have visual breathing room.Closes #54358
Video of manual test below :
Screencast.from.2026-04-21.02-22-12.webm
How to Review
crates/markdown/src/markdown.rsThree changes:heading_level_stylesblock fromMarkdownStyle::themed()that was overriding heading font sizes with nearly-body-text values;mt_4()to the heading div inpush_markdown_headingfor better vertical spacing;test_heading_font_sizes_are_distinctwhich renders H1–H3 and a paragraph then asserts that line heights strictly decrease from H1 down to body text.Self-Review Checklist
Release Notes: