mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Add autoID for definition terms
Fixes #13403 See #11566 Co-authored-by: Joe Mooring <joe@mooring.com>
This commit is contained in:
@@ -53,6 +53,10 @@ func (t *tocTransformer) Transform(n *ast.Document, reader text.Reader, pc parse
|
||||
headingText bytes.Buffer
|
||||
)
|
||||
|
||||
if ids := pc.IDs().(stringValuesProvider).StringValues(); len(ids) > 0 {
|
||||
toc.SetIdentifiers(ids)
|
||||
}
|
||||
|
||||
ast.Walk(n, func(n ast.Node, entering bool) (ast.WalkStatus, error) {
|
||||
s := ast.WalkStatus(ast.WalkContinue)
|
||||
if n.Kind() == ast.KindHeading {
|
||||
@@ -131,5 +135,7 @@ func (e *tocExtension) Extend(m goldmark.Markdown) {
|
||||
r.AddOptions(e.options...)
|
||||
m.Parser().AddOptions(parser.WithASTTransformers(util.Prioritized(&tocTransformer{
|
||||
r: r,
|
||||
}, 10)))
|
||||
},
|
||||
// This must run after the ID generation (priority 100).
|
||||
110)))
|
||||
}
|
||||
|
Reference in New Issue
Block a user