Documentation
¶
Overview ¶
Package notionast provides a set of functions to work with Notion AST It is used to convert notion.Blocks to AST and vice versa It also provides Walk functionality to traverse the AST.
Index ¶
- Constants
- func ASTToBlocks(n *NodeBlock) notion.Blocks
- func PrintAST(node Node, levelArg ...int)
- func Walk(node Node, fn func(node Node))
- type Node
- type NodeBlock
- func (n *NodeBlock) AppendChild(newNode Node)
- func (n *NodeBlock) GetBlock() notion.Block
- func (n *NodeBlock) GetChildCount() int
- func (n *NodeBlock) GetFirstChild() Node
- func (n *NodeBlock) GetID() NodeID
- func (n *NodeBlock) GetLastChild() Node
- func (n *NodeBlock) GetNextSibling() Node
- func (n *NodeBlock) GetParent() Node
- func (n *NodeBlock) GetPrevSibling() Node
- func (n *NodeBlock) GetType() NodeType
- func (n *NodeBlock) IsRoot() bool
- func (n *NodeBlock) RemoveChild(childNode Node)
- func (n *NodeBlock) RemoveChildren()
- type NodeID
- type NodeType
- type Nodes
Constants ¶
const RootNodeID = "tmp-0000000000"
RootNodeID is a constant for the root node auto-generated ID
Variables ¶
This section is empty.
Functions ¶
func ASTToBlocks ¶
ASTToBlocks converts the AST to notion.Blocks
Types ¶
type Node ¶
type Node interface { GetID() NodeID GetType() NodeType GetPrevSibling() Node GetNextSibling() Node GetChildCount() int GetFirstChild() Node GetLastChild() Node GetParent() Node AppendChild(child Node) RemoveChild(child Node) RemoveChildren() // removes all children }
Node is a generic interface for a node in the AST
type NodeBlock ¶
type NodeBlock struct {
// contains filtered or unexported fields
}
NodeBlock is a node implementation for notion.Block
func BlocksToAST ¶
BlocksToAST creates a new AST from the given notion.Blocks
func NewNodeBlock ¶
NewNodeBlock returns a new NodeBlock with the given block
func (*NodeBlock) AppendChild ¶
AppendChild appends a child node to the end of the list of children.
func (*NodeBlock) GetChildCount ¶
GetChildCount returns the number of child nodes.
func (*NodeBlock) GetFirstChild ¶
GetFirstChild returns the first child node, or nil if there are no children.
func (*NodeBlock) GetLastChild ¶
GetLastChild returns the last child node, or nil if there are no children.
func (*NodeBlock) GetNextSibling ¶
GetNextSibling returns the next sibling node, or nil if there is none.
func (*NodeBlock) GetPrevSibling ¶
GetPrevSibling returns the previous sibling node, or nil if there is none.
func (*NodeBlock) RemoveChild ¶
RemoveChild removes a child node (matched by ID) from the node.
func (*NodeBlock) RemoveChildren ¶
func (n *NodeBlock) RemoveChildren()
RemoveChildren removes all child nodes from the node.