parser

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseFrontmatter

func ParseFrontmatter(content []byte) (map[string]interface{}, []byte)

ParseFrontmatter extracts YAML frontmatter from content between --- delimiters Returns the parsed frontmatter and the remaining content without frontmatter

Types

type FileCategory

type FileCategory int

FileCategory represents the semantic purpose of a file

const (
	// FileCategoryUnknown is for files that don't match any known category
	FileCategoryUnknown FileCategory = iota
	// FileCategoryConfig is for settings and configuration files (settings.json, mcp.json)
	FileCategoryConfig
	// FileCategoryInstructions is for directive content (CLAUDE.md files)
	FileCategoryInstructions
	// FileCategoryCommands is for custom slash commands (.claude/commands/)
	FileCategoryCommands
	// FileCategoryDocumentation is for descriptive content (README.md, docs)
	FileCategoryDocumentation
)

func GetFileCategory

func GetFileCategory(path string) FileCategory

GetFileCategory returns the semantic FileCategory for a given path

func (FileCategory) String

func (c FileCategory) String() string

type FileType

type FileType int

FileType represents the type of configuration file

const (
	FileTypeUnknown FileType = iota
	FileTypeMarkdown
	FileTypeJSON
	FileTypeYAML
)

func GetFileType

func GetFileType(path string) FileType

GetFileType returns the FileType for a given path

type JSONParser

type JSONParser struct{}

JSONParser parses JSON configuration files

func (*JSONParser) CanParse

func (p *JSONParser) CanParse(path string) bool

CanParse returns true if this parser can handle the file

func (*JSONParser) Parse

func (p *JSONParser) Parse(path string, content []byte) (*ParsedFile, error)

Parse parses a JSON file

type MarkdownParser

type MarkdownParser struct{}

MarkdownParser parses markdown configuration files

func (*MarkdownParser) CanParse

func (p *MarkdownParser) CanParse(path string) bool

CanParse returns true if this parser can handle the file

func (*MarkdownParser) Parse

func (p *MarkdownParser) Parse(path string, content []byte) (*ParsedFile, error)

Parse parses a markdown file into sections

type ParsedFile

type ParsedFile struct {
	Path        string
	Content     []byte
	FileType    FileType
	Category    FileCategory
	Sections    []Section
	Frontmatter map[string]interface{} // YAML frontmatter from markdown files
}

ParsedFile represents a parsed configuration file

func Parse

func Parse(path string) (*ParsedFile, error)

Parse parses a file using the appropriate parser

type Parser

type Parser interface {
	Parse(path string, content []byte) (*ParsedFile, error)
	CanParse(path string) bool
}

Parser defines the interface for parsing configuration files

type PlainParser

type PlainParser struct{}

PlainParser parses plain text files with no special structure

func (*PlainParser) CanParse

func (p *PlainParser) CanParse(path string) bool

CanParse returns true (fallback parser)

func (*PlainParser) Parse

func (p *PlainParser) Parse(path string, content []byte) (*ParsedFile, error)

Parse parses a plain text file

type Section

type Section struct {
	Title       string
	Level       int
	StartLine   int
	EndLine     int
	Content     string
	Subsections []Section
}

Section represents a section within a parsed file

type YAMLParser

type YAMLParser struct{}

YAMLParser parses YAML configuration files

func (*YAMLParser) CanParse

func (p *YAMLParser) CanParse(path string) bool

CanParse returns true if this parser can handle the file

func (*YAMLParser) Parse

func (p *YAMLParser) Parse(path string, content []byte) (*ParsedFile, error)

Parse parses a YAML file

Jump to

Keyboard shortcuts

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