Skip to content

Commit

Permalink
Render html <code> tags as code in markdown (helix-editor#3425)
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Walrus authored and Shekhinah Memmel committed Dec 11, 2022
1 parent c7a87c1 commit 848c276
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions helix-term/src/ui/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) => {
Expand Down

0 comments on commit 848c276

Please sign in to comment.