parse

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package parse turns raw file bytes into a normalized model.ParsedDoc. A small extension registry routes each file to its Parser: markdown, Go source, or the plain-text fallback. Richer SQL/HTML parsers are deliberately deferred — for V0 those extensions fall through to the text parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasFrontmatter

func HasFrontmatter(content []byte) bool

HasFrontmatter reports whether content opens with a YAML frontmatter block (a leading `---` delimiter line). It lets callers distinguish "no frontmatter at all" from "frontmatter present but missing a field".

Types

type GoParser

type GoParser struct{}

GoParser parses Go source with the standard go/parser, emitting one section per top-level declaration (func, method, type) including its leading doc comment, with exact line ranges from the token.FileSet. When parsing fails (e.g. a non-compiling snippet) it falls back to a single whole-file section that the code chunker windows by lines.

func (GoParser) Parse

Parse implements parse.Parser.

type MarkdownParser

type MarkdownParser struct{}

MarkdownParser parses markdown via goldmark. It extracts YAML frontmatter, builds heading-scoped sections with exact 1-based line ranges, and collects link destinations from the AST (not regex, so fenced code blocks don't produce false-positive links). OKF index.md files are marked structure-only.

func (MarkdownParser) Parse

Parse implements parse.Parser.

type Parser

type Parser interface {
	// Parse reads src.Content and returns the normalized document.
	Parse(ctx context.Context, src model.Source) (model.ParsedDoc, error)
}

Parser converts a Source into a ParsedDoc. Implementations must be deterministic and side-effect free.

func For

func For(path string) Parser

For returns the Parser for the given file path, defaulting to the text parser for any extension without a dedicated entry.

type TextParser

type TextParser struct{}

TextParser is the V0 fallback for any non-markdown, non-Go file (.txt, .sql, .html, .json, .yaml/.yml, .toml). It emits a single whole-document section; the text chunker handles paragraph/line windowing. Rich SQL/HTML structure is deliberately deferred past V0.

func (TextParser) Parse

Parse implements parse.Parser.

Jump to

Keyboard shortcuts

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