markdown_preview: Independent font family and theme#54003
markdown_preview: Independent font family and theme#54003ChristopherBiscardi merged 2 commits intozed-industries:mainfrom
Conversation
|
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 🖊️ |
|
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'. |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
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'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
This comment was marked as spam.
This comment was marked as spam.
|
@Anthony-Eid 🙏🏼 |
44693b4 to
855c40c
Compare
855c40c to
78861f2
Compare
ChristopherBiscardi
left a comment
There was a problem hiding this comment.
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:
markdown_preview_font_sizeseems to only apply to code blocksmarkdown_preview_line_heightdoesn't seem to apply when viewing preview
|
@ChristopherBiscardi thanks for the review:
|
ChristopherBiscardi
left a comment
There was a problem hiding this comment.
Currently:
markdown_preview_font_sizeisn't applying to paragraph text, links, list elements, and such. Screenshot here shows a small font size set.- similarly
markdown_preview_line_heightdoesn't apply to code blocks.
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.
63839f8 to
606cc04
Compare
|
@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! The scope now is:
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. |




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
MarkdownFont::Previewvariant, used only by the preview surface.MarkdownStyle::themed_with_overrides()that accepts explicitThemeColorsandSyntaxThemeso the preview can render with a theme other than the active editor theme. Existingthemed()callers are unchanged.editor_background.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— schemacrates/theme_settings/src/settings.rs— runtime + accessorcrates/markdown/src/markdown.rs—MarkdownFont::Preview+themed_with_overrides()crates/markdown_preview/src/markdown_preview_view.rs— theme resolution, style selection, backgroundcrates/markdown_preview/Cargo.toml—themedependencycrates/settings/src/vscode_import.rs— new fields in struct literalRelease Notes:
markdown_preview_font_familyandmarkdown_preview_themesettings to customize the markdown preview independently from the editor.