mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Add AddMeta
This commit is contained in:
parent
41b1d4542d
commit
b7b0919dfe
1 changed files with 14 additions and 1 deletions
15
ast/block.go
15
ast/block.go
|
|
@ -87,7 +87,20 @@ func (n *Document) Meta() map[string]interface{} {
|
|||
|
||||
// SetMeta sets given metadata to this document.
|
||||
func (n *Document) SetMeta(meta map[string]interface{}) {
|
||||
n.meta = meta
|
||||
if n.meta == nil {
|
||||
n.meta = map[string]interface{}{}
|
||||
}
|
||||
for k, v := range meta {
|
||||
n.meta[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
// AddMeta adds given metadata to this document.
|
||||
func (n *Document) AddMeta(key string, value interface{}) {
|
||||
if n.meta == nil {
|
||||
n.meta = map[string]interface{}{}
|
||||
}
|
||||
n.meta[key] = value
|
||||
}
|
||||
|
||||
// NewDocument returns a new Document node.
|
||||
|
|
|
|||
Loading…
Reference in a new issue