theme

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ThemeVariants = map[string]string{
	"technical": "干净、专业的风格,适合技术文档和IT领域的书籍",
	"elegant":   "优雅的风格,使用衬线字体,适合文学和出版类书籍",
	"minimal":   "极简风格,简洁干净,大量空白,高度可读性",
}

ThemeVariants 定义可用的主题变体及其描述

Functions

func GetThemeDescription

func GetThemeDescription(themeName string) string

GetThemeDescription 获取主题的描述

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:"codeBg"`
	// 代码文本颜色
	CodeText string `yaml:"codeText"`
	// 强调颜色
	Accent string `yaml:"accent"`
	// 边框颜色
	Border string `yaml:"border"`
}

ColorScheme 定义颜色方案

type MarginSettings

type MarginSettings struct {
	// 上边距
	Top float64 `yaml:"top"`
	// 下边距
	Bottom float64 `yaml:"bottom"`
	// 左边距
	Left float64 `yaml:"left"`
	// 右边距
	Right float64 `yaml:"right"`
}

MarginSettings 定义边距设置 (单位: mm)

type Theme

type Theme struct {
	// 主题名称
	Name string `yaml:"name"`
	// 页面大小 (A4, Letter等)
	PageSize string `yaml:"pageSize"`
	// 字体族
	FontFamily string `yaml:"fontFamily"`
	// 字体大小 (pt)
	FontSize int `yaml:"fontSize"`
	// 代码主题
	CodeTheme string `yaml:"codeTheme"`
	// 行高
	LineHeight float64 `yaml:"lineHeight"`

	// 颜色设置
	Colors ColorScheme `yaml:"colors"`

	// 边距设置
	Margins MarginSettings `yaml:"margins"`

	// 页眉模板
	HeaderTemplate string `yaml:"headerTemplate"`
	// 页脚模板
	FooterTemplate string `yaml:"footerTemplate"`
}

Theme 定义了文档的主题样式

func (*Theme) Clone

func (t *Theme) Clone() *Theme

Clone 创建主题的深拷贝

func (*Theme) ToCSS

func (t *Theme) ToCSS() string

ToCSS converts theme settings to CSS code.

func (*Theme) Validate

func (t *Theme) Validate() error

Validate 验证主题的有效性

type ThemeManager

type ThemeManager struct {
	// contains filtered or unexported fields
}

ThemeManager 管理主题的加载和获取

func NewThemeManager

func NewThemeManager() *ThemeManager

NewThemeManager 创建一个新的主题管理器,包含内置主题

func (*ThemeManager) Get

func (tm *ThemeManager) Get(name string) (*Theme, error)

Get 根据名称获取主题

func (*ThemeManager) List

func (tm *ThemeManager) List() []string

List 返回所有可用的主题名称列表

func (*ThemeManager) LoadFromFile

func (tm *ThemeManager) LoadFromFile(path string) (*Theme, error)

LoadFromFile 从YAML文件加载主题

Jump to

Keyboard shortcuts

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