themeformat

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package themeformat provides types and utilities for the markdown theme format.

Index

Constants

View Source
const (
	// DefaultThumbnailMaxWidth is the maximum width for thumbnails.
	DefaultThumbnailMaxWidth = 800
	// DefaultThumbnailQuality is the JPEG quality for thumbnails.
	DefaultThumbnailQuality = 75
)

Variables

This section is empty.

Functions

func DecodeWallpaper

func DecodeWallpaper(theme *Theme, basePath string) ([]byte, string, error)

DecodeWallpaper extracts wallpaper bytes from a theme. For embedded wallpapers, decodes the base64 data. For external references, reads from path or URL.

func Generate

func Generate(theme *Theme, includeThumbnail bool, thumbnailData string) (string, error)

Generate creates the complete markdown content for a theme.

func GenerateThumbnail

func GenerateThumbnail(imageData []byte, maxWidth int, quality int) (string, error)

GenerateThumbnail creates a smaller preview image from the original. Returns base64-encoded JPEG data.

func WriteFile

func WriteFile(path string, theme *Theme, includeThumbnail bool, thumbnailData string) error

WriteFile writes a theme to a markdown file.

Types

type Ambience

type Ambience struct {
	Hex    string  `yaml:"hex"`
	Region string  `yaml:"region"`
	Weight float64 `yaml:"weight"`
}

Ambience represents an ambient/edge color.

type Color

type Color struct {
	Hex    string  `yaml:"hex"`
	Weight float64 `yaml:"weight"`
	Role   string  `yaml:"role,omitempty"`
}

Color represents a color in the palette.

type Source

type Source struct {
	Plugin string `yaml:"plugin"`
	Model  string `yaml:"model,omitempty"`
	Prompt string `yaml:"prompt,omitempty"`
}

Source contains information about how the theme was generated.

type Theme

type Theme struct {
	Name      string    `yaml:"name"`
	Version   string    `yaml:"version"`
	Generator string    `yaml:"generator"`
	Generated time.Time `yaml:"generated"`

	Source    *Source    `yaml:"source,omitempty"`
	Wallpaper *Wallpaper `yaml:"wallpaper,omitempty"`
	Colors    []Color    `yaml:"colors"`
	Ambience  []Ambience `yaml:"ambience,omitempty"`
}

Theme represents a complete theme file with metadata, colors, and wallpaper.

func Parse

func Parse(data []byte) (*Theme, error)

Parse parses markdown theme data from bytes.

func ParseFile

func ParseFile(path string) (*Theme, error)

ParseFile reads and parses a markdown theme file.

type Thumbnail

type Thumbnail struct {
	Format string `yaml:"format"`
	Width  int    `yaml:"width"`
	Height int    `yaml:"height"`
	Data   string `yaml:"data"` // base64
}

Thumbnail contains a smaller preview image for the markdown body.

type Wallpaper

type Wallpaper struct {
	Embedded bool   `yaml:"embedded"`
	Format   string `yaml:"format,omitempty"`
	Width    int    `yaml:"width,omitempty"`
	Height   int    `yaml:"height,omitempty"`
	Data     string `yaml:"data,omitempty"` // base64, only if embedded
	Path     string `yaml:"path,omitempty"` // relative/absolute path
	URL      string `yaml:"url,omitempty"`  // remote URL
}

Wallpaper contains wallpaper image data or references.

func EncodeWallpaper

func EncodeWallpaper(data []byte, format string) (*Wallpaper, error)

EncodeWallpaper encodes image bytes to base64 and returns a Wallpaper struct.

func ExternalWallpaper

func ExternalWallpaper(path string) *Wallpaper

ExternalWallpaper creates a Wallpaper struct for an external file reference.

Jump to

Keyboard shortcuts

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