mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
Add parse_markdown rewrite function
This commit is contained in:
parent
9ba15e9649
commit
36df7b36ec
4 changed files with 21 additions and 0 deletions
|
@ -15,6 +15,8 @@ import (
|
|||
"miniflux.app/config"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/yuin/goldmark"
|
||||
goldmarkhtml "github.com/yuin/goldmark/renderer/html"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -318,3 +320,18 @@ func decodeBase64Content(entryContent string) string {
|
|||
return html.EscapeString(string(ret))
|
||||
}
|
||||
}
|
||||
|
||||
func parseMarkdown(entryContent string) string {
|
||||
var sb strings.Builder
|
||||
md := goldmark.New(
|
||||
goldmark.WithRendererOptions(
|
||||
goldmarkhtml.WithUnsafe(),
|
||||
),
|
||||
)
|
||||
|
||||
if err := md.Convert([]byte(entryContent), &sb); err != nil {
|
||||
return entryContent
|
||||
}
|
||||
|
||||
return sb.String()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue