config

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentCSS

func ContentCSS(s string) string

ContentCSS converts a header/footer slot value to a CSS content value. Empty string produces `""`. Tokens {page} and {pages} become CSS counters.

func MergeFile

func MergeFile(cfg *Config, path string) error

MergeFile overlays the YAML file at path on top of cfg.

Types

type ColorsConfig

type ColorsConfig struct {
	Primary      string `yaml:"primary"`
	PrimaryLight string `yaml:"primary_light"`
	Background   string `yaml:"background"`
	Text         string `yaml:"text"`
	TextMuted    string `yaml:"text_muted"`
}

type Config

type Config struct {
	Page            PageConfig           `yaml:"page"`
	Font            FontConfig           `yaml:"font"`
	Headings        HeadingsConfig       `yaml:"headings"`
	Justify         bool                 `yaml:"justify"`
	ParagraphIndent string               `yaml:"paragraph_indent"`
	HeadingIndent   string               `yaml:"heading_indent"`
	HeadingNumbers  HeadingNumbersConfig `yaml:"heading_numbers"`
	TOC             TOCConfig            `yaml:"toc"`
	Header          HeaderFooterConfig   `yaml:"header"`
	Footer          HeaderFooterConfig   `yaml:"footer"`
	BlankPage       bool                 `yaml:"blank_page"`
	Colors          ColorsConfig         `yaml:"colors"`
	Cover           CoverConfig          `yaml:"cover"`
	References      ReferencesConfig     `yaml:"references"`
	Custom          map[string]any       `yaml:"custom"`
	// contains filtered or unexported fields
}

func Default

func Default() *Config

func FromBundle

func FromBundle(data []byte) (*Config, error)

FromBundle builds a Config from the raw YAML of a bundle's default.yml. Falls back to Default() if data is nil.

func Load

func Load(path string) (*Config, error)

func (*Config) ApplyDocMeta

func (c *Config) ApplyDocMeta(meta map[string]any)

ApplyDocMeta overrides header/footer Left/Center/Right from the document's front matter. Front matter keys "header" and "footer" accept the same left/center/right sub-keys.

func (*Config) CustomBool

func (c *Config) CustomBool(path string, def bool) bool

func (*Config) CustomString

func (c *Config) CustomString(path, def string) string

CustomString returns a string value from Config.Custom at the given dot-separated path, falling back to def if missing or not a string (e.g. "invoice.labels.client").

func (*Config) ResolvePath

func (c *Config) ResolvePath(p string) string

ResolvePath resolves a path relative to the config file's directory.

type CoverConfig

type CoverConfig struct {
	Enabled  bool   `yaml:"enabled"`
	Template string `yaml:"template"`
}

type FontConfig

type FontConfig struct {
	Family     string  `yaml:"family"`
	URL        string  `yaml:"url"`
	Size       string  `yaml:"size"`
	LineHeight float64 `yaml:"line_height"`
}

type HeaderFooterConfig

type HeaderFooterConfig struct {
	Enabled    bool   `yaml:"enabled"`
	Background string `yaml:"background"`
	Left       string `yaml:"left"`
	Center     string `yaml:"center"`
	Right      string `yaml:"right"`
}

HeaderFooterConfig configures a header or footer band on every page. Left/Center/Right accept plain text or {page}/{pages} tokens.

type HeadingLevel

type HeadingLevel struct {
	Size            string `yaml:"size"`
	PageBreakBefore bool   `yaml:"page_break_before"`
}

type HeadingNumbersConfig

type HeadingNumbersConfig struct {
	Enabled bool     `yaml:"enabled"`
	Exclude []string `yaml:"exclude"`
}

type HeadingsConfig

type HeadingsConfig struct {
	H1 HeadingLevel `yaml:"h1"`
	H2 HeadingLevel `yaml:"h2"`
	H3 HeadingLevel `yaml:"h3"`
	H4 HeadingLevel `yaml:"h4"`
	H5 HeadingLevel `yaml:"h5"`
	H6 HeadingLevel `yaml:"h6"`
}

type MarginsConfig

type MarginsConfig struct {
	Top    string `yaml:"top"`
	Right  string `yaml:"right"`
	Bottom string `yaml:"bottom"`
	Left   string `yaml:"left"`
}

type PageConfig

type PageConfig struct {
	Size    string        `yaml:"size"`
	Margins MarginsConfig `yaml:"margins"`
}

type ReferencesConfig

type ReferencesConfig struct {
	Bibliography string `yaml:"bibliography"` // h2 heading text of the bibliography section
	Sitography   string `yaml:"sitography"`   // h2 heading text of the sitography section
	Figures      string `yaml:"figures"`      // h2 heading text for the auto-generated table of figures
}

type TOCConfig

type TOCConfig struct {
	Enabled  bool     `yaml:"enabled"`
	MaxDepth int      `yaml:"max_depth"`
	Exclude  []string `yaml:"exclude"`
	PreTOC   []string `yaml:"pre_toc"` // sections extracted from body and placed before the TOC
}

Jump to

Keyboard shortcuts

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