diff options
author | 2022-08-26 13:28:06 +0200 | |
---|---|---|
committer | 2022-08-26 13:28:06 +0200 | |
commit | 79fb8bad04662bfb5aa8990afeba4c134eb06201 (patch) | |
tree | 4938fc81981acad65f63af8a4c57cbed3aa82186 /internal/text/markdown.go | |
parent | [bugfix] Fix boost of boost issue (#764) (diff) | |
download | gotosocial-79fb8bad04662bfb5aa8990afeba4c134eb06201.tar.xz |
[feature] Allow footnotes in markdown, use `<br>` instead of `\n` (#767)
* allow markdown footnotes + hard line breaks
* don't keep whitespace w/minify (unnecessary now)
* test markdown a bit more
Diffstat (limited to 'internal/text/markdown.go')
-rw-r--r-- | internal/text/markdown.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/internal/text/markdown.go b/internal/text/markdown.go index 8952b99d6..13fb93378 100644 --- a/internal/text/markdown.go +++ b/internal/text/markdown.go @@ -28,7 +28,10 @@ import ( "github.com/tdewolff/minify/v2/html" ) -var m *minify.M +var ( + bfExtensions = blackfriday.CommonExtensions | blackfriday.HardLineBreak | blackfriday.Footnotes + m *minify.M +) func (f *formatter) FromMarkdown(ctx context.Context, md string, mentions []*gtsmodel.Mention, tags []*gtsmodel.Tag) string { // format tags nicely @@ -38,7 +41,7 @@ func (f *formatter) FromMarkdown(ctx context.Context, md string, mentions []*gts content = f.ReplaceMentions(ctx, content, mentions) // parse markdown - contentBytes := blackfriday.Run([]byte(content)) + contentBytes := blackfriday.Run([]byte(content), blackfriday.WithExtensions(bfExtensions)) // clean anything dangerous out of it content = SanitizeHTML(string(contentBytes)) @@ -46,9 +49,8 @@ func (f *formatter) FromMarkdown(ctx context.Context, md string, mentions []*gts if m == nil { m = minify.New() m.Add("text/html", &html.Minifier{ - KeepEndTags: true, - KeepQuotes: true, - KeepWhitespace: true, + KeepEndTags: true, + KeepQuotes: true, }) } |