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

View File

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

View File

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