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
- 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.
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" )