From cfd9c7292c1cb610277513ebb2314ce1aeb214ad Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Sat, 5 Nov 2022 09:10:37 +0000 Subject: [PATCH] Fixed double dash in tweets Signed-off-by: Marcus Noble --- chars.go | 1 + main.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/chars.go b/chars.go index 01dcfc0..162e84f 100644 --- a/chars.go +++ b/chars.go @@ -77,6 +77,7 @@ var charWidths = map[string]float64{ "(": 7.8, ")": 7.8, "-": 10.300003051757812, + "—": 10.300003051757812, "_": 9.73333740234375, "=": 14.333328247070312, "+": 14.333328247070312, diff --git a/main.go b/main.go index 1e46a86..2644b4b 100644 --- a/main.go +++ b/main.go @@ -208,8 +208,10 @@ func calculateHeight(tweet anaconda.Tweet) int64 { lineHeight := 28.0 tweetText := strings.ReplaceAll(tweet.FullText, "
", " \n") tweetText = strip.StripTags(tweetText) + tweetText = strings.ReplaceAll(tweetText, "--", "——") words := regexp.MustCompile(`[ |-]`).Split(tweetText, -1) for _, word := range words { + word = strings.ReplaceAll(word, "——", "--") if len(emoji.FindAll(word)) > 0 { lineHeight = 32.0 }