mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 06:00:25 +03:00
Add autoID for definition terms
Fixes #13403 See #11566 Co-authored-by: Joe Mooring <joe@mooring.com>
This commit is contained in:
parent
9c2f8ec61b
commit
157d3703c3
9 changed files with 262 additions and 47 deletions
|
@ -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)))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue