Documentation
¶
Index ¶
- func ContentCSS(s string) string
- func MergeFile(cfg *Config, path string) error
- type CodeConfig
- type ColorsConfig
- type Config
- func (c *Config) ApplyDocMeta(meta map[string]any)
- func (c *Config) CustomBool(path string, def bool) bool
- func (c *Config) CustomString(path, def string) string
- func (c *Config) Dir() string
- func (c *Config) FontFacesCSS() string
- func (c *Config) ResolvePath(p string) string
- func (c *Config) SetFontFacesCSS(css string)
- type CoverConfig
- type FontConfig
- type FontFace
- type HeaderFooterConfig
- type HeadingLevel
- type HeadingNumbersConfig
- type HeadingsConfig
- type MarginsConfig
- type PageConfig
- type ReferencesConfig
- type TOCConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentCSS ¶
ContentCSS converts a header/footer slot value to a CSS content value. Empty string produces `""`. Tokens {page} and {pages} become CSS counters.
Types ¶
type CodeConfig ¶ added in v0.0.7
type CodeConfig struct {
Theme string `yaml:"theme"`
Background string `yaml:"background"`
Foreground string `yaml:"foreground"`
FontFamily string `yaml:"font_family"`
FontURL string `yaml:"font_url"`
Faces []FontFace `yaml:"faces"`
FontSize string `yaml:"font_size"`
LineHeight float64 `yaml:"line_height"`
LineNumbers bool `yaml:"line_numbers"`
Wrap bool `yaml:"wrap"`
KeepTogetherLines int `yaml:"keep_together_lines"`
}
CodeConfig configures how fenced code blocks and inline code are rendered. Theme is a Chroma style name (see `templify --code-themes`); "none" or an empty value disables syntax highlighting and keeps the plain panel style. Background/Foreground override the colors the theme would otherwise pick.
type ColorsConfig ¶
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"`
BlankPage bool `yaml:"blank_page"`
Colors ColorsConfig `yaml:"colors"`
Code CodeConfig `yaml:"code"`
Cover CoverConfig `yaml:"cover"`
References ReferencesConfig `yaml:"references"`
Custom map[string]any `yaml:"custom"`
// contains filtered or unexported fields
}
func Default ¶
func Default() *Config
Default returns a Config pre-filled with sensible defaults for page size, typography, colors, TOC, and footer page numbering.
func FromBundle ¶
FromBundle builds a Config from the raw YAML of a bundle's default.yml. Falls back to Default() if data is nil.
func (*Config) ApplyDocMeta ¶
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 ¶
CustomBool returns a bool value from Config.Custom at the given dot-separated path, falling back to def if the key is missing or the value is not a bool.
func (*Config) CustomString ¶
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) Dir ¶ added in v0.0.7
Dir returns the directory of the config file, used to resolve relative paths.
func (*Config) FontFacesCSS ¶ added in v0.0.7
FontFacesCSS returns the inlined @font-face rules, or "" when no face is configured.
func (*Config) ResolvePath ¶
ResolvePath resolves a path relative to the config file's directory.
func (*Config) SetFontFacesCSS ¶ added in v0.0.7
SetFontFacesCSS stores the @font-face rules built from Font.Faces and Code.Faces. Reading and encoding the files happens before rendering, so the stylesheet generator stays free of I/O.
type CoverConfig ¶
type FontConfig ¶
type FontConfig struct {
Family string `yaml:"family"`
URL string `yaml:"url"`
Faces []FontFace `yaml:"faces"`
Size string `yaml:"size"`
LineHeight float64 `yaml:"line_height"`
}
FontConfig configures the body font. Faces takes precedence over URL: when it is set the linked stylesheet is dropped, since mixing the two would put the broken text layer back. Use `templify -fetch-fonts` to turn a URL into faces.
type FontFace ¶ added in v0.0.7
type FontFace struct {
File string `yaml:"file"`
Weight int `yaml:"weight"`
Style string `yaml:"style"`
UnicodeRange string `yaml:"unicode_range"`
}
FontFace is one self-hosted font file. Faces are inlined into the document's own stylesheet as data URIs. This matters for the PDF's text layer: fonts pulled in through a linked stylesheet are more likely to end up as a variable font, which Chromium's PDF export badly mis-positions; a static, self-hosted face avoids that specific cause (see docs/configuration.md's "Self-hosting fonts" section for the other causes of the same symptom, which self-hosting alone does not fix). File is resolved relative to the config file. Weight defaults to 400 and Style to normal. UnicodeRange is optional and passed through as-is.
type HeaderFooterConfig ¶
type HeaderFooterConfig struct {
}
HeaderFooterConfig configures a header or footer band on every page. Left/Center/Right accept plain text or {page}/{pages} tokens.
type HeadingLevel ¶
type HeadingNumbersConfig ¶
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 PageConfig ¶
type PageConfig struct {
Size string `yaml:"size"`
Margins MarginsConfig `yaml:"margins"`
}