diff --git a/notes/file.go b/notes/file.go index 630589e..ea97599 100755 --- a/notes/file.go +++ b/notes/file.go @@ -27,7 +27,7 @@ func (n *Notes) File(urlPath string) (string, error) { return "", errors.New("path is dir") } b, _ := ioutil.ReadFile(p.Local) - return n.Gomarkdown(urlPath, b) + return n.gomarkdown(urlPath, b) return n.blackfriday(urlPath, b) return n.goldmark(urlPath, b) return n.md2min(urlPath, b) @@ -56,10 +56,14 @@ func (n *Notes) md2min(urlPath string, b []byte) (string, error) { 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) { + return Gomarkdown(b, n.commentFormer(urlPath, b)) +} + +func Gomarkdown(b []byte, renderHook html.RenderNodeFunc) (string, error) { renderer := html.NewRenderer(html.RendererOptions{ Flags: html.CommonFlags | html.TOC, - RenderNodeHook: n.commentFormer(urlPath, b), + RenderNodeHook: renderHook, }) ext := parser.NoExtensions for _, extension := range []parser.Extensions{