Merge branch 'html_entities' into 'master'

Html entities

See merge request veretcle/scootaloo!4
This commit is contained in:
VC
2020-03-03 18:41:45 +01:00
3 changed files with 17 additions and 5 deletions

9
Cargo.lock generated
View File

@@ -620,6 +620,12 @@ dependencies = [
"digest",
]
[[package]]
name = "htmlescape"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163"
[[package]]
name = "http"
version = "0.1.21"
@@ -1492,10 +1498,11 @@ dependencies = [
[[package]]
name = "scootaloo"
version = "0.1.4"
version = "0.1.5"
dependencies = [
"clap",
"egg-mode",
"htmlescape",
"mammut",
"reqwest 0.10.3",
"serde",

View File

@@ -1,6 +1,6 @@
[package]
name = "scootaloo"
version = "0.1.4"
version = "0.1.5"
authors = ["VC <veretcle+framagit@mateu.be>"]
edition = "2018"
@@ -17,3 +17,5 @@ egg-mode = "^0.13"
mammut = "^0.13"
reqwest = { version = "^0.10", features = ["blocking"] }
htmlescape = "^0.3"

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))
}