mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-17 07:37:34 -06:00
[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
This commit is contained in:
parent
2fe3a2b5b8
commit
79fb8bad04
2 changed files with 22 additions and 6 deletions
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue