summaryrefslogtreecommitdiffstats
path: root/markup/goldmark/convert.go
diff options
context:
space:
mode:
authorJonas Zeiger <jonas.zeiger@talpidae.net>2023-12-06 00:29:03 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-03-07 14:08:29 +0100
commit134e7d1d3d1ca901a274c56ef720c9c48be56b77 (patch)
tree7f5a20b3015d5a6b3eb751086c2d82c3c1d07c53 /markup/goldmark/convert.go
parent1f48b717c7f1bb9ecdbf8a7f50cbcdc5cf1dcc0a (diff)
markup/goldmark: TOC: render strikethrough, emojis
Configure the TOC (TableOfContents, toc.go) goldmark renderer to always enable the Strikethrough and Emoji extensions. This allows handling ast.KindStrikethrough and ast.KindEmoji AST nodes when rendering the TOC. Fixes #7169 Fixes #11783 Fixes #12022
Diffstat (limited to 'markup/goldmark/convert.go')
-rw-r--r--markup/goldmark/convert.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/markup/goldmark/convert.go b/markup/goldmark/convert.go
index de06bedff..d835d17cf 100644
--- a/markup/goldmark/convert.go
+++ b/markup/goldmark/convert.go
@@ -18,14 +18,14 @@ import (
"bytes"
"github.com/gohugoio/hugo-goldmark-extensions/passthrough"
+ "github.com/yuin/goldmark/util"
+
"github.com/gohugoio/hugo/markup/goldmark/codeblocks"
"github.com/gohugoio/hugo/markup/goldmark/goldmark_config"
"github.com/gohugoio/hugo/markup/goldmark/images"
"github.com/gohugoio/hugo/markup/goldmark/internal/extensions/attributes"
"github.com/gohugoio/hugo/markup/goldmark/internal/render"
- "github.com/gohugoio/hugo/markup/converter"
- "github.com/gohugoio/hugo/markup/tableofcontents"
"github.com/yuin/goldmark"
emoji "github.com/yuin/goldmark-emoji"
"github.com/yuin/goldmark/ast"
@@ -34,6 +34,9 @@ import (
"github.com/yuin/goldmark/renderer"
"github.com/yuin/goldmark/renderer/html"
"github.com/yuin/goldmark/text"
+
+ "github.com/gohugoio/hugo/markup/converter"
+ "github.com/gohugoio/hugo/markup/tableofcontents"
)
const (
@@ -91,10 +94,17 @@ func newMarkdown(pcfg converter.ProviderConfig) goldmark.Markdown {
rendererOptions = append(rendererOptions, html.WithUnsafe())
}
+ tocRendererOptions := make([]renderer.Option, len(rendererOptions))
+ if rendererOptions != nil {
+ copy(tocRendererOptions, rendererOptions)
+ }
+ tocRendererOptions = append(tocRendererOptions,
+ renderer.WithNodeRenderers(util.Prioritized(extension.NewStrikethroughHTMLRenderer(), 500)),
+ renderer.WithNodeRenderers(util.Prioritized(emoji.NewHTMLRenderer(), 200)))
var (
extensions = []goldmark.Extender{
newLinks(cfg),
- newTocExtension(rendererOptions),
+ newTocExtension(tocRendererOptions),
}
parserOptions []parser.Option
)