Skip to content

Commit c6b21cb

Browse files
committed
Fix markdown indented code block rendering
1 parent 18909aa commit c6b21cb

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

helix-term/src/ui/markdown.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,28 +229,26 @@ impl Markdown {
229229
Event::End(tag) => {
230230
tags.pop();
231231
match tag {
232-
Tag::Heading(_, _, _)
233-
| Tag::Paragraph
234-
| Tag::CodeBlock(CodeBlockKind::Fenced(_))
235-
| Tag::Item => {
232+
Tag::Heading(_, _, _) | Tag::Paragraph | Tag::CodeBlock(_) | Tag::Item => {
236233
push_line(&mut spans, &mut lines);
237234
}
238235
_ => (),
239236
}
240237

241238
// whenever heading, code block or paragraph closes, empty line
242239
match tag {
243-
Tag::Heading(_, _, _)
244-
| Tag::Paragraph
245-
| Tag::CodeBlock(CodeBlockKind::Fenced(_)) => {
240+
Tag::Heading(_, _, _) | Tag::Paragraph | Tag::CodeBlock(_) => {
246241
lines.push(Spans::default());
247242
}
248243
_ => (),
249244
}
250245
}
251246
Event::Text(text) => {
252-
// TODO: temp workaround
253-
if let Some(Tag::CodeBlock(CodeBlockKind::Fenced(language))) = tags.last() {
247+
if let Some(Tag::CodeBlock(kind)) = tags.last() {
248+
let language = match kind {
249+
CodeBlockKind::Fenced(language) => language,
250+
CodeBlockKind::Indented => "",
251+
};
254252
let tui_text = highlighted_code_block(
255253
text.to_string(),
256254
language,

0 commit comments

Comments
 (0)