Documentation ¶
Overview ¶
match provides a query language for matching nodes in a larkdown.Tree
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyNode ¶
type AnyNode struct {
BaseNode
}
Matches any node. Useful as a fallback for index matches.
type BaseNode ¶ added in v0.0.1
type BaseNode struct{}
BaseNode partially implements Node, for simpler matchers.
func (BaseNode) IsFlatBranch ¶ added in v0.0.1
type Branch ¶
type Branch struct { // The heading level to match, or 0 to match any level. Level int // The heading name to match, or empty to match any name. Name []byte // If true, the name is matched case-insensitively. CaseInsensitive bool }
Branch matches a heading by level and name, and returns its siblings until the next heading of the same or higher level.
func (Branch) EndMatch ¶ added in v0.0.1
A heading branch ends when the next heading is of the same or higher level.
func (Branch) IsFlatBranch ¶ added in v0.0.1
Headings are branches whose children are siblings until the next heading.
type Heading ¶ added in v0.0.3
type Heading struct { BaseNode // The heading level to match, or 0 to match any level. Level int // The heading name to match, or empty to match any name. Name []byte // If true, the name is matched case-insensitively. CaseInsensitive bool }
Heading matches a heading by level, to get the title contents directly.
type Index ¶
Wraps another query, only when it's the nth child of the parent.
func (Index) IsFlatBranch ¶ added in v0.0.1
type List ¶
type List struct {
BaseNode
}
Matches an ordered or unordered list.
type Node ¶
type Node interface { // Returns true if the node matches the query. Match(node ast.Node, index int, source []byte) (ok bool) // Returns true if the node is the end of a flat branch. // This is used by headings to note when another heading ends the branch. EndMatch(node ast.Node) bool // Show the matcher as a string in error messages. String() string // Returns the next node to match, which usually a child, or for headings a sibling. NextNode(self ast.Node) ast.Node // True for nodes whose children are actually siblings. IsFlatBranch() bool }
Interface for a node matcher.
type NodeOfKind ¶ added in v0.0.1
Matches against a specific node kind. Used for matching arbitrary nodes, including custom ones.
func (NodeOfKind) String ¶ added in v0.0.1
func (m NodeOfKind) String() string