markdown: Respect preview theme for bold text (#63940)

# Objective

Fixes #62814.

Zed displays Markdown files in two ways:

- The editor shows the Markdown source that you type, such as `**bold
text**`.
- The Markdown preview shows the same file as a formatted document, with
the `**` markers hidden.

The editor and the formatted preview can use different color themes.
Currently, normal words in the formatted preview use the preview colors,
but bold words incorrectly use the editor colors. For example, with a
dark editor and a light preview, bold words can appear very light
against a light background and become difficult to read.

## Solution

Make bold formatting change only the font weight. Bold words now inherit
the color of the surrounding formatted document, including the color
selected by the Markdown preview theme.

Related work: #62837 identified the same root cause and attempted a fix
but was closed.

## Testing

- `cargo test -p markdown`
- `cargo test -p markdown_preview`
- `cargo fmt --all -- --check`
- `./script/clippy -p markdown`

## Self-Review Checklist:

- [x] I reviewed the diff for quality, security, and reliability
- [x] Unsafe blocks, if any, have justifying comments
- [x] The content follows Zed UI standards
- [x] Tests cover the changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed bold words using the wrong color theme in Markdown previews.

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
This commit is contained in:
Ibrahim Khan
2026-11-06 13:29:11 +00:00
committed by GitHub
parent 78fde14d12
commit db43f05e39
-1
View File
@@ -3013,7 +3013,6 @@ impl Element for MarkdownElement {
}),
MarkdownTag::Strong => builder.push_text_style(TextStyleRefinement {
font_weight: Some(FontWeight::BOLD),
color: Some(cx.theme().colors().text),
..Default::default()
}),
MarkdownTag::Strikethrough => {