Fixed double dash in tweets

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
master
Marcus Noble 3 weeks ago
parent 7f14289760
commit cfd9c7292c
Signed by: AverageMarcus
GPG Key ID: B8F2DB8A7AEBAF78
  1. 1
      chars.go
  2. 2
      main.go

@ -77,6 +77,7 @@ var charWidths = map[string]float64{
"(": 7.8,
")": 7.8,
"-": 10.300003051757812,
"—": 10.300003051757812,
"_": 9.73333740234375,
"=": 14.333328247070312,
"+": 14.333328247070312,

@ -208,8 +208,10 @@ func calculateHeight(tweet anaconda.Tweet) int64 {
lineHeight := 28.0
tweetText := strings.ReplaceAll(tweet.FullText, "<br />", " \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
}

Loading…
Cancel
Save