MCPcopy Create free account
hub / github.com/devflowinc/trieve / extract_text_from_html

Function extract_text_from_html

server/src/operators/parse_operator.rs:15–26  ·  view source on GitHub ↗
(html: &str)

Source from the content-addressed store, hash-verified

13}
14
15pub fn extract_text_from_html(html: &str) -> String {
16 let document = Html::parse_document(html);
17 let selector = Selector::parse("body").unwrap();
18
19 document
20 .select(&selector)
21 .flat_map(|element| element.text())
22 .map(|text| text.trim())
23 .filter(|text| !text.is_empty())
24 .collect::<Vec<_>>()
25 .join(" ")
26}
27
28pub fn coarse_remove_large_chunks(cur_chunks: Vec<String>) -> Vec<String> {
29 let max_chunk_len = 10000;

Callers

nothing calls this directly

Calls 2

parseFunction · 0.85
trimMethod · 0.80

Tested by

no test coverage detected