on master help sign in
Style Bold/Italic/Strikethrough markdown in docs (#8385)
f520b16A-Walrus
helix-term/src/ui/markdown.rs+9−4
@@ -14,6 +14,7 @@ use helix_core::{
14};
14};
15use helix_view::{
15use helix_view::{
16 graphics::{Margin, Rect, Style},
16 graphics::{Margin, Rect, Style},
17+ theme::Modifier,
17 Theme,
18 Theme,
18};
19};
19
20
@@ -275,17 +276,21 @@ impl Markdown {
275 );
276 );
276 lines.extend(tui_text.lines.into_iter());
277 lines.extend(tui_text.lines.into_iter());
277 } else {
278 } else {
279+ let style = match tags.last() {
278− let style = if let Some(Tag::Heading(level, ..)) = tags.last() {
280+ Some(Tag::Heading(level, ..)) => match level {
279− match level {
280 HeadingLevel::H1 => heading_styles[0],
281 HeadingLevel::H1 => heading_styles[0],
281 HeadingLevel::H2 => heading_styles[1],
282 HeadingLevel::H2 => heading_styles[1],
282 HeadingLevel::H3 => heading_styles[2],
283 HeadingLevel::H3 => heading_styles[2],
283 HeadingLevel::H4 => heading_styles[3],
284 HeadingLevel::H4 => heading_styles[3],
284 HeadingLevel::H5 => heading_styles[4],
285 HeadingLevel::H5 => heading_styles[4],
285 HeadingLevel::H6 => heading_styles[5],
286 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)
286 }
292 }
287− } else {
288− text_style
293+ _ => text_style,
289 };
294 };
290 spans.push(Span::styled(text, style));
295 spans.push(Span::styled(text, style));
291 }
296 }