From a4bbb0be684baec329b9ff59b240ba1669986dd6 Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 3 Sep 2025 16:13:56 +0300 Subject: [PATCH] add strip tags function --- Cargo.toml | 1 + src/main.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 251ff04..386d4ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ log = "0.4" reqwest = { version = "0.12", features = ["blocking"] } rss = "2.0" serde = { version = "1.0", features = ["derive"] } +strip-tags = "0.1" toml = "0.9" tracing-subscriber = { version = "0.3", features = ["env-filter"] } url = "2.5" diff --git a/src/main.rs b/src/main.rs index 6b6b08d..52f82d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ use std::{ io::Write, path::PathBuf, }; +use strip_tags::*; fn main() -> Result<()> { if var("RUST_LOG").is_ok() { @@ -86,8 +87,8 @@ fn crawl(feed: &Feed) -> Result<()> { })? .write_all( index - .replace("{title}", channel.title()) - .replace("{description}", channel.description()) + .replace("{title}", &strip_tags(channel.title())) + .replace("{description}", &strip_tags(channel.description())) .replace("{link}", channel.link()) .replace("{language}", channel.language().unwrap_or_default()) .replace( @@ -106,8 +107,11 @@ fn crawl(feed: &Feed) -> Result<()> { .take(channel_items_limit) .map(|i| { index_item - .replace("{title}", i.title().unwrap_or_default()) - .replace("{description}", i.description().unwrap_or_default()) + .replace("{title}", &strip_tags(i.title().unwrap_or_default())) + .replace( + "{description}", + &strip_tags(i.description().unwrap_or_default()), + ) .replace("{link}", i.link().unwrap_or_default()) .replace("{pub_date}", &time(i.pub_date(), &feed.pub_date_format)) })