directive

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package directive parses user input for inline directives like @Image, @File, and @Bash.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Image   ImageConfig
	RunBash func(ctx context.Context, command string) (string, error)
}

Config holds all directive configuration.

type ImageConfig

type ImageConfig struct {
	Dimension int
	Quality   int
}

ImageConfig holds compression settings for image directives.

type ParsedInput

type ParsedInput struct {
	// Text is the input with directive tokens replaced by placeholders.
	Text string
	// Images holds extracted and compressed images.
	Images image.Images
	// Warnings holds non-fatal issues (file not found, decode error).
	Warnings []string
	// Preamble holds prepended context from @File and @Bash expansions.
	Preamble string
}

ParsedInput is the result of parsing user input for directives.

func Parse

func Parse(ctx context.Context, input, workdir string, cfg Config) ParsedInput

Parse processes raw user input, expanding all registered directives. The workdir is used to resolve relative paths.

func (ParsedInput) HasImages

func (p ParsedInput) HasImages() bool

HasImages reports whether any images were extracted.

Jump to

Keyboard shortcuts

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