Files
Gogs/internal/route/api/v1/misc/markdown.go
2026-01-25 12:05:56 +00:00

29 lines
553 B
Go

package misc
import (
"io"
api "github.com/gogs/go-gogs-client"
"gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/markup"
)
func Markdown(c *context.APIContext, form api.MarkdownOption) {
if form.Text == "" {
_, _ = c.Write([]byte(""))
return
}
_, _ = c.Write(markup.Markdown([]byte(form.Text), form.Context, nil))
}
func MarkdownRaw(c *context.APIContext) {
body, err := io.ReadAll(c.Req.Request.Body)
if err != nil {
c.Error(err, "read body")
return
}
_, _ = c.Write(markup.SanitizeBytes(markup.RawMarkdown(body, "")))
}