TwoPhaseTransformerBuilder

class TwoPhaseTransformerBuilder[FMT, PP](val markupFormat: MarkupFormat, val twoPhaseRenderFormat: TwoPhaseRenderFormat[FMT, PP], val config: OperationConfig) extends TransformerBuilderOps[FMT]

Builder API for Transformer instances.

Allows to add ExtensionBundles, to register AST rewrite rules, to override the renderer for specific elements and other options.

Type parameters:
FMT

the formatter API to use which varies depending on the renderer

PP

the type of the post processor

class Object
trait Matchable
class Any

Type members

Value members

Concrete methods

Inherited methods

Specifies a rewrite rule to be applied to the document tree model between the parse and render operations. This is identical to calling Document.rewrite directly, but if there is no need to otherwise access the document instance and just chain parse and render operations this hook is more convenient.

Specifies a rewrite rule to be applied to the document tree model between the parse and render operations. This is identical to calling Document.rewrite directly, but if there is no need to otherwise access the document instance and just chain parse and render operations this hook is more convenient.

The difference of this method to the usingRules method is that it expects a function that takes a DocumentCursor instance and returns the rewrite rules. This way the full document can be queried before any rule is applied. This is necessary in cases where the rule (which gets applied node-by-node) depends on information from other nodes. An example from the built-in rewrite rules is the rule that resolves link references. To replace all link reference elements with actual link elements, the rewrite rule needs to know all LinkDefinitions the document tree contains.

For being able to perform inspection tasks like this, the rule is executed in a later phase than rules added via usingRules. This means that such a rule is not supposed to insert any link targets itself, as the processing for those has already happened when this rule is run.

The builder function returns an Either[ConfigError, RewriteRules] which allows for validation of document configuration before creating the rule.

The rules themselves are partial functions of type PartialFunction[T, RewriteRule[T]] where T is either Span, Block or TemplateSpan, the 3 main categories of element types that support rewriting.

If the partial function is not defined for a specific element or the rule returns a Retain action as a result the old block remains in the tree unchanged.

If it returns Remove then the element gets removed from the ast, if it returns Replace with a new element it will replace the old one.

The rewriting is performed bottom-up (depth-first), therefore any element container passed to the rule only contains children which have already been processed.

Inherited from:
TransformerBuilderOps

Specifies the filter to apply to runtime messages that should cause a transformation to fail.

Specifies the filter to apply to runtime messages that should cause a transformation to fail.

The default is to fail transformations on messages of level Error or higher.

Inherited from:
ParserBuilderOps

Specifies the minimum required level for a runtime message to get included into the output by this renderer.

Specifies the minimum required level for a runtime message to get included into the output by this renderer.

Inherited from:
RendererBuilderOps
def rendering(customRenderer: PartialFunction[(FMT, Element), String]): ThisType

Specifies a custom render function that overrides one or more of the default renderers for the output format this instance uses.

Specifies a custom render function that overrides one or more of the default renderers for the output format this instance uses.

This method expects a partial function that takes a formatter and the element to render. It will then be invoked for each element it is defined at.

Simple example for customizing the HTML output for emphasized text, adding a specific style class:

val transformer = Transformer.from(Markdown).to(HTML).rendering {
  case (fmt, Emphasized(content, opt)) => fmt.element("em", opt, content, "class" -> "big")
}.build
Inherited from:
RendererBuilderOps

Turns strict mode on for the target parser, switching off any features not part of the original markup syntax. This includes the registration of markup directives (custom tags) as well as configuration sections at the start of the document.

Turns strict mode on for the target parser, switching off any features not part of the original markup syntax. This includes the registration of markup directives (custom tags) as well as configuration sections at the start of the document.

Inherited from:
ParserBuilderOps

Renders without any formatting (line breaks or indentation). Useful when storing the output in a database for example.

Renders without any formatting (line breaks or indentation). Useful when storing the output in a database for example.

Inherited from:
RendererBuilderOps

Returns a new instance with the specified extension bundles installed. Features in the new bundles may override features in already installed bundles.

Returns a new instance with the specified extension bundles installed. Features in the new bundles may override features in already installed bundles.

Bundles are usually provided by libraries (by Laika itself or a 3rd-party extension library) or as re-usable building blocks by application code.

Inherited from:
CommonBuilderOps

Specifies a single block rewrite rule to be applied to the document tree model between the parse and render operations. This is identical to calling Document.rewrite directly, but if there is no need to otherwise access the document instance and just chain parse and render operations this hook is more convenient.

Specifies a single block rewrite rule to be applied to the document tree model between the parse and render operations. This is identical to calling Document.rewrite directly, but if there is no need to otherwise access the document instance and just chain parse and render operations this hook is more convenient.

The rule is a type alias for a partial function of type PartialFunction[Block, RewriteRule[Block]].

If the partial function is not defined for a specific block or the rule returns a Retain action as a result the old block remains in the tree unchanged.

If it returns Remove then the block gets removed from the ast, if it returns Replace with a new block it will replace the old one.

The rewriting is performed bottom-up (depth-first), therefore any element container passed to the rule only contains children which have already been processed.

Inherited from:
TransformerBuilderOps

Specifies rewrite rules to be applied to the document tree model between the parse and render operations. This is identical to calling Document.rewrite directly, but if there is no need to otherwise access the document instance and just chain parse and render operations this hook is more convenient.

Specifies rewrite rules to be applied to the document tree model between the parse and render operations. This is identical to calling Document.rewrite directly, but if there is no need to otherwise access the document instance and just chain parse and render operations this hook is more convenient.

The rules are partial functions of type PartialFunction[T, RewriteRule[T]] where T is either Span, Block or TemplateSpan, the 3 main categories of element types that support rewriting.

If the partial function is not defined for a specific element or the rule returns a Retain action as a result the old element remains in the tree unchanged.

If it returns Remove then the element gets removed from the ast, if it returns Replace with a new element it will replace the old one.

The rewriting is performed bottom-up (depth-first), therefore any element container passed to the rule only contains children which have already been processed.

Inherited from:
TransformerBuilderOps

Specifies a single span rewrite rule to be applied to the document tree model between the parse and render operations. This is identical to calling Document.rewrite directly, but if there is no need to otherwise access the document instance and just chain parse and render operations this hook is more convenient.

Specifies a single span rewrite rule to be applied to the document tree model between the parse and render operations. This is identical to calling Document.rewrite directly, but if there is no need to otherwise access the document instance and just chain parse and render operations this hook is more convenient.

The rule is a type alias for a partial function of type PartialFunction[Span, RewriteRule[Span].

If the partial function is not defined for a specific span or the rule returns a Retain action as a result the old span remains in the tree unchanged.

If it returns Remove then the span gets removed from the ast, if it returns Replace with a new span it will replace the old one.

The rewriting is performed bottom-up (depth-first), therefore any element container passed to the rule only contains children which have already been processed.

Inherited from:
TransformerBuilderOps

Specifies a single rewrite rule for template spans to be applied to the template tree model between the parse and render operations. This is identical to calling TemplateDocument.rewrite directly, but if there is no need to otherwise access the document instance and just chain parse and render operations this hook is more convenient.

Specifies a single rewrite rule for template spans to be applied to the template tree model between the parse and render operations. This is identical to calling TemplateDocument.rewrite directly, but if there is no need to otherwise access the document instance and just chain parse and render operations this hook is more convenient.

The rule is a type alias for a partial function of type PartialFunction[TemplateSpan, RewriteRule[TemplateSpan].

If the partial function is not defined for a specific span or the rule returns a Retain action as a result the old span remains in the tree unchanged.

If it returns Remove then the span gets removed from the ast, if it returns Replace with a new span it will replace the old one.

The rewriting is performed bottom-up (depth-first), therefore any element container passed to the rule only contains children which have already been processed.

Inherited from:
TransformerBuilderOps
def withConfigValue[T : ConfigEncoder](key: Key, value: T): ThisType

Returns a new instance with the specified configuration value added.

Returns a new instance with the specified configuration value added.

The specified value with have higher precedence than any value with the same key registered by extension bundles, but lower precedence than any value with the same key specified in a configuration file for a directory or a configuration header in a markup document.

Inherited from:
ParserBuilderOps
def withConfigValue[T : ConfigEncoder](key: String, value: T): ThisType

Returns a new instance with the specified configuration value added.

Returns a new instance with the specified configuration value added.

The specified value with have higher precedence than any value with the same key registered by extension bundles, but lower precedence than any value with the same key specified in a configuration file for a directory or a configuration header in a markup document.

Inherited from:
ParserBuilderOps
def withConfigValue[T : DefaultKey](value: T): ThisType

Returns a new instance with the specified configuration value added.

Returns a new instance with the specified configuration value added.

The specified value with have higher precedence than any value with the same key registered by extension bundles, but lower precedence than any value with the same key specified in a configuration file for a directory or a configuration header in a markup document.

Inherited from:
ParserBuilderOps

Enables all extensions that process raw content embedded into the host markup language. These are disabled by default as Laika is designed to render to multiple output formats from a single input document. With raw content embedded the markup document is tied to a specific output format.

Enables all extensions that process raw content embedded into the host markup language. These are disabled by default as Laika is designed to render to multiple output formats from a single input document. With raw content embedded the markup document is tied to a specific output format.

Inherited from:
ParserBuilderOps

Deprecated and Inherited methods

@deprecated("use buildingRules", "0.19.0")
Deprecated
Inherited from:
TransformerBuilderOps