summaryrefslogtreecommitdiff
path: root/internal/text/markdown.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-07-29 13:18:22 +0200
committerLibravatar GitHub <noreply@github.com>2021-07-29 13:18:22 +0200
commita940a520d301d00f42012743b3999a73f7180848 (patch)
tree50bdd749381d6f773df46dbc4cc33a9b533a4e7b /internal/text/markdown.go
parentLink parsing (#120) (diff)
downloadgotosocial-a940a520d301d00f42012743b3999a73f7180848.tar.xz
Link hashtag bug (#121)
* link + hashtag bug * remove printlns * tidy up some duplicated code
Diffstat (limited to 'internal/text/markdown.go')
-rw-r--r--internal/text/markdown.go20
1 files changed, 4 insertions, 16 deletions
diff --git a/internal/text/markdown.go b/internal/text/markdown.go
index d1309f389..f9d12209a 100644
--- a/internal/text/markdown.go
+++ b/internal/text/markdown.go
@@ -19,9 +19,6 @@
package text
import (
- "fmt"
- "strings"
-
"github.com/russross/blackfriday/v2"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
@@ -39,20 +36,11 @@ func (f *formatter) FromMarkdown(md string, mentions []*gtsmodel.Mention, tags [
// do the markdown parsing *first*
content = string(blackfriday.Run([]byte(content), blackfriday.WithExtensions(bfExtensions)))
- // format mentions nicely
- for _, menchie := range mentions {
- targetAccount := &gtsmodel.Account{}
- if err := f.db.GetByID(menchie.TargetAccountID, targetAccount); err == nil {
- mentionContent := fmt.Sprintf(`<span class="h-card"><a href="%s" class="u-url mention">@<span>%s</span></a></span>`, targetAccount.URL, targetAccount.Username)
- content = strings.ReplaceAll(content, menchie.NameString, mentionContent)
- }
- }
-
// format tags nicely
- for _, tag := range tags {
- tagContent := fmt.Sprintf(`<a href="%s" class="mention hashtag" rel="tag">#<span>%s</span></a>`, 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)
return postformat(content)
}