export markdown

master
Bel LaPointe 2020-09-28 09:48:34 -06:00
parent f60d0618e6
commit 4d076ede3d
2 changed files with 5 additions and 5 deletions

View File

@ -27,7 +27,7 @@ func (n *Notes) File(urlPath string) (string, error) {
return "", errors.New("path is dir") return "", errors.New("path is dir")
} }
b, _ := ioutil.ReadFile(p.Local) b, _ := ioutil.ReadFile(p.Local)
return n.gomarkdown(urlPath, b) return n.Gomarkdown(urlPath, b)
return n.blackfriday(urlPath, b) return n.blackfriday(urlPath, b)
return n.goldmark(urlPath, b) return n.goldmark(urlPath, b)
return n.md2min(urlPath, b) return n.md2min(urlPath, b)
@ -56,7 +56,7 @@ func (n *Notes) md2min(urlPath string, b []byte) (string, error) {
return string(buff.Bytes()), err return string(buff.Bytes()), err
} }
func (n *Notes) gomarkdown(urlPath string, b []byte) (string, error) { func (n *Notes) Gomarkdown(urlPath string, b []byte) (string, error) {
renderer := html.NewRenderer(html.RendererOptions{ renderer := html.NewRenderer(html.RendererOptions{
Flags: html.CommonFlags | html.TOC, Flags: html.CommonFlags | html.TOC,
RenderNodeHook: n.commentFormer(urlPath, b), RenderNodeHook: n.commentFormer(urlPath, b),
@ -115,7 +115,7 @@ func (n *Notes) commentFormer(urlPath string, md []byte) html.RenderNodeFunc {
} }
} }
return func(w io.Writer, node ast.Node, entering bool) (ast.WalkStatus, bool) { return func(w io.Writer, node ast.Node, entering bool) (ast.WalkStatus, bool) {
if heading, ok := node.(*ast.Heading); !n.ro && ok && !entering { if heading, ok := node.(*ast.Heading); !n.RO && ok && !entering {
nextHeader() nextHeader()
fmt.Fprintf(w, ` fmt.Fprintf(w, `
<form method="POST" action=%q class="comment"> <form method="POST" action=%q class="comment">

View File

@ -4,12 +4,12 @@ import "local/notes-server/config"
type Notes struct { type Notes struct {
root string root string
ro bool RO bool
} }
func New() *Notes { func New() *Notes {
return &Notes{ return &Notes{
root: config.Root, root: config.Root,
ro: config.ReadOnly, RO: config.ReadOnly,
} }
} }