Documentation
¶
Overview ¶
Package parser turns source files (Markdown, HTML, YAML, JSON, TOON) into a unified ContextNode tree.
Index ¶
Constants ¶
View Source
const ( FormatPlain = "plain" FormatToon = "toon" FormatMathml = "mathml" FormatLatex = "latex" )
View Source
const MathmlSavingsThreshold = 0.15
Minimum byte-savings fraction LaTeX must beat over the raw MathML XML before it's preferred.
View Source
const MaxInlineFields = 5
Promote a nested map or array to its own ContextNode at or above this many entries; smaller structures stay inlined.
View Source
const ToonSavingsThreshold = 0.15
Minimum byte-savings fraction TOON must beat over plain rendering before it's preferred.
Variables ¶
Functions ¶
func FlattenMap ¶
func FlattenMap(roots []*ContextNode) map[string]*ContextNode
Types ¶
type ContextNode ¶
type ContextNode struct {
Children []*ContextNode
WikilinkRefs []WikilinkRef
ID string
ParentID string
SourceFile string
Label string
Content string
ContentHash string
Format string
Temperature *float64
Depth int
TokenCount int
SeedPinned bool
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 HtmlParser ¶ added in v0.2.0
type HtmlParser struct{}
type JsonParser ¶
type JsonParser struct{}
type ToonParser ¶
type ToonParser struct{}
type WikilinkRef ¶ added in v0.3.0
func ExtractWikilinks ¶ added in v0.3.0
func ExtractWikilinks(text string) (string, []WikilinkRef)
type YamlParser ¶
type YamlParser struct{}
Click to show internal directories.
Click to hide internal directories.