html

package
v0.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WalkFunc

func WalkFunc(n *Node, f NodeVisitorFunc)

WalkFunc is like Walk but accepts just a callback function

Types

type NodeVisitor

type NodeVisitor interface {
	Visit(node *Node, entering bool) WalkStatus
}

NodeVisitor is a callback to be called when traversing the syntax tree. Called twice for every node: once with entering=true when the branch is first visited, then with entering=false after all the children are done.

type NodeVisitorFunc

type NodeVisitorFunc func(node *Node, entering bool) WalkStatus

NodeVisitorFunc casts a function to match NodeVisitor interface

func (NodeVisitorFunc) Visit

func (f NodeVisitorFunc) Visit(node *Node, entering bool) WalkStatus

Visit calls visitor function

type WalkStatus

type WalkStatus int

WalkStatus allows NodeVisitor to have some control over the tree traversal. It is returned from NodeVisitor and different values allow Node.Walk to decide which node to go to next.

const (
	// GoToNext is the default traversal of every node.
	GoToNext WalkStatus = iota
	// SkipChildren tells walker to skip all children of current node.
	SkipChildren
	// Terminate tells walker to terminate the traversal.
	Terminate
)

func Walk

func Walk(n *Node, visitor NodeVisitor) WalkStatus

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL