Documentation ¶
Overview ¶
gmast provides some helper functions for working with goldmark's AST. Useful for writing NodeUnmarshalers.
Index ¶
- func AppendChild[T ast.Node](parent T, children ...ast.Node) (theParent T)
- func AppendHeadingChild[T ast.Node](heading T, children ...ast.Node) (theParent T)
- func FindSibling(node ast.Node, isMatch func(node ast.Node) bool) ast.Node
- func ForEachChild(node ast.Node, source []byte, fn func(child ast.Node, index int))
- func ForEachListItem(node *ast.List, source []byte, fn func(item ast.Node, index int))
- func IsHeadingLevelBelow(node ast.Node, level int) bool
- func LastChildOfHeading(node ast.Node) (sibling ast.Node, err error)
- func NewHashtag(tag string, source []byte) (node ast.Node, newSource []byte)
- func NewParagraph(newText string, source []byte) (node ast.Node, newSource []byte)
- func NewSegment(newText string, source []byte) (text.Segment, []byte)
- func NewSpace(source []byte) (node ast.Node, newSource []byte)
- func NewTextSegment(newText string, source []byte) (textSegment *ast.Text, newSource []byte)
- func WalkSiblingsUntil(node ast.Node, walker ast.Walker) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendChild ¶ added in v0.0.3
AppendChild is a chainable version of ast.Node.AppendChild. Builds a new AST in a single call.
func AppendHeadingChild ¶ added in v0.0.3
AppendHeadingChild appends a child to the last sibling of the heading before a new higher-level heading. Conceptually, this is the same as AppendChild.
func FindSibling ¶ added in v0.0.3
FindSibling finds the first direct sibling of a node that matches the given predicate. If no match is found, returns nil.
func ForEachChild ¶
ForEachChild runs a callback on each direct child of a node.
func ForEachListItem ¶
ForEachListItem runs a callback on each list item in a list.
func IsHeadingLevelBelow ¶ added in v0.0.3
IsHeadingLevelBelow checks if a node is a heading that is outside a given level's children.
func LastChildOfHeading ¶ added in v0.0.3
LastChildOfHeading returns the last node that is before a heading of a lower level or the end of the document.
func NewHashtag ¶ added in v0.0.3
NewHashtag returns a new hashtag.Node with the text set up correctly.
func NewParagraph ¶ added in v0.0.3
NewParagraph is a helper to build a new paragraph with a single text segment.
func NewSegment ¶ added in v0.0.3
NewSegment builds a new text.Segment and appends its content to the source in a single call.
func NewSpace ¶ added in v0.0.3
NewSpace returns a new space text segment for adding space between inline nodes.
func NewTextSegment ¶ added in v0.0.3
NewTextSegment builds a new ast.TextSegment and appends its content to the source in a single call.
Types ¶
This section is empty.