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
··· 1 - package pages 2 3 import ( 4 "bytes" ··· 8 "github.com/yuin/goldmark/parser" 9 ) 10 11 - func renderMarkdown(source string) string { 12 md := goldmark.New( 13 goldmark.WithExtensions(extension.GFM), 14 goldmark.WithParserOptions(
··· 1 + // Package markup is an umbrella package for all markups and their renderers. 2 + package markup 3 4 import ( 5 "bytes" ··· 9 "github.com/yuin/goldmark/parser" 10 ) 11 12 + func RenderMarkdown(source string) string { 13 md := goldmark.New( 14 goldmark.WithExtensions(extension.GFM), 15 goldmark.WithParserOptions(
+26
appview/pages/markup/readme.go
···
··· 1 + package markup 2 + 3 + import "strings" 4 + 5 + type Format string 6 + 7 + const ( 8 + FormatMarkdown Format = "markdown" 9 + FormatText Format = "text" 10 + ) 11 + 12 + var FileTypes map[Format][]string = map[Format][]string{ 13 + FormatMarkdown: []string{".md", ".markdown", ".mdown", ".mkdn", ".mkd"}, 14 + } 15 + 16 + func GetFormat(filename string) Format { 17 + for format, extensions := range FileTypes { 18 + for _, extension := range extensions { 19 + if strings.HasSuffix(filename, extension) { 20 + return format 21 + } 22 + } 23 + } 24 + // default format 25 + return FormatText 26 + }