Skip to content

Commit

Permalink
Style Bold/Italic/Strikethrough markdown in docs (helix-editor#8385)
Browse files Browse the repository at this point in the history
* Style Bold/Italic/Strikthrough markdown in docs

* Flatten to single match
  • Loading branch information
A-Walrus authored and mtoohey31 committed Jun 2, 2024
1 parent f8de6c6 commit ac07fd6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions helix-term/src/ui/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use helix_core::{
};
use helix_view::{
graphics::{Margin, Rect, Style},
theme::Modifier,
Theme,
};

Expand Down Expand Up @@ -275,17 +276,21 @@ impl Markdown {
);
lines.extend(tui_text.lines.into_iter());
} else {
let style = if let Some(Tag::Heading(level, ..)) = tags.last() {
match level {
let style = match tags.last() {
Some(Tag::Heading(level, ..)) => match level {
HeadingLevel::H1 => heading_styles[0],
HeadingLevel::H2 => heading_styles[1],
HeadingLevel::H3 => heading_styles[2],
HeadingLevel::H4 => heading_styles[3],
HeadingLevel::H5 => heading_styles[4],
HeadingLevel::H6 => heading_styles[5],
},
Some(Tag::Emphasis) => text_style.add_modifier(Modifier::ITALIC),
Some(Tag::Strong) => text_style.add_modifier(Modifier::BOLD),
Some(Tag::Strikethrough) => {
text_style.add_modifier(Modifier::CROSSED_OUT)
}
} else {
text_style
_ => text_style,
};
spans.push(Span::styled(text, style));
}
Expand Down

0 comments on commit ac07fd6

Please sign in to comment.