API for configuring a batch operation for a directory.
Represents a single transformation operation for a specific input that has already been parsed.
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 expects 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
.
Parses files from the specified directory and its subdirectories and returns a new builder instance which allows to specify the output and other configuration options.
Parses files from the specified directory and its subdirectories and returns a new builder instance which allows to specify the output and other configuration options.
the directory to traverse
the character encoding of the files, if not specified the platform default will be used.
Parses files from the specified directory and its subdirectories and returns a new builder instance which allows to specify the output and other configuration options.
Parses files from the specified directory and its subdirectories and returns a new builder instance which allows to specify the output and other configuration options.
the name of the directory to traverse
the character encoding of the files, if not specified the platform default will be used.
Parses the specified file and returns a new Operation instance which allows to specify the output.
Parses the specified file and returns a new Operation instance which allows to specify the output. Any kind of character input is valid, including empty files.
the file to read from
the character encoding of the file, if not specified the platform default will be used.
Parses the file with the specified name and returns a new Operation instance which allows to specify the output.
Parses the file with the specified name and returns a new Operation instance which allows to specify the output. 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.
Parses the input from the specified reader and returns a new Operation instance which allows to specify the output.
Parses the input from the specified stream and returns a new Operation instance which allows to specify the output.
Parses the input from the specified stream and returns a new Operation instance which allows to specify the output.
the stream to use as input for the parser
the character encoding of the stream, if not specified the platform default will be used.
Parses the specified string and returns a new Operation instance which allows to specify the output.
Parses the specified string and returns a new Operation instance which allows to specify the output. Any kind of input is valid, including an empty string.
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 parameter. 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 elememnt 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"
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
.
Transforms documents according to the specified batch configuration.
Transforms documents according to the specified batch configuration.
the configuration for the input and output trees to process
Transforms documents according to the specified batch configuration.
Transforms documents according to the specified batch configuration.
a builder for the configuration for the input and output trees to process
Parses files from the source
directory inside the current working directory
and renders the result to the target
directory inside the current working directory.
Parses files from the source
directory inside the current working directory
and renders the result to the target
directory inside the current working directory.
the character encoding of the files, if not specified the platform default will be used.
Parses files from the source
directory inside the specified root directory
and renders the result to the target
directory inside the root directory.
Parses files from the source
directory inside the specified root directory
and renders the result to the target
directory inside the root directory.
Both directories must already exist inside the specified directory.
the root directory that contains the source and target directory
the character encoding of the files, if not specified the platform default will be used.
Parses files from the source
directory inside the specified root directory
and renders the result to the target
directory inside the root directory.
Parses files from the source
directory inside the specified root directory
and renders the result to the target
directory inside the root directory.
Both directories must already exist inside the specified directory.
the name of the root directory that contains the source and target directory
the character encoding of the files, if not specified the platform default will be used.
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:
Or for transforming a document fragment from a string to the PrettyPrint 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