aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2017-09-28 10:11:55 -0700
committeriximeow <me@iximeow.net>2017-09-28 10:11:55 -0700
commit834d3f704556330cf0f39b86cc45f617fd93004a (patch)
treece99a9bd2c52a03e11b9bf7952f34a083702a8c7
parenta4c8b5e8beca50ededc60197610fc1a6093c3ff9 (diff)
suppoprt multi-line tweets decently
also adjust \x0d to "\r" so \r in tweets doesn't mangle the displayed text
-rw-r--r--main.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/main.rs b/main.rs
index 3b6624d..5d5991c 100644
--- a/main.rs
+++ b/main.rs
@@ -760,7 +760,7 @@ fn render_twete(twete_id: &String, tweeter: &tw::TwitterCache) {
}
}
- println!(" {}", twete.text.split("\n").collect::<Vec<&str>>().join("\n "));
+ println!(" {}", twete.text.replace("\r", "\\r").split("\n").collect::<Vec<&str>>().join("\n "));
if let Some(ref qt_id) = twete.quoted_tweet_id {
if let Some(ref qt) = tweeter.retrieve_tweet(qt_id) {
@@ -775,7 +775,7 @@ fn render_twete(twete_id: &String, tweeter: &tw::TwitterCache) {
);
println!(
" {}",
- qt.text.split("\n").collect::<Vec<&str>>().join("\n ")
+ qt.text.replace("\r", "\\r").split("\n").collect::<Vec<&str>>().join("\n ")
);
} else {
println!(" << don't have quoted tweet! >>");
@@ -1030,7 +1030,8 @@ fn url_encode(s: &str) -> String {
s
.replace(" ", "+")
.replace("%", "%25")
- .replace("\\n", "%0d")
+ .replace("\\n", "%0a")
+ .replace("\\r", "%0d")
.replace("!", "%21")
.replace("#", "%23")
.replace("&", "%26")