The type of the result returned by all operations of this trait.
The type of the result returned by all operations of this trait.
The type of the result returned by all operations of this trait.
The type of the operation being configured by this instance
The type of the operation being configured by this instance
The configuration to use for all input operations.
The configuration to use for all input operations.
Renders the specified document and returns a new target instance which allows to specify the output.
Renders the specified document and returns a new target instance which allows to specify the output.
the document to transform
Renders the specified document tree and returns a new target instance which allows to specify the output.
Renders the specified document tree and returns a new target instance which allows to specify the output.
the document tree to transform
Returns a new instance with the specified configuration.
Returns a new instance with the specified configuration.
This method discards any previously specified options. It is usually meant to be used when copying over the configuration from a fully configured object to an unconfigured one.
Specifies a rewrite rule to be applied to the document tree model between the parse and render operations.
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 usingRule
method is that it expects a function
that takes a Document instance and returns the rewrite rule. 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.
The rule itself is a partial function that takes an Element
and returns an Option[Element]
.
If the function is not defined for a specific element the old element remains
in the tree unchanged. If it returns None
then the node gets removed from the tree,
if it returns an element it will replace the old one. Of course the function may
also return the old element.
The rewriting is performed in a way that only branches of the tree that contain new or removed elements will be replaced. It is processed bottom-up, therefore any element container passed to the rule only contains children which have already been processed.
In case multiple rewrite rules need to be applied it may be more efficient to
first combine them with orElse
.
Returns the result obtained by parsing files from the current working directory.
Returns the result obtained by parsing files from the current working directory.
the files to exclude from processing
the character encoding of the files, if not specified the platform default will be used.
Returns the result obtained by parsing files from the specified directories and its subdirectories, merging them into a tree with a single root.
Returns the result obtained by parsing files from the specified directories and its subdirectories, merging them into a tree with a single root.
the root directories to traverse
the files to exclude from processing
the character encoding of the files, if not specified the platform default will be used.
Returns the result obtained by parsing files from the specified directories and its subdirectories, merging them into a tree with a single root.
Returns the result obtained by parsing files from the specified directories and its subdirectories, merging them into a tree with a single root.
the root directories to traverse
the character encoding of the files, if not specified the platform default will be used.
Returns the result obtained by parsing files from the specified directory and its subdirectories.
Returns the result obtained by parsing files from the specified directory and its subdirectories.
the root directory to traverse
the files to exclude from processing
the character encoding of the files, if not specified the platform default will be used.
Returns the result obtained by parsing files from the specified directory and its subdirectories.
Returns the result obtained by parsing files from the specified directory and its subdirectories.
the root directory to traverse
the character encoding of the files, if not specified the platform default will be used.
Returns the result obtained by parsing files from the specified directory and its subdirectories.
Returns the result obtained by parsing files from the specified directory and its subdirectories.
the name of the directory to traverse
the files to exclude from processing
the character encoding of the files, if not specified the platform default will be used.
Returns the result obtained by parsing files from the specified directory and its subdirectories.
Returns the result obtained by parsing files from the specified directory and its subdirectories.
the name of the directory to traverse
the character encoding of the files, if not specified the platform default will be used.
Returns the result from parsing the specified file.
Returns the result from parsing the specified file. Any kind of character input is valid, including empty files.
the file to use as input
the character encoding of the file, if not specified the platform default will be used.
Returns the result from parsing the file with the specified name.
Returns the result from parsing the file with the specified name. Any kind of character input is valid, including empty files.
the name of the file to parse
the character encoding of the file, if not specified the platform default will be used.
Returns the result from parsing the specified input.
Returns the result from parsing the specified input.
This is a generic method based on Laika's IO abstraction layer that concrete methods delegate to. Usually not used directly in application code, but might come in handy for very special requirements.
the input for the parser
Returns the result obtained by parsing files from the specified input tree.
Returns the result obtained by parsing files from the specified input tree.
the input tree to process
Returns the result obtained by parsing files from the specified input tree builder.
Returns the result obtained by parsing files from the specified input tree builder.
a builder for the input tree to process
Returns the result from parsing the input from the specified reader.
Returns the result from parsing the input from the specified reader.
Returns the result from parsing the input from the specified stream.
Returns the result from parsing the input from the specified stream.
the stream to use as input for the parser
the character encoding of the stream, if not specified the platform default will be used.
Returns the result from parsing a the specified string.
Returns the result from parsing a the specified string. Any kind of input is valid, including an empty string.
Instructs the parser and/or renderer to process all inputs and outputs in parallel, with the specified level of parallelism.
Instructs the parser and/or renderer to process all inputs and outputs in parallel, with the specified level of parallelism.
The recursive structure of document trees will be flattened before parsing and rendering and then get reassembled afterwards, therefore the parallel processing includes all subtrees of the document tree.
The actual transformation is a three phase process, the first (parsing) and third (rendering) can run in parallel. The second phase in the middle cannot, as this is the document tree model rewrite step where things like cross references or table of contents get processed that need access to more than just the current document.
the number of batches to be executed in parallel, 1 means sequential execution
the minimum number of operations required for parallel execution
Instructs the parser and/or renderer to process all inputs and outputs in parallel, with the default level of parallelism which corresponds to the number of CPUs.
Instructs the parser and/or renderer to process all inputs and outputs in parallel, with the default level of parallelism which corresponds to the number of CPUs.
The recursive structure of document trees will be flattened before parsing and rendering and then get reassembled afterwards, therefore the parallel processing includes all subtrees of the document tree.
The actual transformation is a three phase process, the first (parsing) and third (rendering) can run in parallel. The second phase in the middle cannot, as this is the document tree model rewrite step where things like cross references or table of contents get processed that need access to more than just the current document.
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 function that returns a partial function as the result. The outer function allows to capture the writer instance to write to and will only be invoked once. The partial function 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:
Transform from Markdown to HTML rendering { out => { case Emphasized(content) => out << """<em class="big">""" << content << "</em>" } } fromFile "hello.md" toFile "hello.html"
Turns strict mode on for the target parser, switching off any features not part of the original markup syntax.
Turns strict mode on for the target parser, switching off any features not part of the original markup syntax. This includes the registration of directives (custom tags), custom templates with directives, as well as configuration sections at the start of the document.
Technically it removes all ExtensionBundle
instances which do not have
the useInStrictMode
flag set to true.
Renders without any formatting (line breaks or indentation).
Renders without any formatting (line breaks or indentation). Useful when storing the output in a database for example.
Returns a new instance with the specified extension bundles installed.
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.
Specifies a rewrite rule to be applied to the document tree model between the parse and render operations.
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 rule is a partial function that takes an Element
and returns an Option[Element]
.
If the function is not defined for a specific element the old element remains
in the tree unchanged. If it returns None
then the node gets removed from the tree,
if it returns an element it will replace the old one. Of course the function may
also return the old element.
The rewriting is performed in a way that only branches of the tree that contain new or removed elements will be replaced. It is processed bottom-up, therefore any element container passed to the rule only contains children which have already been processed.
In case multiple rewrite rules need to be applied it may be more efficient to
first combine them with orElse
.
Specifies the minimum required level for a system message to get included into the output by this renderer.
Specifies the minimum required level for a system message to get included into the output by this renderer.
Enables all extensions that process raw content embedded into the host markup language.
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.
Technically it activates all ExtensionBundle
instances which have
the acceptRawContent
flag set to true.
API for performing a transformation operation from and to various types of input and output, combining a parse and render operation.
In cases where a parse or render operation should be performed separately, for example for manually processing the document tree model between these operations, the laika.api.Parse and laika.api.Render APIs should be used instead.
Example for transforming from Markdown to HTML using files for both input and output:
Example for transforming an entire directory and its subdirectories to HTML in a target directory:
Example for transforming an entire directory and its subdirectories to a single PDF file:
Or for transforming a document fragment from a string to the AST format for debugging purposes:
Apart from specifying input and output, the Transform API also allows to customize the operation in various ways. The
usingRule
andcreatingRule
methods allow to rewrite the document tree between the parse and render operations and therendering
method allows to customize the way certain types of elements are rendered.the writer API to use which varies depending on the renderer