# markdown: Fix heading sizes and spacing in preview \(\#54374\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/d2ddb4b2d9a005b450ea287a20b1c60fe201144a)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: d2ddb4b2d9a005b450ea287a20b1c60fe201144a

Requested commit: d2ddb4b2d9a005b450ea287a20b1c60fe201144a

Commit: d2ddb4b2d9a005b450ea287a20b1c60fe201144a

Tree: ca76cadb6ac87c9f4e8d83404a45b81e2e56fbf3

Author: saberoueslati

Committer: GitHub

## Message

```
markdown: Fix heading sizes and spacing in preview (#54374)

## Context

Heading sizes in the markdown preview were nearly identical to body
text, making `# H1`, `## H2`, and `### H3` visually indistinguishable.
The root cause was in `MarkdownStyle::themed()`: it set a
`heading_level_styles` override with font sizes of `rems(1.05–1.15)`,
which silently replaced the correct sizes applied by
`apply_heading_style` (via GPUI's `text_3xl`/`text_2xl`/`text_xl`
utilities `rems(1.875/1.5/1.25)`). Removing that override restores the
intended hierarchy. A `mt_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](https://github.com/user-attachments/assets/8dd815f9-6f9b-4e88-bebb-28c79f019427)

## How to Review

`crates/markdown/src/markdown.rs` Three changes:
- (1) removed the `heading_level_styles` block from
`MarkdownStyle::themed()` that was overriding heading font sizes with
nearly-body-text values;
- (2) added `mt_4()` to the heading div in `push_markdown_heading` for
better vertical spacing;
- (3) added `test_heading_font_sizes_are_distinct` which renders H1–H3
and a paragraph then asserts that line heights strictly decrease from H1
down to body text.

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed heading sizes in the markdown preview to correctly reflect the
H1–H6 size hierarchy, matching standard markdown renderers
```

## Parents

- [481407479d3c7e1a0943090d63b606ff3b02d064](https://git.cafe/gitcafe/zed/commit/481407479d3c7e1a0943090d63b606ff3b02d064?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/d2ddb4b2d9a005b450ea287a20b1c60fe201144a?format=markdown)
