From d80aa67c9703b0ff175c859daba6749be0d05adf Mon Sep 17 00:00:00 2001 From: boojack Date: Sat, 20 May 2023 10:00:21 +0800 Subject: [PATCH] feat: parse markdown to html format in rss (#1683) --- go.mod | 1 + go.sum | 2 ++ server/rss.go | 10 +++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index eee62b81..69f6854f 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/spf13/cobra v1.6.1 github.com/spf13/viper v1.15.0 github.com/stretchr/testify v1.8.1 + github.com/yuin/goldmark v1.5.4 go.uber.org/zap v1.24.0 golang.org/x/crypto v0.1.0 golang.org/x/exp v0.0.0-20230111222715-75897c7a292a diff --git a/go.sum b/go.sum index 20796ee6..ce2011df 100644 --- a/go.sum +++ b/go.sum @@ -262,6 +262,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU= +github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= diff --git a/server/rss.go b/server/rss.go index 18b8b66c..6437e59d 100644 --- a/server/rss.go +++ b/server/rss.go @@ -1,6 +1,7 @@ package server import ( + "bytes" "context" "encoding/json" "net/http" @@ -12,6 +13,7 @@ import ( "github.com/labstack/echo/v4" "github.com/usememos/memos/api" "github.com/usememos/memos/common" + "github.com/yuin/goldmark" ) func (s *Server) registerRSSRoutes(g *echo.Group) { @@ -169,7 +171,13 @@ func getRSSItemDescription(content string) string { } else { description = content } - return description + + // TODO: use our `./plugin/gomark` parser to handle markdown-like content. + var buf bytes.Buffer + if err := goldmark.Convert([]byte(description), &buf); err != nil { + panic(err) + } + return buf.String() } func isTitleDefined(content string) bool {