Support rendering strikethrough text in markdown (#8287)

Just noticed strikethrough text handling was not implemented for the
following:

Chat

![image](https://github.com/zed-industries/zed/assets/53836821/ddd98272-d4d4-4a94-bd79-77e967f3ca15)

Markdown Preview

![image](https://github.com/zed-industries/zed/assets/53836821/9087635c-5b89-40e6-8e4d-2785a43ef318)

Code Documentation

![image](https://github.com/zed-industries/zed/assets/53836821/5ed55c60-3e5e-4fc2-86c2-a81fac7de038)

It looks like there are three different markdown parsing/rendering
implementations, might be worth to investigate if any of these can be
combined into a single crate (looks like a lot of work though).

Release Notes:

- Added support for rendering strikethrough text in markdown elements
This commit is contained in:
Bennet Bo Fenner 2024-02-26 20:04:48 +01:00 committed by GitHub
parent cd8ede542b
commit 43163a0154
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 187 additions and 69 deletions

View file

@ -1,4 +1,6 @@
use gpui::{px, FontStyle, FontWeight, HighlightStyle, SharedString, UnderlineStyle};
use gpui::{
px, FontStyle, FontWeight, HighlightStyle, SharedString, StrikethroughStyle, UnderlineStyle,
};
use language::HighlightId;
use std::{ops::Range, path::PathBuf};
@ -170,6 +172,13 @@ impl MarkdownHighlight {
});
}
if style.strikethrough {
highlight.strikethrough = Some(StrikethroughStyle {
thickness: px(1.),
..Default::default()
});
}
if style.weight != FontWeight::default() {
highlight.font_weight = Some(style.weight);
}
@ -189,6 +198,8 @@ pub struct MarkdownHighlightStyle {
pub italic: bool,
/// Whether the text should be underlined.
pub underline: bool,
/// Whether the text should be struck through.
pub strikethrough: bool,
/// The weight of the text.
pub weight: FontWeight,
}