mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
Link hashtag bug (#121)
* link + hashtag bug * remove printlns * tidy up some duplicated code
This commit is contained in:
@@ -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 := >smodel.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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user