parser

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 13 Imported by: 0

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 Slugify

func Slugify(name string) string

Slugify converts a note name/filename to a URL-safe slug. It lowercases, trims .md, replaces spaces with hyphens, and removes non-alphanumeric characters except hyphens.

func TitleFromPath

func TitleFromPath(path string) string

TitleFromPath derives a fallback title from the relative file path.

Types

type ASTChunk

type ASTChunk struct {
	NoteSlug    string
	Index       int
	Text        string // clean prose text for embedding
	HeadingPath string // e.g. "Architecture > Data Flow > Ingest"
	Level       int    // depth of the deepest heading in this chunk (1-6)
	CodeBlocks  int    // number of fenced code blocks in this chunk
	HasTable    bool
	HasTask     bool
	WordCount   int
}

ASTChunk is one section of a note, bounded by heading structure.

type ASTResult

type ASTResult struct {
	Chunks      []ASTChunk
	Tags        []string
	Links       []string
	Frontmatter map[string]interface{}
}

ASTResult is the output from parsing the full document, containing the chunks and metadata.

func ParseAST

func ParseAST(body, noteSlug string, maxChunkRunes int) ASTResult

ParseAST parses body text into ASTChunks, extracting wikilinks, tags, and frontmatter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL