From 848c276105f1270c519b5eed6206c6b49d3a11d3 Mon Sep 17 00:00:00 2001 From: A-Walrus <58790821+A-Walrus@users.noreply.github.com> Date: Tue, 13 Sep 2022 12:14:16 +0300 Subject: [PATCH] Render html tags as code in markdown (#3425) --- helix-term/src/ui/markdown.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/helix-term/src/ui/markdown.rs b/helix-term/src/ui/markdown.rs index a0b299e7c14c..923dd73a16ab 100644 --- a/helix-term/src/ui/markdown.rs +++ b/helix-term/src/ui/markdown.rs @@ -178,6 +178,21 @@ impl Markdown { .map(|key| get_theme(key)) .collect(); + // Transform text in `` blocks into `Event::Code` + let mut in_code = false; + let parser = parser.filter_map(|event| match event { + Event::Html(tag) if *tag == *"" => { + in_code = true; + None + } + Event::Html(tag) if *tag == *"" => { + in_code = false; + None + } + Event::Text(text) if in_code => Some(Event::Code(text)), + _ => Some(event), + }); + for event in parser { match event { Event::Start(Tag::List(list)) => {