Skip to content

Commit

Permalink
Render html <code> tags as code in markdown (#3425)
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Walrus authored Sep 13, 2022
1 parent ffb41a9 commit ac460ac
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 ac460ac

Please sign in to comment.