Skip to content

Commit

Permalink
Fix markdown indented code block rendering (helix-editor#3503)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorlay authored and jdrst committed Sep 13, 2022
1 parent 20997e2 commit 779e010
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions helix-term/src/ui/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,28 +229,26 @@ impl Markdown {
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);
}
_ => (),
}

// 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,
Expand Down

0 comments on commit 779e010

Please sign in to comment.