laika.io.model

Type members

Classlikes

case class BinaryInput[F[_]](path: Path, input: Resource[F, InputStream], formats: TargetFormats, sourceFile: Option[File])(implicit evidence$1: Sync[F]) extends Navigatable

A binary input stream and its virtual path within the input tree.

A binary input stream and its virtual path within the input tree.

Companion
object
object BinaryInput
Companion
class
case class BinaryOutput[F[_]](path: Path, resource: Resource[F, OutputStream], targetFile: Option[File])

A resource for binary output.

A resource for binary output.

Most renderers write character data, but formats like PDF or EPUB require a binary stream to write to.

case class DirectoryInput(directories: Seq[File], codec: Codec, docTypeMatcher: Path => DocumentType, fileFilter: File => Boolean, mountPoint: Path)

A directory in the file system containing input documents for a tree transformation.

A directory in the file system containing input documents for a tree transformation.

The specified docTypeMatcher is responsible for determining the type of input (e.g. text markup, template, etc.) based on the (virtual) document path.

Companion
object
Companion
class
case class DirectoryOutput(directory: File, codec: Codec) extends TreeOutput

A directory as a target for a rendering operation of a document tree.

A directory as a target for a rendering operation of a document tree.

The specified codec will be used for writing all character output.

sealed trait InputReader extends Product with Serializable
case class InputTree[F[_]](textInputs: Seq[TextInput[F]], binaryInputs: Seq[BinaryInput[F]], parsedResults: Seq[ParserResult], providedPaths: Seq[StaticDocument], sourcePaths: Seq[String])

A (virtual) tree of input documents, either obtained from scanning a directory recursively or constructed programmatically (or a mix of both).

A (virtual) tree of input documents, either obtained from scanning a directory recursively or constructed programmatically (or a mix of both).

Even though the documents are specified as a flat sequence, they logically form a tree based on their virtual path.

Companion
object
object InputTree

Factory methods for creating InputTreeBuilder instances.

Factory methods for creating InputTreeBuilder instances.

Companion
class
class InputTreeBuilder[F[_]](val exclude: File => Boolean, val steps: Vector[(Path => DocumentType, File => Boolean) => Kleisli[F, InputTree[F], InputTree[F]]], val fileRoots: Vector[File])(implicit F: Sync[F])

Builder API for freely constructing input trees from directories, files, classpath resources, in-memory strings or pre-constructed AST trees.

Builder API for freely constructing input trees from directories, files, classpath resources, in-memory strings or pre-constructed AST trees.

If your input is just one or more directories, you can use the corresponding shortcuts on the parser or transformer instances, e.g. transformer.fromDirectory(...).toDirectory(...). This builder is meant to be used for situations where more flexibility is required.

All the specified inputs will be combined into a single logical tree and each document gets a virtual path assigned that describes its logical position within the tree. As a consequence all cross-linking or referencing of images can happen within the virtual path abstraction, meaning a resource from the file system can point to an input constructed in-memory via a relative, virtual path.

When adding strings, files or directories you need to specify a "mount point" that signals where within the virtual tree the inputs should be placed. For adding directories the mount point is optional, when omitted the directory becomes the virtual root of the input tree.

The resulting input tree can be passed to parsers, transformers and theme builders.

Example for composing inputs from two directories, a template loaded from the classpath and a CSS file generated in-memory:

val inputs = InputTree[F]
 .addDirectory("/path-to-my/markup-files")
 .addDirectory("/path-to-my/images", Root / "images")
 .addClasspathResource("my-templates/default.template.html", DefaultTemplatePath.forHTML)
 .addString(generateMyStyles(), Root / "css" / "site.css")

These inputs can then be configured for the sbt plugin:

 laikaInputs := inputs

Or passed to a TreeTransformer instance:

val res: F[RenderedTreeRoot[F]] = transformer.use {
 _.fromInputTree(inputs)
  .toDirectory("target")
  .transform
}
sealed trait OutputWriter extends Product with Serializable
case class ParsedTree[F[_]](root: DocumentTreeRoot, staticDocuments: Seq[BinaryInput[F]])

The result of a parsing operation for an entire document tree.

The result of a parsing operation for an entire document tree.

The DocumentTreeRoot is the recursive structure of parsed inputs, like markup document, templates or other file types, represented by their AST.

The static documents are merely a sequence of unprocessed inputs that have been discovered via directory scanning (or have been passed programmatically). The actual processing of these inputs is left to the render step, which might copy them into a target directory, or embed them into an output format like EPUB.

case class PureReader(input: String) extends InputReader
case object PureWriter extends OutputWriter
sealed trait RenderContent extends Navigatable

A titled, positional element in the tree of rendered documents.

A titled, positional element in the tree of rendered documents.

case class RenderedDocument(path: Path, title: Option[SpanSequence], sections: Seq[SectionInfo], content: String, config: Config) extends RenderContent with DocumentNavigation

A single rendered document with the content as a plain string in the target format.

A single rendered document with the content as a plain string in the target format.

The title and section info are still represented as an AST, so they be used in any subsequent step that needs to produce navigation structures.

case class RenderedTree(path: Path, title: Option[SpanSequence], content: Seq[RenderContent], titleDocument: Option[RenderedDocument]) extends RenderContent

Represents a node of the tree of rendered documents.

Represents a node of the tree of rendered documents.

Value Params
content

the rendered documents and subtrees in a recursive structure

path

the full, absolute path of this (virtual) document tree

title

the title of this tree, either obtained from the title document or configuration

titleDocument

the optional title document of this tree

case class RenderedTreeRoot[F[_]](tree: RenderedTree, defaultTemplate: TemplateRoot, config: Config, styles: StyleDeclarationSet, coverDocument: Option[RenderedDocument], staticDocuments: Seq[BinaryInput[F]])

Represents the root of a tree of rendered documents. In addition to the recursive structure of documents it holds additional items like static or cover documents, which may contribute to the output of a site or an e-book.

Represents the root of a tree of rendered documents. In addition to the recursive structure of documents it holds additional items like static or cover documents, which may contribute to the output of a site or an e-book.

Value Params
config

the root configuration of the rendered tree

coverDocument

the cover document (usually used with e-book formats like EPUB and PDF)

defaultTemplate

the default template configured for the output format, which may be used by a post-processor

staticDocuments

the paths of documents that were neither identified as text markup, config or templates, and will potentially be embedded or copied as is to the final output, depending on the output format

tree

the recursive structure of documents, usually obtained from parsing text markup

case class StreamReader(input: Reader, sizeHint: Int) extends InputReader
case class StreamWriter(output: Writer) extends OutputWriter
case object StringTreeOutput extends TreeOutput

Instructs the renderer to produce an in-memory representation of the tree of rendered outputs.

Instructs the renderer to produce an in-memory representation of the tree of rendered outputs.

case class TextInput[F[_]](path: Path, docType: TextDocumentType, input: Resource[F, InputReader], sourceFile: Option[File]) extends Navigatable

Character input for the various parsers of this library.

Character input for the various parsers of this library.

Value Params
docType

Indicates the type of the document, to distinguish between text markup, templates, configuration and style sheets, which all have a different kind of parser

input

The resource to read the character input from

path

The full virtual path of this input (does not represent the filesystem path in case of file I/O)

sourceFile

The source file from the file system, empty if this does not represent a file system resource

Companion
object
object TextInput
Companion
class
case class TextOutput[F[_]](path: Path, resource: Resource[F, OutputWriter], targetFile: Option[File])

Character output for the various renderers of this library

Character output for the various renderers of this library

Value Params
path

The full virtual path of this input (does not represent the filesystem path in case of file I/O)

resource

The resource to write the character output to

targetFile

The target file in the file system, empty if this does not represent a file system resource

Companion
object
object TextOutput
Companion
class
sealed trait TreeOutput

A (virtual) tree of output documents.

A (virtual) tree of output documents.