MCPcopy Create free account
hub / github.com/chatmail/core / dehtml

Function dehtml

src/dehtml.rs:80–104  ·  view source on GitHub ↗
(buf: &str)

Source from the content-addressed store, hash-verified

78}
79
80pub(crate) fn dehtml(buf: &str) -> Option<SimplifiedText> {
81 let (s, quote) = dehtml_quick_xml(buf);
82 if !s.trim().is_empty() {
83 let text = dehtml_cleanup(s);
84 let top_quote = if !quote.trim().is_empty() {
85 Some(dehtml_cleanup(simplify_quote(&quote).0))
86 } else {
87 None
88 };
89 return Some(SimplifiedText {
90 text,
91 top_quote,
92 ..Default::default()
93 });
94 }
95 let s = dehtml_manually(buf);
96 if !s.trim().is_empty() {
97 let text = dehtml_cleanup(s);
98 return Some(SimplifiedText {
99 text,
100 ..Default::default()
101 });
102 }
103 None
104}
105
106fn dehtml_cleanup(mut text: String) -> String {
107 text.retain(|c| c != '\r');

Callers 12

test_dehtml_parse_brFunction · 0.85
test_dehtml_parse_pFunction · 0.85
test_dehtml_parse_hrefFunction · 0.85
test_dehtml_bold_textFunction · 0.85
test_dehtml_html_encodedFunction · 0.85
test_unclosed_tagsFunction · 0.85
test_pre_tagFunction · 0.85
test_hp_legacy_displayFunction · 0.85
test_quote_divFunction · 0.85
test_spacesFunction · 0.85

Calls 5

dehtml_quick_xmlFunction · 0.85
dehtml_cleanupFunction · 0.85
simplify_quoteFunction · 0.85
dehtml_manuallyFunction · 0.85
is_emptyMethod · 0.45

Tested by 11

test_dehtml_parse_brFunction · 0.68
test_dehtml_parse_pFunction · 0.68
test_dehtml_parse_hrefFunction · 0.68
test_dehtml_bold_textFunction · 0.68
test_dehtml_html_encodedFunction · 0.68
test_unclosed_tagsFunction · 0.68
test_pre_tagFunction · 0.68
test_hp_legacy_displayFunction · 0.68
test_quote_divFunction · 0.68
test_spacesFunction · 0.68