mirror of
https://github.com/helix-editor/helix.git
synced 2025-04-05 03:47:51 +03:00
Style Bold/Italic/Strikethrough markdown in docs (#8385)
* Style Bold/Italic/Strikthrough markdown in docs * Flatten to single match
This commit is contained in:
parent
0252c7b162
commit
f520b16fca
1 changed files with 9 additions and 4 deletions
|
@ -14,6 +14,7 @@ use helix_core::{
|
||||||
};
|
};
|
||||||
use helix_view::{
|
use helix_view::{
|
||||||
graphics::{Margin, Rect, Style},
|
graphics::{Margin, Rect, Style},
|
||||||
|
theme::Modifier,
|
||||||
Theme,
|
Theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -275,17 +276,21 @@ impl Markdown {
|
||||||
);
|
);
|
||||||
lines.extend(tui_text.lines.into_iter());
|
lines.extend(tui_text.lines.into_iter());
|
||||||
} else {
|
} else {
|
||||||
let style = if let Some(Tag::Heading(level, ..)) = tags.last() {
|
let style = match tags.last() {
|
||||||
match level {
|
Some(Tag::Heading(level, ..)) => match level {
|
||||||
HeadingLevel::H1 => heading_styles[0],
|
HeadingLevel::H1 => heading_styles[0],
|
||||||
HeadingLevel::H2 => heading_styles[1],
|
HeadingLevel::H2 => heading_styles[1],
|
||||||
HeadingLevel::H3 => heading_styles[2],
|
HeadingLevel::H3 => heading_styles[2],
|
||||||
HeadingLevel::H4 => heading_styles[3],
|
HeadingLevel::H4 => heading_styles[3],
|
||||||
HeadingLevel::H5 => heading_styles[4],
|
HeadingLevel::H5 => heading_styles[4],
|
||||||
HeadingLevel::H6 => heading_styles[5],
|
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));
|
spans.push(Span::styled(text, style));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue