From 0e9150b8f64f1dadb8cb297fcb4bea2a10b0bebe Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Sun, 27 Sep 2020 11:05:07 -0600 Subject: [PATCH] Explicit extensions --- notes/file.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/notes/file.go b/notes/file.go index 3d3d89f..cdcb0fa 100755 --- a/notes/file.go +++ b/notes/file.go @@ -24,13 +24,35 @@ func (n *Notes) File(urlPath string) (string, error) { return "", errors.New("path is dir") } b, _ := ioutil.ReadFile(p.Local) + return n.gomarkdown(urlPath, b) + "\n", nil +} + +func (n *Notes) gomarkdown(urlPath string, b []byte) string { renderer := html.NewRenderer(html.RendererOptions{ Flags: html.CommonFlags | html.TOC, RenderNodeHook: n.commentFormer(urlPath, b), }) - parser := parser.NewWithExtensions(parser.CommonExtensions | parser.HeadingIDs | parser.AutoHeadingIDs | parser.Titleblock) + ext := parser.NoExtensions + for _, extension := range []parser.Extensions{ + parser.NoIntraEmphasis, + parser.Tables, + parser.FencedCode, + parser.Autolink, + parser.Strikethrough, + parser.SpaceHeadings, + parser.HeadingIDs, + parser.BackslashLineBreak, + parser.DefinitionLists, + parser.MathJax, + parser.Titleblock, + parser.AutoHeadingIDs, + parser.Includes, + } { + ext |= extension + } + parser := parser.NewWithExtensions(ext) content := markdown.ToHTML(b, parser, renderer) - return string(content) + "\n", nil + return string(content) } func (n *Notes) commentFormer(urlPath string, md []byte) html.RenderNodeFunc {