From 690a33b75a34459aa916c7bdf9fd84497d950256 Mon Sep 17 00:00:00 2001 From: Eliseo Ocampos Date: Wed, 30 Mar 2016 16:00:56 -0400 Subject: [PATCH] Preserve line breaks on displayed tweets Preserve line breaks on received tweet so we can display it with original format Signed-off-by: Eliseo Ocampos --- rainbowstream/draw.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index 756604e..b9373d3 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -273,7 +273,8 @@ def draw(t, keyword=None, humanize=True, noti=False, fil=[], ig=[]): if favorited: fav = color_func(c['TWEET']['favorited'])(u'\u2605') - tweet = text.split() + tweet = text.split(' ') + tweet = [x for x in tweet if x != ''] # Replace url if expanded_url: for index in xrange(len(expanded_url)): @@ -289,17 +290,18 @@ def draw(t, keyword=None, humanize=True, noti=False, fil=[], ig=[]): else x, tweet) # Highlight screen_name - tweet = lmap(lambda x: cycle_color(x) if x[0] == '@' else x, tweet) + tweet = lmap( + lambda x: cycle_color(x) if x.lstrip().startswith('@') else x, tweet) # Highlight link tweet = lmap( lambda x: color_func(c['TWEET']['link'])(x) - if x.startswith('http') + if x.lstrip().startswith('http') else x, tweet) # Highlight hashtag tweet = lmap( lambda x: color_func(c['TWEET']['hashtag'])(x) - if x.startswith('#') + if x.lstrip().startswith('#') else x, tweet) # Highlight my tweet @@ -308,11 +310,12 @@ def draw(t, keyword=None, humanize=True, noti=False, fil=[], ig=[]): for x in tweet if not any([ x == 'RT', - x.startswith('http'), - x.startswith('#')]) + x.lstrip().startswith('http'), + x.lstrip().startswith('#')]) ] # Highlight keyword tweet = ' '.join(tweet) + tweet = '\n '.join(tweet.split('\n')) if keyword: roj = re.search(keyword, tweet, re.IGNORECASE) if roj: -- 2.25.1