mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Add AttributeString method
This commit is contained in:
parent
bdde5e8472
commit
3bf70b9428
1 changed files with 11 additions and 0 deletions
11
ast/ast.go
11
ast/ast.go
|
|
@ -5,6 +5,7 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
textm "github.com/yuin/goldmark/text"
|
||||
"github.com/yuin/goldmark/util"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -148,6 +149,11 @@ type Node interface {
|
|||
// (nil, false)
|
||||
Attribute(name []byte) ([]byte, bool)
|
||||
|
||||
// AttributeString returns a (attribute value, true) if an attribute
|
||||
// associated with the given name is found, otherwise
|
||||
// (nil, false)
|
||||
AttributeString(name string) ([]byte, bool)
|
||||
|
||||
// Attributes returns a list of attributes.
|
||||
// This may be a nil if there are no attributes.
|
||||
Attributes() []Attribute
|
||||
|
|
@ -355,6 +361,11 @@ func (n *BaseNode) Attribute(name []byte) ([]byte, bool) {
|
|||
return nil, false
|
||||
}
|
||||
|
||||
// AttributeString implements Node.AttributeString.
|
||||
func (n *BaseNode) AttributeString(s string) ([]byte, bool) {
|
||||
return n.Attribute(util.StringToReadOnlyBytes(s))
|
||||
}
|
||||
|
||||
// Attributes implements Node.Attributes
|
||||
func (n *BaseNode) Attributes() []Attribute {
|
||||
return n.attributes
|
||||
|
|
|
|||
Loading…
Reference in a new issue