on master help sign in
Fix markdown indented code block rendering (#3503)
99b1e8aClay
helix-term/src/ui/markdown.rs+7−9
@@ -229,10 +229,7 @@ impl Markdown {
229 Event::End(tag) => {
229 Event::End(tag) => {
230 tags.pop();
230 tags.pop();
231 match tag {
231 match tag {
232− Tag::Heading(_, _, _)
232+ Tag::Heading(_, _, _) | Tag::Paragraph | Tag::CodeBlock(_) | Tag::Item => {
233− | Tag::Paragraph
234− | Tag::CodeBlock(CodeBlockKind::Fenced(_))
235− | Tag::Item => {
236 push_line(&mut spans, &mut lines);
233 push_line(&mut spans, &mut lines);
237 }
234 }
238 _ => (),
235 _ => (),
@@ -240,17 +237,18 @@ impl Markdown {
240
237
241 // whenever heading, code block or paragraph closes, empty line
238 // whenever heading, code block or paragraph closes, empty line
242 match tag {
239 match tag {
243− Tag::Heading(_, _, _)
240+ Tag::Heading(_, _, _) | Tag::Paragraph | Tag::CodeBlock(_) => {
244− | Tag::Paragraph
245− | Tag::CodeBlock(CodeBlockKind::Fenced(_)) => {
246 lines.push(Spans::default());
241 lines.push(Spans::default());
247 }
242 }
248 _ => (),
243 _ => (),
249 }
244 }
250 }
245 }
251 Event::Text(text) => {
246 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+ };
254 let tui_text = highlighted_code_block(
252 let tui_text = highlighted_code_block(
255 text.to_string(),
253 text.to_string(),
256 language,
254 language,