aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorA-Walrus2022-09-13 09:14:16 +0000
committerGitHub2022-09-13 09:14:16 +0000
commitac460ac8371e2d7cfe99b9e06be9b8f5edac1c44 (patch)
tree137fa812400c92c32e4fabab7afa8871a6b00bf2 /helix-term/src
parentffb41a94f040e251a3269e0d13417b16bef244c0 (diff)
Render html <code> tags as code in markdown (#3425)
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/ui/markdown.rs15
1 files changed, 15 insertions, 0 deletions
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 `<code>` blocks into `Event::Code`
+ let mut in_code = false;
+ let parser = parser.filter_map(|event| match event {
+ Event::Html(tag) if *tag == *"<code>" => {
+ in_code = true;
+ None
+ }
+ Event::Html(tag) if *tag == *"</code>" => {
+ 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)) => {