From 834d3f704556330cf0f39b86cc45f617fd93004a Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 28 Sep 2017 10:11:55 -0700 Subject: suppoprt multi-line tweets decently also adjust \x0d to "\r" so \r in tweets doesn't mangle the displayed text --- main.rs | 7 ++++--- 1 file 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::>().join("\n ")); + println!(" {}", twete.text.replace("\r", "\\r").split("\n").collect::>().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::>().join("\n ") + qt.text.replace("\r", "\\r").split("\n").collect::>().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") -- cgit v1.1