on master help sign in
Style Bold/Italic/Strikethrough markdown in docs (#8385)

* Style Bold/Italic/Strikthrough markdown in docs * Flatten to single match

commitf520b16fcaa2bc13d8d72c09694d88717055d0fd authorA-Walrus <58790821+A-Walrus@users.noreply.github.com> dateMon 25 Sep 2023, 18:42 (3 years ago) parent0252c7b
1 file changed+9−4
helix-term/src/ui/markdown.rs+9−4
helix-term/src/ui/markdown.rs+9−4
@@ -14,6 +14,7 @@ use helix_core::{
1414};
1515use helix_view::{
1616 graphics::{Margin, Rect, Style},
17+ theme::Modifier,
1718 Theme,
1819};
1920
@@ -275,17 +276,21 @@ impl Markdown {
275276 );
276277 lines.extend(tui_text.lines.into_iter());
277278 } else {
278− let style = if let Some(Tag::Heading(level, ..)) = tags.last() {
279− match level {
279+ let style = match tags.last() {
280+ Some(Tag::Heading(level, ..)) => match level {
280281 HeadingLevel::H1 => heading_styles[0],
281282 HeadingLevel::H2 => heading_styles[1],
282283 HeadingLevel::H3 => heading_styles[2],
283284 HeadingLevel::H4 => heading_styles[3],
284285 HeadingLevel::H5 => heading_styles[4],
285286 HeadingLevel::H6 => heading_styles[5],
287+ },
288+ Some(Tag::Emphasis) => text_style.add_modifier(Modifier::ITALIC),
289+ Some(Tag::Strong) => text_style.add_modifier(Modifier::BOLD),
290+ Some(Tag::Strikethrough) => {
291+ text_style.add_modifier(Modifier::CROSSED_OUT)
286292 }
287− } else {
288− text_style
293+ _ => text_style,
289294 };
290295 spans.push(Span::styled(text, style));
291296 }