Files
Gogs/internal/route/api/v1/markdown.go
ᴊᴏᴇ ᴄʜᴇɴ a1fa62b270 all: decouple API types from go-gogs-client SDK (#8171)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-10 10:56:17 -05:00

31 lines
628 B
Go

package v1
import (
"gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/markup"
)
// markdownRequest represents the request body for rendering markdown.
type markdownRequest struct {
Text string
Context string
}
func markdown(c *context.APIContext, form markdownRequest) {
if form.Text == "" {
_, _ = c.Write([]byte(""))
return
}
_, _ = c.Write(markup.Markdown([]byte(form.Text), form.Context, nil))
}
func markdownRaw(c *context.APIContext) {
body, err := c.Req.Body().Bytes()
if err != nil {
c.Error(err, "read body")
return
}
_, _ = c.Write(markup.SanitizeBytes(markup.RawMarkdown(body, "")))
}