From 5b4a9c3e2d2cb904fa2aa3c94a4a13a26b191d37 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Fri, 31 May 2024 18:38:16 +0200 Subject: [PATCH] don't format inline html tags --- src/convert.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/convert.rs b/src/convert.rs index 2e81fd2..93df3e2 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -64,6 +64,7 @@ fn convert_line(source: &str) -> String { let mut is_b = false; let mut is_code = false; let mut is_ul = false; + let mut is_html_tag = false; let toggle = |state: bool, tag: &str| { if state { format!("<{tag}>") @@ -76,6 +77,13 @@ fn convert_line(source: &str) -> String { let mut chars = source.chars().peekable(); while let Some(c) = chars.next() { + if is_html_tag { + out.push(c); + if c == '>' { + is_html_tag = false; + } + continue; + } if let Some(link_c) = &mut link { match link_c { (link_text, None) => { @@ -119,6 +127,9 @@ fn convert_line(source: &str) -> String { } else if c == '_' { is_ul = !is_ul; out += &toggle(is_ul, "u"); + } else if c == '<' { + out.push(c); + is_html_tag = true; } else { out.push(c); }