Decode HTML Entities inside Tweet

This commit is contained in:
VC
2020-03-03 18:38:49 +01:00
parent 342b1c1700
commit aae59f641e

View File

@@ -37,6 +37,9 @@ use mammut::{
// reqwest
use reqwest::blocking::Client;
// htmlescape
use htmlescape::decode_html;
/**********
* Generic usage functions
***********/
@@ -144,9 +147,9 @@ fn build_basic_status(tweet: &Tweet) -> Result<StatusBuilder, Box<dyn Error>> {
toot = toot.replace(&decoded_url.0, &decoded_url.1);
}
// remove the &amp; and replace it with &
// this is the only entities and/or char that is not available via Twitter API
toot = toot.replace("&amp;", "&");
if let Ok(t) = decode_html(&toot) {
toot = t;
}
Ok(StatusBuilder::new(toot))
}