forked from tangled.org/core
this repo has no description

appview: pages/markup: setup package for markdown and other markups

Changed files
+29 -2
appview
pages
+3 -2
appview/pages/markdown.go appview/pages/markup/markdown.go
···
-
package pages
+
// Package markup is an umbrella package for all markups and their renderers.
+
package markup
import (
"bytes"
···
"github.com/yuin/goldmark/parser"
)
-
func renderMarkdown(source string) string {
+
func RenderMarkdown(source string) string {
md := goldmark.New(
goldmark.WithExtensions(extension.GFM),
goldmark.WithParserOptions(
+26
appview/pages/markup/readme.go
···
+
package markup
+
+
import "strings"
+
+
type Format string
+
+
const (
+
FormatMarkdown Format = "markdown"
+
FormatText Format = "text"
+
)
+
+
var FileTypes map[Format][]string = map[Format][]string{
+
FormatMarkdown: []string{".md", ".markdown", ".mdown", ".mkdn", ".mkd"},
+
}
+
+
func GetFormat(filename string) Format {
+
for format, extensions := range FileTypes {
+
for _, extension := range extensions {
+
if strings.HasSuffix(filename, extension) {
+
return format
+
}
+
}
+
}
+
// default format
+
return FormatText
+
}