parser

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(ext string, p Parser)

Register associates an extension (e.g. ".md") with a Parser.

Types

type Document

type Document struct {
	Meta     Meta
	Title    string
	Sections []Section
}

Document is the parsed output of a file.

type Meta

type Meta struct {
	Title       string `yaml:"title"`
	Description string `yaml:"description"`
	Timestamp   string `yaml:"timestamp"`
	// Date is the documented alias for Timestamp; read it via Timestamp.
	Date string     `yaml:"date"`
	Tags stringList `yaml:"tags"`
}

Meta holds YAML frontmatter fields promoted to document level.

func (Meta) Summary

func (m Meta) Summary() string

Summary renders the retrieval-worthy frontmatter as plain prose. It is empty when there is nothing worth indexing.

type Parser

type Parser interface {
	Parse(path string, data []byte) (*Document, error)
}

Parser extracts structure from a file's bytes.

func For

func For(ext string) Parser

For returns the Parser for the given extension, or plaintext fallback.

type Section

type Section struct {
	HeadingPath string // e.g. "Introduction > Background"
	Text        string
	Ordinal     int // byte offset where this section starts
}

Section is a logical division of a document (heading + content).

Jump to

Keyboard shortcuts

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