Skip to content

Commit 97a4bb3

Browse files
committed
fix: enable GFM extension for markdown rendering in proxy mode
When `filter_readme_scripts` is enabled, markdown files served through the proxy are converted to HTML using goldmark. However, the default goldmark converter does not include GFM (GitHub Flavored Markdown) extensions, causing tables, strikethrough, and other GFM syntax to be rendered as plain text instead of proper HTML elements. This adds `extension.GFM` to the goldmark converter so that GFM tables, strikethrough, autolinks, and task lists are correctly converted to HTML.
1 parent 2f903c4 commit 97a4bb3

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎server/handles/down.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/microcosm-cc/bluemonday"
1919
log "github.com/sirupsen/logrus"
2020
"github.com/yuin/goldmark"
21+
"github.com/yuin/goldmark/extension"
2122
)
2223

2324
func Down(c *gin.Context) {
@@ -151,7 +152,8 @@ func localProxy(c *gin.Context, link *model.Link, file model.Obj, proxyRange boo
151152
}
152153

153154
var html bytes.Buffer
154-
if err = goldmark.Convert(buf.Bytes(), &html); err != nil {
155+
md := goldmark.New(goldmark.WithExtensions(extension.GFM))
156+
if err = md.Convert(buf.Bytes(), &html); err != nil {
155157
err = fmt.Errorf("markdown conversion failed: %w", err)
156158
} else {
157159
buf.Reset()

0 commit comments

Comments
 (0)