Skip to content

markdown_preview: Independent font family and theme#54003

Merged
ChristopherBiscardi merged 2 commits intozed-industries:mainfrom
robinojw:feat/markdown-preview-readability
Apr 23, 2026
Merged

markdown_preview: Independent font family and theme#54003
ChristopherBiscardi merged 2 commits intozed-industries:mainfrom
robinojw:feat/markdown-preview-readability

Conversation

@robinojw
Copy link
Copy Markdown
Contributor

@robinojw robinojw commented Apr 15, 2026

Summary

Adds two user-facing settings that let the markdown preview render with a font family and theme independent from the editor. Both are optional and fall back to the editor defaults when unset.

{
  "markdown_preview_font_family": "Georgia",
  "markdown_preview_theme": "Solarized Light"
}

Details

  • New MarkdownFont::Preview variant, used only by the preview surface.
  • New MarkdownStyle::themed_with_overrides() that accepts explicit ThemeColors and SyntaxTheme so the preview can render with a theme other than the active editor theme. Existing themed() callers are unchanged.
  • The preview pane background adopts the chosen theme's editor_background.
  • Follows the pattern already used by agent_ui_font_size / agent_buffer_font_size.

Scope

Sizing-related changes (markdown_preview_font_size, markdown_preview_line_height, typography tweaks, responsive max-width container) were in an earlier revision of this PR and have been removed per review feedback — they interact with the Cmd+/- zoom behavior in ways that still need design work, and will land in a follow-up.

Files Changed

  • crates/settings_content/src/theme.rs — schema
  • crates/theme_settings/src/settings.rs — runtime + accessor
  • crates/markdown/src/markdown.rsMarkdownFont::Preview + themed_with_overrides()
  • crates/markdown_preview/src/markdown_preview_view.rs — theme resolution, style selection, background
  • crates/markdown_preview/Cargo.tomltheme dependency
  • crates/settings/src/vscode_import.rs — new fields in struct literal

Release Notes:

  • Added markdown_preview_font_family and markdown_preview_theme settings to customize the markdown preview independently from the editor.

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 15, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @robinojw on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Apr 15, 2026
@robinojw
Copy link
Copy Markdown
Contributor Author

We require contributors to sign our Contributor License Agreement, and we don't have @robinojw on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

Signed 🖊️

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 15, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @robinojw on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@robinojw robinojw marked this pull request as ready for review April 15, 2026 18:44
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 15, 2026

The cla-bot has been summoned, and re-checked this pull request!

@zed-codeowner-coordinator zed-codeowner-coordinator Bot requested review from a team, Anthony-Eid and danilo-leal and removed request for a team April 15, 2026 18:45
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 16, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @robinojw on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@robinojw
Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 16, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 16, 2026

The cla-bot has been summoned, and re-checked this pull request!

@robinojw
Copy link
Copy Markdown
Contributor Author

robinojw commented Apr 16, 2026

Screenshots

Before:
Screenshot 2026-04-16 at 3 54 32 PM

After:
Screenshot 2026-04-16 at 3 48 14 PM

Custom font etc:
Screenshot 2026-04-16 at 3 35 01 PM

@dshap474

This comment was marked as spam.

@robinojw
Copy link
Copy Markdown
Contributor Author

@Anthony-Eid 🙏🏼

@robinojw robinojw force-pushed the feat/markdown-preview-readability branch from 44693b4 to 855c40c Compare April 22, 2026 02:13
@robinojw robinojw changed the title feat(markdown_preview): independent font, theme, and typographic improvements markdown_preview: Independent font, theme, and typographic improvements Apr 22, 2026
@robinojw robinojw force-pushed the feat/markdown-preview-readability branch from 855c40c to 78861f2 Compare April 22, 2026 02:20
Copy link
Copy Markdown
Contributor

@ChristopherBiscardi ChristopherBiscardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems interesting as a feature, and is a decent set of starting configurations.

markdown_preview_font_family and markdown_preview_theme work as expected. In an ideal world we probably want the ability to set the font family differently for headings and paragraph text, but I don't think we support that now, so its fine that this PR doesn't address that.

However a couple options seem to apply to selective elements, or no elements, as seen in this screenshot:

Image
  • markdown_preview_font_size seems to only apply to code blocks
  • markdown_preview_line_height doesn't seem to apply when viewing preview

@robinojw
Copy link
Copy Markdown
Contributor Author

robinojw commented Apr 22, 2026

@ChristopherBiscardi thanks for the review:

  • markdown_preview_font_size: preview heading sizes are now computed as multiples of the configured font size (h1 = 2.0×, h2 = 1.6×, h3 = 1.3×, h4 = 1.1×, h5 = 1.0×, h6 = 0.9×) instead of being pinned to GPUI's default rem base, so the setting scales the whole preview (headings + body + code) rather than only code blocks. Paragraph body text already picked up the setting via base_text_style, but the visual effect was dominated by the unchanged headings.
  • markdown_preview_line_height: preview paragraphs now use the configured line-height instead of a fixed 1.6. List items also pick it up (floored at 1.5 so tight rows don't clip).

Copy link
Copy Markdown
Contributor

@ChristopherBiscardi ChristopherBiscardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently:

  • markdown_preview_font_size isn't applying to paragraph text, links, list elements, and such. Screenshot here shows a small font size set.
  • similarly markdown_preview_line_height doesn't apply to code blocks.
Image

I also noticed the markdown preview is not responsive to Cmd+/- at all, which means you can't zoom in or out. That is notably different than how other text works (like regular .md files, etc). It turns out that on main Cmd+/- only affects codeblocks in the preview, so there seems to be some buggy interactions here, but this PR removes the ability that current exists to zoom those codeblocks. I feel fairly strongy that since this PR touches font sizing and makes it theme-able that zooming should work with that theming.

Also we should remove the "responsive container size" for the markdown document. The pane is already sizeable by users and the responsive container doesn't have a large impact on the display.


Since the sizing has gone through a couple of rounds now, I think we could move the size-related changes to a different PR and keep the font family/theme selection changes here. The theme/font family changes look good, but the sizing changes seem like they still need some work.

Adds two settings that let the markdown preview render independently
from the editor:

- `markdown_preview_font_family` — font family used for the preview
  body, falling back to the UI font.
- `markdown_preview_theme` — theme used for the preview, falling back
  to the active editor theme.

Plumbed via a new `MarkdownFont::Preview` variant and
`MarkdownStyle::themed_with_overrides`, which accepts explicit
`ThemeColors` and `SyntaxTheme` so the preview can render with a
theme other than the active one. The preview pane background adopts
the chosen theme's `editor_background`.

Release Notes:

- Added `markdown_preview_font_family` and `markdown_preview_theme`
  settings to customize the markdown preview independently from the
  editor.
@robinojw robinojw force-pushed the feat/markdown-preview-readability branch from 63839f8 to 606cc04 Compare April 23, 2026 14:09
@robinojw robinojw changed the title markdown_preview: Independent font, theme, and typographic improvements markdown_preview: Independent font family and theme Apr 23, 2026
@robinojw
Copy link
Copy Markdown
Contributor Author

robinojw commented Apr 23, 2026

@ChristopherBiscardi agreed, dropped all the sizing/line-height/typography/responsive-container changes in 606cc04 and kept just font family + theme selection as you suggested.

Just wanted to say thank you for being so kind and bearing with me here!
I know how time consuming these tests/reviews can be. I've tested on my local and everything looks good.

The scope now is:

  • markdown_preview_font_family (falls back to UI font)
  • markdown_preview_theme (falls back to active editor theme)

Size-related changes will come back in a follow-up PR so the Cmd+/- zoom interaction can be thought through properly. PR title + body updated to reflect the reduced scope.

Copy link
Copy Markdown
Contributor

@ChristopherBiscardi ChristopherBiscardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for taking the feedback so well! This looks good to me now.

Image

@ChristopherBiscardi ChristopherBiscardi added this pull request to the merge queue Apr 23, 2026
Merged via the queue into zed-industries:main with commit a1cb370 Apr 23, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants