Documentation
¶
Overview ¶
Package parser provides Markdown parsing, slugification, and text chunking for notebrain-cli.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAttachmentLink ¶
IsAttachmentLink returns true if target points to a known attachment file (e.g. images, canvas files, archives). Dotted note names such as "Note 1.2.3" are notes, not attachments.
func Slugify ¶
Slugify converts a note name/filename to a slug. It lowercases, trims .md, replaces spaces with hyphens, and removes punctuation, emoji, and other symbols. Unicode letters and numerals are preserved so accented or CJK names do not collapse into the same slug.
func TitleFromPath ¶
TitleFromPath derives a fallback title from the relative file path.
Types ¶
type Chunk ¶
type Chunk struct {
NoteSlug string
Index int
// Text and RichText are the overlap-free display text used for storage and
// retrieval output. Text is clean prose (code blocks replaced with
// placeholders); RichText keeps actual code and markdown inline.
Text string
RichText string
// EmbedText is the text fed to the embedding model. For split sections it
// includes the configured chunk-overlap so sentence-level continuity across
// sub-chunk boundaries survives embedding. It is never stored or displayed.
EmbedText string
HeadingPath string // e.g. "Architecture > Data Flow > Ingest"
Level int // depth of the deepest heading in this chunk (1-6)
HasTask bool
HasCode bool // true when the chunk contains a fenced code block
}
Chunk is one section of a note, bounded by heading structure.
type Result ¶
Result is the output from parsing the full document, containing the chunks and metadata.
func Parse ¶
Parse parses body text into Chunks, extracting wikilinks, tags, and frontmatter. maxChunkRunes controls the maximum rune length per chunk. overlapRunes controls how many runes are repeated at the start of the next sub-chunk when a section is split (overlap). If skipAttachments is true, links pointing to non-markdown attachments (images, PDFs, etc.) are ignored.