From 2f5b468f73c0a74c7f85c6cf88b9a8c6fb34045e Mon Sep 17 00:00:00 2001 From: Facundo Olano Date: Thu, 12 Sep 2024 12:58:56 -0300 Subject: [PATCH] Enable markdown extensions (#46) * add footnote to markdow example * add footnote markdown extension * add gfm extensions --- commands/initfiles/src/blog/goodbye-markdown.md | 10 ++++++++++ markup/templates.go | 13 +++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/commands/initfiles/src/blog/goodbye-markdown.md b/commands/initfiles/src/blog/goodbye-markdown.md index 6c83b06..f1c2c08 100644 --- a/commands/initfiles/src/blog/goodbye-markdown.md +++ b/commands/initfiles/src/blog/goodbye-markdown.md @@ -22,4 +22,14 @@ def hello(): hello() ``` +Let's try some gfm extensions. This is ~~strikethrough~~. + +| foo | bar | +| --- | --- | +| baz | bim | + +Would it support footnotes[^1]? + [Next time](./hello-org), I'll talk about org-mode posts. + +[^1]: apparently it would? diff --git a/markup/templates.go b/markup/templates.go index d316669..09e1aa2 100644 --- a/markup/templates.go +++ b/markup/templates.go @@ -18,6 +18,7 @@ import ( "github.com/osteele/liquid" "github.com/yuin/goldmark" gm_highlight "github.com/yuin/goldmark-highlighting/v2" + "github.com/yuin/goldmark/extension" "gopkg.in/yaml.v3" ) @@ -169,10 +170,14 @@ func (templ Template) RenderWith(context map[string]interface{}, hlTheme string) options := make([]goldmark.Option, 0) if hlTheme != NO_SYNTAX_HIGHLIGHTING { - options = append(options, goldmark.WithExtensions(gm_highlight.NewHighlighting( - gm_highlight.WithStyle(hlTheme), - gm_highlight.WithFormatOptions(html.TabWidth(CODE_TABWIDTH)), - ))) + + options = append(options, goldmark.WithExtensions( + extension.GFM, + extension.Footnote, + gm_highlight.NewHighlighting( + gm_highlight.WithStyle(hlTheme), + gm_highlight.WithFormatOptions(html.TabWidth(CODE_TABWIDTH)), + ))) } md := goldmark.New(options...) if err := md.Convert(content, &buf); err != nil {