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 | d5a5ffdcfb00c2f56afc352d445ba485b20d77fd (patch) | |
tree | ce99a9bd2c52a03e11b9bf7952f34a083702a8c7 | |
parent | 0f88655798ebe3e5c63e6a984e58afae494168cd (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") |