mirror of
https://github.com/gogs/gogs.git
synced 2026-03-01 09:40:55 +01:00
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
27 lines
536 B
Go
27 lines
536 B
Go
package misc
|
|
|
|
import (
|
|
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 := c.Req.Body().Bytes()
|
|
if err != nil {
|
|
c.Error(err, "read body")
|
|
return
|
|
}
|
|
_, _ = c.Write(markup.SanitizeBytes(markup.RawMarkdown(body, "")))
|
|
}
|