From 79fb8bad04662bfb5aa8990afeba4c134eb06201 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 26 Aug 2022 13:28:06 +0200 Subject: [feature] Allow footnotes in markdown, use `
` instead of `\n` (#767) * allow markdown footnotes + hard line breaks * don't keep whitespace w/minify (unnecessary now) * test markdown a bit more --- internal/text/markdown.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'internal/text/markdown.go') 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, }) } -- cgit v1.2.3