From 829ad9ad6a3efafa6d6e3dba458ef28d7336a1ba Mon Sep 17 00:00:00 2001 From: Wesley Kerfoot Date: Sat, 21 Dec 2019 16:51:35 -0500 Subject: [PATCH] fix issue with newline characters --- src/twit2blogpkg/twitter.nim | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/twit2blogpkg/twitter.nim b/src/twit2blogpkg/twitter.nim index 9939771..49958c6 100644 --- a/src/twit2blogpkg/twitter.nim +++ b/src/twit2blogpkg/twitter.nim @@ -67,18 +67,19 @@ proc getThread*(tweetStart : string, user : string) : seq[string] = proc convertWords(tweet : string) : string = let words = tweet.split(" ") var stripped : seq[string] - for word in words: - if word.len > 3 and word[0..3] == "http": - let parsedUri = word.parseUri - let scheme = parsedUri.scheme - let hostname = parsedUri.hostname - let path = parsedUri.path - if (scheme.len > 0 and hostname.len > 0): - stripped &= fmt"[{scheme}://{hostname}{path}]({scheme}://{hostname}{path})" - elif word[0] != '@': - stripped &= word - else: - continue + for chunk in words: + for word in chunk.splitLines: + if word.len > 3 and word[0..3] == "http": + let parsedUri = word.parseUri + let scheme = parsedUri.scheme + let hostname = parsedUri.hostname + let path = parsedUri.path + if (scheme.len > 0 and hostname.len > 0): + stripped &= fmt"[{scheme}://{hostname}{path}]({scheme}://{hostname}{path})" + elif word.len > 0 and word[0] != '@': + stripped &= word + else: + continue stripped.join(" ") proc renderThread*(tweetID : string, user : string) : string =