diff options
author | iximeow <me@iximeow.net> | 2017-09-28 10:11:55 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2017-09-28 10:11:55 -0700 |
commit | 834d3f704556330cf0f39b86cc45f617fd93004a (patch) | |
tree | ce99a9bd2c52a03e11b9bf7952f34a083702a8c7 | |
parent | a4c8b5e8beca50ededc60197610fc1a6093c3ff9 (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.rs | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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") |