mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
Fix markdown indented code block rendering (#3503)
This commit is contained in:
parent
e4c9d4082a
commit
99b1e8ad89
@ -229,10 +229,7 @@ fn push_line<'a>(spans: &mut Vec<Span<'a>>, lines: &mut Vec<Spans<'a>>) {
|
||||
Event::End(tag) => {
|
||||
tags.pop();
|
||||
match tag {
|
||||
Tag::Heading(_, _, _)
|
||||
| Tag::Paragraph
|
||||
| Tag::CodeBlock(CodeBlockKind::Fenced(_))
|
||||
| Tag::Item => {
|
||||
Tag::Heading(_, _, _) | Tag::Paragraph | Tag::CodeBlock(_) | Tag::Item => {
|
||||
push_line(&mut spans, &mut lines);
|
||||
}
|
||||
_ => (),
|
||||
@ -240,17 +237,18 @@ fn push_line<'a>(spans: &mut Vec<Span<'a>>, lines: &mut Vec<Spans<'a>>) {
|
||||
|
||||
// whenever heading, code block or paragraph closes, empty line
|
||||
match tag {
|
||||
Tag::Heading(_, _, _)
|
||||
| Tag::Paragraph
|
||||
| Tag::CodeBlock(CodeBlockKind::Fenced(_)) => {
|
||||
Tag::Heading(_, _, _) | Tag::Paragraph | Tag::CodeBlock(_) => {
|
||||
lines.push(Spans::default());
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
Event::Text(text) => {
|
||||
// TODO: temp workaround
|
||||
if let Some(Tag::CodeBlock(CodeBlockKind::Fenced(language))) = tags.last() {
|
||||
if let Some(Tag::CodeBlock(kind)) = tags.last() {
|
||||
let language = match kind {
|
||||
CodeBlockKind::Fenced(language) => language,
|
||||
CodeBlockKind::Indented => "",
|
||||
};
|
||||
let tui_text = highlighted_code_block(
|
||||
text.to_string(),
|
||||
language,
|
||||
|
Loading…
Reference in New Issue
Block a user