Documentation
¶
Overview ¶
Package parser extracts frontmatter, links, headings, and blocks from Markdown files.
Index ¶
- func ClassifyNote(fm map[string]interface{}) (isDomain bool, id string, noteType string)
- func ExtractFrontmatter(content []byte) (fm map[string]interface{}, body string, err error)
- func StripForFTS(body string) string
- func StripForFTSOffsets(body string) (string, []int)
- func StripHTMLComments(s string) string
- func StripVaultMindMarkers(s string) string
- type ExtractedBlock
- type ExtractedHeading
- type ExtractedLink
- type LinkType
- type ParsedNote
- type TargetKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClassifyNote ¶
ClassifyNote determines whether a note is a domain note (has both id and type as non-empty strings) or an unstructured note.
func ExtractFrontmatter ¶
ExtractFrontmatter splits a raw .md file into its YAML frontmatter map and the remaining body text.
If the file has no frontmatter (does not start with "---\n"), fm is nil and body is the entire file content.
func StripForFTS ¶
StripForFTS converts Markdown body text to plain text for full-text search indexing.
func StripForFTSOffsets ¶ added in v0.10.10
StripForFTSOffsets applies the keyword lane's Markdown normalization while retaining the raw byte position of each remaining byte for excerpt delivery.
func StripHTMLComments ¶ added in v0.10.13
StripHTMLComments removes every HTML comment. Search text and recall excerpts use it: those paths quote the note's words, not its comments. A VaultMind marker is removed here because every comment is. Delivery does not call this. An author comment is part of the note, and the only comment delivery hides is StripVaultMindMarkers.
func StripVaultMindMarkers ¶ added in v0.10.13
StripVaultMindMarkers removes HTML comments whose text starts with "vaultmind:". Those are VaultMind's own bookkeeping, written so a retried accept does not append a proposal twice. Any other HTML comment is the author's and stays. Whitespace after "<!--" is allowed; the comment accept writes is "<!-- vaultmind:".
Callers that load a body for an agent: QueryFullNote (ask, memory pack, arc recite, --read, summarize, MCP ask), populateRawSnippets, and the FTS preview. note get does not call this. It is an explicit raw read.
Types ¶
type ExtractedBlock ¶
ExtractedBlock is a block ID anchor (^block-id) found in a note body.
func ExtractBlocks ¶
func ExtractBlocks(body string) []ExtractedBlock
ExtractBlocks returns all block ID anchors (^block-id) in document order. Block IDs inside fenced code blocks are ignored.
type ExtractedHeading ¶
ExtractedHeading is a Markdown heading found in a note body.
func ExtractHeadings ¶
func ExtractHeadings(body string) []ExtractedHeading
ExtractHeadings returns all Markdown headings in document order. Headings inside fenced code blocks are ignored.
type ExtractedLink ¶
type ExtractedLink struct {
Target string
Display string
LinkType LinkType
TargetKind TargetKind
Heading string
BlockID string
Line int
}
ExtractedLink is a single outbound link found in a note body.
func ExtractLinks ¶
func ExtractLinks(body string) []ExtractedLink
ExtractLinks scans body text for all outbound links. Code fences and inline code spans are skipped.
type LinkType ¶
type LinkType string
LinkType classifies how a link was expressed in the source text.
type ParsedNote ¶
type ParsedNote struct {
Frontmatter map[string]interface{}
Body string
FTSBody string
Links []ExtractedLink
Headings []ExtractedHeading
Blocks []ExtractedBlock
IsDomain bool
ID string
NoteType string
}
ParsedNote is the complete result of parsing a single .md file.
func Parse ¶
func Parse(content []byte) (*ParsedNote, error)
Parse converts raw .md file content into a ParsedNote. Returns an error only if YAML frontmatter is present but syntactically invalid.
type TargetKind ¶
type TargetKind string
TargetKind classifies what the link target refers to.
const ( TargetKindNote TargetKind = "note" TargetKindHeading TargetKind = "heading" TargetKindBlock TargetKind = "block" TargetKindPath TargetKind = "path" TargetKindExternal TargetKind = "external" )