Builder API for constructing Theme
instances, providing several shortcuts for defining the contents
of a theme.
A theme can consist of inputs like templates, CSS or JavaScript files and optionally of one or more
extension bundles for customizing Laika with features like directives or parser extensions.
The API is entirely optional and can be used to avoid boilerplate when implementing a laika.theme.ThemeProvider.
- Companion
- object
Value members
Concrete methods
Add pre-populated configuration to the theme that will be merged with the user-supplied configuration. User configuration has always higher precedence than theme configuration. It is recommended to put all theme-specific configuration into a namespace to avoid clashes.
Add pre-populated configuration to the theme that will be merged with the user-supplied configuration. User configuration has always higher precedence than theme configuration. It is recommended to put all theme-specific configuration into a namespace to avoid clashes.
Most common use case for pre-populating configuration is to provide AST nodes and strings to be used in the theme templates.
Adds one or more extension bundles to the theme.
For the most common bundle features like pre-populated configuration, rewrite rules or render overrides,
the respective shortcuts of this class can be used to avoid the boilerplate of extending ExtensionBundle
yourself.
The shortcuts are addBaseConfig
, addRewriteRules
and addRenderOverrides
.
Adds one or more extension bundles to the theme.
For the most common bundle features like pre-populated configuration, rewrite rules or render overrides,
the respective shortcuts of this class can be used to avoid the boilerplate of extending ExtensionBundle
yourself.
The shortcuts are addBaseConfig
, addRewriteRules
and addRenderOverrides
.
Adds the specified inputs to the theme. When the method is invoked multiple times the respective input trees will be merged.
Adds the specified inputs to the theme. When the method is invoked multiple times the respective input trees will be merged.
Adds the specified inputs, suspended in the effect F
, to the theme.
When the method is invoked multiple times the respective input trees will be merged.
Adds the specified inputs, suspended in the effect F
, to the theme.
When the method is invoked multiple times the respective input trees will be merged.
Adds overrides for the renderer which can be used for theme-specific UI elements.
One example is to provide custom icons for some of Laika's decorated blocks, like those produced
by the @:callout
directive.
Adds overrides for the renderer which can be used for theme-specific UI elements.
One example is to provide custom icons for some of Laika's decorated blocks, like those produced
by the @:callout
directive.
Adds a custom rewrite rule that can swap or remove individual nodes from the document AST.
In contrast to the processTree
hook which looks at the entire tree of documents,
a rewrite rule looks at the individual AST nodes within a document.
Adds a custom rewrite rule that can swap or remove individual nodes from the document AST.
In contrast to the processTree
hook which looks at the entire tree of documents,
a rewrite rule looks at the individual AST nodes within a document.
This is an overload that allows to construct the rules based on looking at the corresponding
DocumentCursor
first.
Adds a custom rewrite rule that can swap or remove individual nodes from the document AST.
In contrast to the processTree
hook which looks at the entire tree of documents,
a rewrite rule looks at the individual AST nodes within a document.
Adds a custom rewrite rule that can swap or remove individual nodes from the document AST.
In contrast to the processTree
hook which looks at the entire tree of documents,
a rewrite rule looks at the individual AST nodes within a document.
Builds a theme resource based on the elements passed to this builder instance.
Builds a theme resource based on the elements passed to this builder instance.
Adds a function that processes the document tree between parsing and rendering.
In contrast to the addRewriteRule
hook which looks at AST nodes within a document,
this function can look at the entire tree and add, swap or remove documents for example.
Adds a function that processes the document tree between parsing and rendering.
In contrast to the addRewriteRule
hook which looks at AST nodes within a document,
this function can look at the entire tree and add, swap or remove documents for example.
The laika.theme.TreeProcessorBuilder provides several shortcuts for constructing
a TreeProcessor
(which is just a type alias for a plain Kleisli
).
Adds a function that processes the document tree between parsing and rendering, to be executed only for the specified output format.
Adds a function that processes the document tree between parsing and rendering, to be executed only for the specified output format.
In contrast to the addRewriteRule
hook which looks at AST nodes within a document,
this function can look at the entire tree and add, swap or remove documents for example.
In case of binary formats like EPUB or PDF this processing step happens before the renderer for the
interim format is invoked.
As a consequence you need to pass their interim formats to this method,
which is EPUB.XHTML
for EPUB and XSLFO
for PDF.
This also avoids a dependency on the PDF module as the user of your theme might not use it.
The laika.theme.TreeProcessorBuilder provides several shortcuts for constructing
a TreeProcessor
(which is just a type alias for a plain Kleisli
).