Documentation
¶
Overview ¶
Package parser turns source files (Markdown, YAML, JSON) into a unified ContextNode tree.
Index ¶
Constants ¶
View Source
const ( FormatPlain = "plain" FormatToon = "toon" )
View Source
const MaxInlineFields = 5
MaxInlineFields is the threshold for promoting a nested map or array to its own ContextNode. Smaller structures stay inlined in the parent's Content.
View Source
const ToonSavingsThreshold = 0.15
ToonSavingsThreshold is the minimum fraction of bytes TOON must save versus plain rendering before it is preferred.
Variables ¶
View Source
var ( ErrUnsupportedExt = errors.New("unsupported extension") ErrInvalidUTF8 = errors.New("invalid UTF-8") )
Functions ¶
func FlattenMap ¶
func FlattenMap(roots []*ContextNode) map[string]*ContextNode
Types ¶
type ContextNode ¶
type ContextNode struct {
Children []*ContextNode
ID string
ParentID string
SourceFile string
Label string
Content string
ContentHash string
Format string
Temperature *float64
Depth int
TokenCount int
NodeType
}
func Flatten ¶
func Flatten(roots []*ContextNode) []*ContextNode
func Parse ¶
func Parse(path string, r io.Reader) ([]*ContextNode, error)
Read r and route it to a format-specific parser based on path's extension.
func ParseBytes ¶
func ParseBytes(path string, data []byte) ([]*ContextNode, error)
func ParseFile ¶
func ParseFile(path string) ([]*ContextNode, error)
type JsonParser ¶
type JsonParser struct{}
type ToonParser ¶
type ToonParser struct{}
type YamlParser ¶
type YamlParser struct{}
Click to show internal directories.
Click to hide internal directories.