Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetThemeDescription ¶
GetThemeDescription returns the human-readable description for a theme.
Types ¶
type ColorScheme ¶
type ColorScheme struct {
Text string `yaml:"text"`
Background string `yaml:"background"`
Heading string `yaml:"heading"`
Link string `yaml:"link"`
CodeBg string `yaml:"code_bg"`
CodeText string `yaml:"code_text"`
Accent string `yaml:"accent"`
Border string `yaml:"border"`
}
ColorScheme defines the color palette for a theme.
type MarginSettings ¶
type MarginSettings struct {
Top float64 `yaml:"top"`
Bottom float64 `yaml:"bottom"`
Left float64 `yaml:"left"`
Right float64 `yaml:"right"`
}
MarginSettings defines page margins in millimeters.
type Theme ¶
type Theme struct {
Name string `yaml:"name"`
PageSize string `yaml:"page_size"` // e.g. A4, Letter
FontFamily string `yaml:"font_family"`
FontSize int `yaml:"font_size"` // in pt
CodeTheme string `yaml:"code_theme"`
LineHeight float64 `yaml:"line_height"`
Colors ColorScheme `yaml:"colors"`
Margins MarginSettings `yaml:"margins"`
HeaderTemplate string `yaml:"header_template"`
// FontSizeCSS overrides FontSize with a literal CSS length. book.yaml's
// style.font_size accepts any CSS unit (px, em, rem, %), which the integer
// point value above cannot represent, so the resolved config sets this
// when the user configured a size. Empty means "use FontSize".
FontSizeCSS string `yaml:"-"`
}
Theme defines the document theme styling.
func (*Theme) ApplyTypography ¶ added in v0.7.15
func (t *Theme) ApplyTypography(o TypographyOverride)
ApplyTypography overlays non-empty user typography onto the theme. Without it, style.font_family / font_size / line_height are parsed and validated but never reach any renderer.
func (*Theme) ResolvedFontSize ¶ added in v0.7.15
ResolvedFontSize returns the theme's body font size as a CSS length, taking a user override into account. Use it instead of formatting FontSize directly, so every backend agrees on the effective size.
type ThemeManager ¶
type ThemeManager struct {
// contains filtered or unexported fields
}
ThemeManager manages theme loading and retrieval.
func NewThemeManager ¶
func NewThemeManager() *ThemeManager
NewThemeManager creates a new theme manager pre-loaded with built-in themes.
func (*ThemeManager) Get ¶
func (tm *ThemeManager) Get(name string) (*Theme, error)
Get returns the theme with the given name.
func (*ThemeManager) List ¶
func (tm *ThemeManager) List() []string
List returns the names of all available themes in sorted order.
func (*ThemeManager) LoadFromFile ¶
func (tm *ThemeManager) LoadFromFile(path string) (*Theme, error)
LoadFromFile loads a theme from a YAML file.
type TypographyOverride ¶ added in v0.7.15
TypographyOverride carries the typography settings from book.yaml's `style` block. They win over the theme's own values, so a user can retune a built-in theme without forking it.