Fixed double dash in tweets

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
Marcus Noble 2022-11-05 09:10:37 +00:00
parent 7f14289760
commit cfd9c7292c
Signed by: AverageMarcus
GPG Key ID: B8F2DB8A7AEBAF78
2 changed files with 3 additions and 0 deletions

View File

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

View File

@ -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
}