Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rendering of indented code blocks in markdown #3503

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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