From a940a520d301d00f42012743b3999a73f7180848 Mon Sep 17 00:00:00 2001 From: Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 29 Jul 2021 13:18:22 +0200 Subject: Link hashtag bug (#121) * link + hashtag bug * remove printlns * tidy up some duplicated code --- internal/text/plain.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'internal/text/plain.go') diff --git a/internal/text/plain.go b/internal/text/plain.go index 4f6659484..40fb6412f 100644 --- a/internal/text/plain.go +++ b/internal/text/plain.go @@ -19,7 +19,6 @@ package text import ( - "fmt" "strings" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" @@ -29,22 +28,13 @@ func (f *formatter) FromPlain(plain string, mentions []*gtsmodel.Mention, tags [ content := preformat(plain) // format links nicely - content = ReplaceLinks(content) - - // format mentions nicely - for _, menchie := range mentions { - targetAccount := >smodel.Account{} - if err := f.db.GetByID(menchie.TargetAccountID, targetAccount); err == nil { - mentionContent := fmt.Sprintf(`@%s`, targetAccount.URL, targetAccount.Username) - content = strings.ReplaceAll(content, menchie.NameString, mentionContent) - } - } + content = f.ReplaceLinks(content) // format tags nicely - for _, tag := range tags { - tagContent := fmt.Sprintf(``, tag.URL, tag.Name) - content = strings.ReplaceAll(content, fmt.Sprintf("#%s", tag.Name), tagContent) - } + content = f.ReplaceTags(content, tags) + + // format mentions nicely + content = f.ReplaceMentions(content, mentions) // replace newlines with breaks content = strings.ReplaceAll(content, "\n", "
") -- cgit v1.2.3