diff options
Diffstat (limited to 'internal/text/markdown.go')
| -rw-r--r-- | internal/text/markdown.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/internal/text/markdown.go b/internal/text/markdown.go index e4b633e75..8486d6935 100644 --- a/internal/text/markdown.go +++ b/internal/text/markdown.go @@ -24,6 +24,7 @@ import ( "strings" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" + "code.superseriousbusiness.org/gotosocial/internal/id" "code.superseriousbusiness.org/gotosocial/internal/log" "code.superseriousbusiness.org/gotosocial/internal/regexes" "codeberg.org/gruf/go-byteutil" @@ -118,6 +119,18 @@ func (f *Formatter) fromMarkdown( } } + // Inject a footnote ID prefix to avoid + // footnote ID clashes. StatusID isn't + // always set (eg., when parsing instance + // description markdown), so take a random + // ULID if it's not. + var footnoteIDPrefix string + if statusID != "" { + footnoteIDPrefix = statusID + "-" + } else { + footnoteIDPrefix = id.NewULID() + "-" + } + // Instantiate goldmark parser for // markdown, using custom renderer // to add hashtag/mention links. @@ -141,7 +154,9 @@ func (f *Formatter) fromMarkdown( extension.NewLinkify( extension.WithLinkifyURLRegexp(regexes.URLLike), ), - extension.Footnote, + extension.NewFootnote( + extension.WithFootnoteIDPrefix(footnoteIDPrefix), + ), extension.Strikethrough, ), ) |
