From 45f134e7d08547ff73f297c4bfcf7b9aca05e89b Mon Sep 17 00:00:00 2001 From: Shengyu Zhang Date: Sat, 12 Apr 2025 14:11:29 +0800 Subject: [PATCH] Break line when encountering
tag --- src/decoders/html.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/decoders/html.rs b/src/decoders/html.rs index f1b9f480..579d74e8 100644 --- a/src/decoders/html.rs +++ b/src/decoders/html.rs @@ -78,7 +78,8 @@ pub fn html_to_text(input: &str) -> String { match input.get(token_start..token_end + 1) { Some(tag) if tag.eq_ignore_ascii_case(b"br") - || (tag.eq_ignore_ascii_case(b"p") && is_tag_close) => + || (tag.eq_ignore_ascii_case(b"p") && is_tag_close) + || (tag.eq_ignore_ascii_case(b"div") && is_tag_close) => { result.push('\n'); is_after_space = false; @@ -2390,6 +2391,13 @@ mod tests { "

please unsubscribe here.

", "please unsubscribe here.\n", ), + ( + concat!( + "
what is the
weather
", + "today
" + ), + "what is the\nweather today\n", + ), ]; for input in inputs {