mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Fix goldmark toc rendering
Previously gordmark-based TOC renderes only `KindText` and `KindString` This commit expands target node with Goldmark's renderer I am not sure of what are expected results as TOC contents in some (rare) cases but Blackfriday's behaviours are fundamentally respected. For example, - image `[image text](link)` is rendered as `<img>` tag - GFM AutoLink `gohugo.io` is rendered as text * Render AutoLink as <a> tag as Blackfriday does Fixes #6736 Fixes #6809
This commit is contained in:
@@ -81,15 +81,7 @@ func (c *goldmarkConverter) SanitizeAnchorName(s string) string {
|
||||
func newMarkdown(pcfg converter.ProviderConfig) goldmark.Markdown {
|
||||
mcfg := pcfg.MarkupConfig
|
||||
cfg := pcfg.MarkupConfig.Goldmark
|
||||
|
||||
var (
|
||||
extensions = []goldmark.Extender{
|
||||
newLinks(),
|
||||
newTocExtension(),
|
||||
}
|
||||
rendererOptions []renderer.Option
|
||||
parserOptions []parser.Option
|
||||
)
|
||||
var rendererOptions []renderer.Option
|
||||
|
||||
if cfg.Renderer.HardWraps {
|
||||
rendererOptions = append(rendererOptions, html.WithHardWraps())
|
||||
@@ -103,6 +95,14 @@ func newMarkdown(pcfg converter.ProviderConfig) goldmark.Markdown {
|
||||
rendererOptions = append(rendererOptions, html.WithUnsafe())
|
||||
}
|
||||
|
||||
var (
|
||||
extensions = []goldmark.Extender{
|
||||
newLinks(),
|
||||
newTocExtension(rendererOptions),
|
||||
}
|
||||
parserOptions []parser.Option
|
||||
)
|
||||
|
||||
if mcfg.Highlight.CodeFences {
|
||||
extensions = append(extensions, newHighlighting(mcfg.Highlight))
|
||||
}
|
||||
|
Reference in New Issue
Block a user