Skip to content

markdown: Apply heading level text styles to the shaped text - #63465

Open
archcorsair wants to merge 1 commit into
zed-industries:mainfrom
archcorsair:markdown-heading-weight
Open

markdown: Apply heading level text styles to the shaped text#63465
archcorsair wants to merge 1 commit into
zed-industries:mainfrom
archcorsair:markdown-heading-weight

Conversation

@archcorsair

@archcorsair archcorsair commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Objective

Follow-up to #63118. That PR set the preview's headings to semibold and gave h6 a muted color through heading_level_styles, and the PR body says as much, but neither actually rendered. Headings in the preview came out at the base weight and color, which you can see in the after screenshot on that PR: every heading is regular while the bold body text and the table header cells are heavy.

I found this while looking into @Arcitec's report on #63118 about bold not rendering with SF Pro. That one turned out to be a different bug: SF Pro is a variable font, and the Linux text system does not pass the requested weight through to it. It is tracked in #60155 and #62832 has a fix up for it, so this PR does not touch it.

Solution

apply_heading_style wrote the per-level style onto the heading div only. The div's text style reaches layout, which is why the font sizes worked, but the text runs are shaped from MarkdownElementBuilder's style stack, and nothing ever pushed the level style onto that stack. So weight and color were dropped on the floor.

The fix pulls the level lookup out into heading_level_style and has push_markdown_heading refine the heading's run text style with it before pushing, alongside the existing div refinement. No style values change anywhere. The agent panel's level styles only set font size, so its rendering is identical before and after; I checked.

Testing

  • cargo test -p markdown and ./script/clippy are clean.
  • Smoke tested the preview on Linux with a document covering h1 to h6, headings containing bold, italic, code, and links, a wrapping heading, lists, blockquotes, tables, and code blocks. Headings are now semibold, h6 is muted, sizes and h1/h2 borders are unchanged.
  • Checked the agent panel with a reply containing headings, bold, a list, and a table: unchanged.
  • No new test. The test platform's text system is a no-op that returns the same FontId for every font, so an assertion on run weight could not fail.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments (there are none)
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior (see Testing for why not)
  • Performance impact has been considered and is acceptable

Showcase

Before is main at 399258f, which already includes #63118, so the only difference is the heading weight and the h6 color.

Before After
zed_before zed_after

Release Notes:

  • Fixed Markdown preview headings not rendering at their configured weight.

The preview declares a semibold weight and a muted h6 color in
heading_level_styles, but apply_heading_style only wrote them onto the
heading div. Text runs are shaped from the builder's style stack, which
never saw the per-level style, so headings rendered at the base weight
and color. Push the level style onto the stack as well; the div keeps
driving font size and line height for layout.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Aug 30, 2026
@ChristopherBiscardi ChristopherBiscardi self-assigned this Aug 31, 2026
@ChristopherBiscardi ChristopherBiscardi added the area:preview/markdown Feedback for Zed's Markdown preview label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:preview/markdown Feedback for Zed's Markdown preview cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants