Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FrontMatter ¶
type FrontMatter struct {
Data map[string]any
Content string
HasFrontMatter bool
SchemaSource string // "flag", "inline", "key", or "none"
SchemaRef string // when SchemaSource == "key"
InlineSchema map[string]any // when SchemaSource == "inline"
}
FrontMatter contains parsed front matter data. We keep it generic as map[string]any so schemas can be flexible. Content is the remaining markdown without the front matter fence. SchemaSource indicates from where schema came (flag or inline or key reference) SchemaRef holds the path/URL when schema is referenced via key InlineSchema holds parsed inline schema object if present If neither is set and no global schema, no validation occurs.
func ParseFrontMatter ¶
func ParseFrontMatter(content string) (*FrontMatter, error)
ParseFrontMatter extracts YAML front matter from markdown content. For now, we only support YAML front matter (between --- fences at the beginning of the file), as it's the most common; JSON can be added later.
func (*FrontMatter) DetermineSchemaType ¶
func (fm *FrontMatter) DetermineSchemaType() SchemaType
DetermineSchemaType analyzes the front matter data to determine the schema type.
func (*FrontMatter) GetSchemaSource ¶
func (fm *FrontMatter) GetSchemaSource() SchemaType
GetSchemaSource returns the schema source as a typed enum.
func (*FrontMatter) GetSchemaType ¶
func (fm *FrontMatter) GetSchemaType() SchemaType
GetSchemaType returns the current schema type as a typed enum.
func (*FrontMatter) HasSchema ¶
func (fm *FrontMatter) HasSchema() bool
HasSchema returns true if the front matter contains schema information.
func (*FrontMatter) SetSchemaType ¶
func (fm *FrontMatter) SetSchemaType(schemaType SchemaType)
SetSchemaType sets the schema source using a typed enum.
type Options ¶
type Options struct {
Root string
Recursive bool
Extensions []string
SchemaPath string // optional global schema path/URL
Force bool // fail files without front matter when true
// Workers allows overriding the number of concurrent workers used during scanning.
// When 0 or negative, a default based on CPU count is used.
Workers int
}
Options controls the behavior of the scanner.
type Result ¶
Result represents a validation result for a single file.
func ValidateContent ¶
ValidateContent validates markdown content directly without file system operations. SchemaPath, when provided, takes precedence over any $schema in the front matter. When no schema is available: if force is true and there's no front matter, the result fails; otherwise the result is OK with a "no schema provided" warning.
type SchemaType ¶
type SchemaType string
SchemaType represents the source of schema configuration.
const ( SchemaTypeFlag SchemaType = "flag" SchemaTypeInline SchemaType = "inline" SchemaTypeKey SchemaType = "key" SchemaTypeNone SchemaType = "none" )
func (SchemaType) IsValid ¶
func (st SchemaType) IsValid() bool
IsValid returns true if the schema type is one of the known valid types.