ThemeSet

ThemeSet

Marpit theme set class.

Constructor

new ThemeSet()

Create a ThemeSet instance.

Source:

Members

default :Theme|undefined

An instance of default theme.

While running ThemeSet#pack, ThemeSet will use this theme when the definition of theme directive or the theme with specified name is not found.

By default, Marpit does not provide default theme (undefined).

Source:
Type:

(readonly) size :number

Return the number of themes.

Source:
Type:
  • number

Methods

add(css) → {Theme}

Add theme CSS from string.

Source:
Parameters:
Name Type Description
css string

The theme CSS string.

Throws:

Will throw an error if the theme name is not specified by @theme.

Returns:
Type:
Theme

A created Theme instance.

addTheme(theme)

Add theme instance.

Source:
Parameters:
Name Type Description
theme Theme

The theme instnace.

Throws:

Will throw an error if the theme name is not specified.

clear()

Removes all themes from a themeSet object.

Source:

delete(name) → {boolean}

Remove a specific named theme from a themeSet object.

Source:
Parameters:
Name Type Description
name string

The theme name to delete.

Returns:
Type:
boolean

Returns true if a theme in current ThemeSet existed and has been removed, or false if the theme does not exist.

get(name, fallbackopt) → {Theme|undefined}

Returns a specific named theme.

Source:
Parameters:
Name Type Attributes Default Description
name string

The theme name to get.

fallback boolean <optional>
false

If true, return instance's default theme or scaffold theme when specified theme cannot find.

Returns:
Type:
Theme | undefined

Returns specified or fallbacked theme, or undefined if fallback is false and the specified theme has not existed.

getThemeProp(theme, propPath)

Returns the value of property from a specified theme. It considers @import rules in getting property value.

It will fallback the reference object into the instance's default theme or scaffold theme when the specified theme is undefined.

Source:
Parameters:
Name Type Description
theme string | Theme

The theme name or instance.

propPath string

The property name or path to get.

has(name) → {boolean}

Returns a boolean indicating whether a specific named theme exists or not.

Source:
Parameters:
Name Type Description
name string

The theme name.

Returns:
Type:
boolean

Returns true if a specific named theme exists, otherwise false.

pack(name, optsopt) → {string}

Convert registered theme CSS into usable in the rendered markdown by Marpit#render.

You should use Marpit#render unless there is some particular reason.

Source:
Parameters:
Name Type Attributes Description
name string

The theme name. It will use the instance's default theme or scaffold theme when a specific named theme does not exist.

opts Object <optional>

The option object passed by Marpit#render.

Name Type Attributes Description
after string <optional>

A CSS string to append into after theme.

before string <optional>

A CSS string to prepend into before theme.

containers Array.<Element> <optional>

Container elements wrapping whole slide deck.

printable boolean <optional>

Make style printable to PDF.

inlineSVG boolean <optional>

Apply a hierarchy of inline SVG to CSS selector by setting true. (Experimental)

Returns:
Type:
string

The converted CSS string.

themes() → {Iterator.<Theme>}

Returns a Iterator object that contains registered themes to current instance.

Source:
Returns:
Type:
Iterator.<Theme>