feat: articles format option with markdown new default
This commit is contained in:
1 parent
68401d66e0
commit
7e9bd9ba30
61 files changed
+2269
-243
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package article
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var ErrUnsupportedBodyFormat = errors.New("unsupported body format")
|
||||
|
||||
type BodyFormat string
|
||||
|
||||
const (
|
||||
BodyFormatMarkdown BodyFormat = "markdown"
|
||||
BodyFormatHTML BodyFormat = "html"
|
||||
BodyFormatJSON BodyFormat = "json"
|
||||
)
|
||||
|
||||
func ParseBodyFormat(value string) (BodyFormat, error) {
|
||||
switch strings.ToLower(value) {
|
||||
case "", string(BodyFormatMarkdown):
|
||||
return BodyFormatMarkdown, nil
|
||||
case string(BodyFormatHTML):
|
||||
return BodyFormatHTML, nil
|
||||
case string(BodyFormatJSON):
|
||||
return BodyFormatJSON, nil
|
||||
}
|
||||
return "", ErrUnsupportedBodyFormat
|
||||
}
|
||||
|
||||
type BodyRenderer interface {
|
||||
Render(html string, format BodyFormat) (string, error)
|
||||
}
|
||||
Reference in new issue
Block a user