From ac460ac8371e2d7cfe99b9e06be9b8f5edac1c44 Mon Sep 17 00:00:00 2001 From: A-Walrus Date: Tue, 13 Sep 2022 12:14:16 +0300 Subject: Render html tags as code in markdown (#3425) --- helix-term/src/ui/markdown.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'helix-term/src/ui') diff --git a/helix-term/src/ui/markdown.rs b/helix-term/src/ui/markdown.rs index a0b299e7..923dd73a 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)) => { -- cgit v1.2.3-70-g09d2