Documentation
¶
Overview ¶
Package theme loads Marp theme CSS and packs it for a deck, as Marpit's Theme, ThemeSet and theme pack pipeline do (theme.js, theme_set.js and the postcss plugins they run).
Index ¶
- func Scope(src, attr string) string
- type PackOptions
- type Packed
- type Set
- func (s *Set) Add(src string) (*Theme, error)
- func (s *Set) Get(name string) *Theme
- func (s *Set) Has(name string) bool
- func (s *Set) Meta(t *Theme, key string) []string
- func (s *Set) Names() []string
- func (s *Set) Pack(t *Theme, opts PackOptions) Packed
- func (s *Set) Resolve(name string) *Theme
- func (s *Set) Size(t *Theme) (w, h string)
- func (s *Set) SizePreset(t *Theme, name string) (w, h string, ok bool)
- type Theme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Scope ¶
Scope confines a <style scoped> element's CSS to one slide, selected by attr (a data attribute the slide carries), as Marpit's style/assign.js does: a selector starting with section narrows the slide itself, any other becomes a descendant of it, and keyframes are renamed so they cannot collide with another slide's.
Types ¶
type PackOptions ¶
type PackOptions struct {
// Before is CSS put ahead of the theme (Marpit's pack option of that
// name): what the renderer needs whatever the theme, such as the rule
// for emoji images.
Before []string
// After is CSS appended to the theme: the deck's style directive and
// global <style> elements, then its scoped styles (see Scope).
After []string
// Container is the selector of the element holding the slides;
// "" means "div.marpit".
Container string
// Slide lists the elements from the container down to the section;
// nil means just "section".
Slide []string
// InlineSVG adds the advanced background rules.
InlineSVG bool
// Printable adds @page and the print rules.
Printable bool
// ContainerQuery makes the slide a size container (Marp Core).
ContainerQuery bool
// Size names a @size preset of the theme (the size directive).
Size string
// GeneratedContent lowers section::after to an element selector, for
// layout engines that do not generate content (see Packed.After).
GeneratedContent bool
}
PackOptions configures Pack.
type Packed ¶
type Packed struct {
CSS string
// Width and Height are the slide size in CSS pixels.
Width, Height float64
// After is the content expression of the theme's section::after rule
// when GeneratedContent lowered it, for the renderer to evaluate.
After string
}
Packed is a packed style sheet.
type Set ¶
type Set struct {
// Default is the theme used when a deck names none or an unknown one;
// nil falls back to Marpit's scaffold.
Default *Theme
// contains filtered or unexported fields
}
Set is a set of themes by name.
func NewSet ¶
func NewSet() *Set
NewSet returns a set holding Marp Core's built-in themes (default, gaia and uncover), with default as the default.
func (*Set) Meta ¶
Meta returns a theme's metadata through its imports: the first theme in the chain that defines the key, or, when every definition is a list, all of them with the importing theme's last.
func (*Set) Pack ¶
func (s *Set) Pack(t *Theme, opts PackOptions) Packed
Pack builds the style sheet of a deck using theme t (Marpit's ThemeSet.pack, with Marp Core's size directive).
type Theme ¶
type Theme struct {
Name string
// CSS is the theme as loaded: nesting resolved and :root replaced.
CSS string
// Meta holds the @key value comments, every occurrence in order.
Meta map[string][]string
// Imports name the themes this one imports, @import-theme first.
Imports []string
// Width and Height are the section size the theme sets, as written.
Width, Height string
}
Theme is a theme style sheet and what its comments declare.