Documentation
¶
Index ¶
- Variables
- func ExtractFrontmatter(source []byte) (map[string]any, error)
- func ExtractMetadataTuples(fm map[string]any) []store.MetadataTuple
- func FrontmatterToJSON(fm map[string]any) string
- func GetTags(fm map[string]any) []string
- func GetTitle(fm map[string]any) string
- func GetWikilinks(fm map[string]any) []string
- func MetaGet(pc parser.Context) map[string]any
- func Slugify(s string) string
- type ParseResult
- type RawLink
Constants ¶
This section is empty.
Variables ¶
var MetaExt goldmark.Extender = &metaExtension{}
MetaExt is a goldmark.Extender that parses YAML frontmatter.
Functions ¶
func ExtractFrontmatter ¶
ExtractFrontmatter extracts YAML frontmatter from markdown bytes using goldmark-meta. Returns nil, nil if no frontmatter is present.
func ExtractMetadataTuples ¶ added in v0.2.0
func ExtractMetadataTuples(fm map[string]any) []store.MetadataTuple
ExtractMetadataTuples converts a frontmatter map into normalized MetadataTuples. Rules:
- "tags" key is skipped (already handled by tag nodes + tagged edges).
- Output is capped at maxTuplesPerDoc; excess keys are logged and dropped.
- Values are truncated to maxValueLen characters.
- value_type is inferred: date, bool, list (JSON array), number, ref, or string.
- Top-level tuples use source="frontmatter".
- Nested "skill_advisory" values use source="skill_advisory".
func FrontmatterToJSON ¶
FrontmatterToJSON converts a frontmatter map to a JSON string. Returns "" if fm is nil.
func GetTags ¶
GetTags extracts the "tags" field from frontmatter, handling both []interface{} and []string.
func GetWikilinks ¶
GetWikilinks scans all string values in the frontmatter map for [[...]] patterns and returns the wikilink targets. Handles both string and slice values.
func Slugify ¶ added in v0.2.3
Slugify converts a heading or term into the lowercase, dash-separated anchor slug used in heading node IDs (relPath#slug): lowercase, whitespace runs collapsed to a single "-", keeping Unicode letters + digits + "-". Exported so the tools layer can resolve a section= argument that was copied from a search-result anchor back to its heading — the match must use this exact algorithm or it would drift.
Types ¶
type ParseResult ¶
type ParseResult struct {
DocNode store.Node
Headings []store.Node
Defs []store.Node
Tags []store.Node // Deduplicated tag nodes
Edges []store.Edge
RawLinks []RawLink
FileInfo store.FileInfo
SectionChunks []store.SectionChunk
MetadataTuples []store.MetadataTuple // Normalized key/value pairs from frontmatter
}
ParseResult contains all data extracted from a single markdown file.
type RawLink ¶
type RawLink struct {
Text string // Display text
Target string // Link target (path, wikilink name, URL)
Kind string // "wikilink", "markdown_link", "embed", "external"
Line int
FromNodeID string // ID of the containing node
}
RawLink represents a link found during parsing, before resolution.