API for performing a parse operation from various types of input to obtain a document tree without a subsequent render operation.
API for performing a render operation to various types of output using an existing document tree model.
API for performing a render operation to various types of output using an existing document tree model.
In cases where a render operation follows a parse operation immediately, it is more convenient to use the laika.api.Transform API instead which combines a parse and a render operation directly.
Example for rendering HTML to a file:
val doc: Document = ... Render as HTML from doc toFile "hello.html"
Example for rendering HTML from an entire tree of documents to a directory:
val tree: DocumentTree = ... Render as HTML from tree toDirectory "path/to/output"
Example for rendering PDF from an entire tree of documents to a single target file:
val tree: DocumentTree = ... Render as PDF from tree toFile "hello.pdf"
the writer API to use which varies depending on the renderer
API for performing a transformation operation from and to various types of input and output, combining a parse and render operation.
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:
Transform from Markdown to HTML fromFile "hello.md" toFile "hello.html"
Example for transforming an entire directory and its subdirectories to HTML in a target directory:
Transform from Markdown to HTML fromDirectory "source" toDirectory "target"
Example for transforming an entire directory and its subdirectories to a single PDF file:
Transform from Markdown to PDF fromDirectory "source" toFile "hello.pdf"
Or for transforming a document fragment from a string to the AST format for debugging purposes:
val input = "some *emphasized* text" Transform from Markdown to AST fromString input toString res0: java.lang.String = Document - Blocks: 1 . Paragraph - Spans: 3 . . Text - 'some ' . . Emphasized - Spans: 1 . . . Text - 'emphasized' . . Text - ' text'
Apart from specifying input and output, the Transform API also allows to customize the operation
in various ways. The usingRule
and creatingRule
methods allow to rewrite the document tree
between the parse and render operations and the rendering
method allows to customize the
way certain types of elements are rendered.
the writer API to use which varies depending on the renderer
API for performing a parse operation from various types of input to obtain a document tree without a subsequent render operation.
In cases where a render operation should follow immediately, it is more convenient to use the laika.api.Transform API instead which combines a parse and a render operation directly.
Example for parsing Markdown from a file:
Example for parsing from an entire directory:
Example for parsing a directory that contains markup documents in different formats: