MCPcopy Create free account
hub / github.com/GCWing/BitFun / extract_description_from_html

Function extract_description_from_html

src/apps/desktop/src/api/skill_api.rs:1307–1330  ·  view source on GitHub ↗
(html: &str)

Source from the content-addressed store, hash-verified

1305}
1306
1307fn extract_description_from_html(html: &str) -> Option<String> {
1308 if let Some(prose_index) = html.find("class=\"prose") {
1309 let scope = &html[prose_index..];
1310 if let Some(p_start) = scope.find("<p>") {
1311 let content = &scope[p_start + 3..];
1312 if let Some(p_end) = content.find("</p>") {
1313 let raw = &content[..p_end];
1314 let normalized = normalize_html_text(raw);
1315 if !normalized.is_empty() {
1316 return Some(limit_text_len(&normalized, MARKET_DESC_MAX_LEN));
1317 }
1318 }
1319 }
1320 }
1321
1322 if let Some(twitter_desc) = extract_meta_content(html, "twitter:description") {
1323 let normalized = normalize_html_text(&twitter_desc);
1324 if is_meaningful_meta_description(&normalized) {
1325 return Some(limit_text_len(&normalized, MARKET_DESC_MAX_LEN));
1326 }
1327 }
1328
1329 None
1330}
1331
1332fn extract_meta_content(html: &str, key: &str) -> Option<String> {
1333 let pattern = format!(r#"<meta name="{}" content="([^"]+)""#, regex::escape(key));

Callers 1

Calls 5

normalize_html_textFunction · 0.85
limit_text_lenFunction · 0.85
extract_meta_contentFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected