trait DirectiveRegistry extends ExtensionBundle
Registry for custom directives. Application code can define any number of instances mixing in this trait and then pass them to Parse, Render or Transform operations:
object MyDirectives extends DirectiveRegistry { val spanDirectives = Seq(...) val blockDirectives = Seq(...) val templateDirectives = Seq(...) val linkDirectives = Seq(...) } object OtherDirectives extends DirectiveRegistry { [...] } val transformer = Transformer .from(Markdown) .to(HTML) .using(MyDirectives, OtherDirectives) .build
- Alphabetic
- By Inheritance
- DirectiveRegistry
- ExtensionBundle
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def blockDirectives: Seq[Blocks.Directive]
Registers the specified block directives.
Registers the specified block directives.
Example:
case class Note (title: String, content: Seq[Block], options: Options = NoOpt) extends Block with BlockContainer[Note] object MyDirectives extends DirectiveRegistry { val blockDirectives = Seq( Blocks.create("note") { (defaultAttribute.as[String] ~ body).map { case title ~ content => Note(title, content) } } ) val spanDirectives = Seq() val templateDirectives = Seq() val linkDirectives = Seq() } val transformer = Transformer.from(Markdown).to(HTML).using(MyDirectives).build
For more details on implementing Laika directives see laika.directive.BuilderContext.dsl.
- abstract def linkDirectives: Seq[Directive]
Registers the specified link directives.
Registers the specified link directives.
Example:
object MyDirectives extends DirectiveRegistry { val linkDirectives = Seq( Links.eval("rfc") { linkId => Try(Integer.parseInt(linkId)) .toEither .fold( _ => Left(s"Not a valid RFC id: $linkId"), id => Right(SpanLink.external(s"http://tools.ietf.org/html/rfc$linkId")(s"RFC $id")) ) } ) val blockDirectives = Seq() val spanDirectives = Seq() } val transformer = Transformer.from(Markdown).to(HTML).using(MyDirectives).build
The code above registers a link directive that detects markup like
@:rfc(2356)
and turns it into an external link node for the URLhttp://tools.ietf.org/html/rfc2356
.For more details on implementing Laika directives see laika.directive.BuilderContext.dsl.
- abstract def spanDirectives: Seq[Spans.Directive]
Registers the specified span directives.
Registers the specified span directives.
Example:
object MyDirectives extends DirectiveRegistry { val spanDirectives = Seq( Spans.create("ticket") { (defaultAttribute.as[String] ~ attribute("param").optional).map { case ticketNo ~ param => val base = "http://tickets.service.com/"+ticketNo val url = base + (param map (p => "?param="+p) getOrElse "") SpanLink.external(url)("Ticket "+ticketNo).withOptions(Styles("ticket")) } } ) val blockDirectives = Seq() val templateDirectives = Seq() val linkDirectives = Seq() } val transformer = Transformer.from(Markdown).to(HTML).using(MyDirectives).build
The code above registers a span directive that detects markup like
@:ticket(2356)
and turns it into an external link node for the URLhttp://tickets.service.com/2356
.For more details on implementing Laika directives see laika.directive.BuilderContext.dsl.
- abstract def templateDirectives: Seq[Templates.Directive]
Registers the specified template directives.
Registers the specified template directives.
Example:
object MyDirectives extends DirectiveRegistry { val templateDirectives = Seq( Templates.create("ticket") { (defaultAttribute.as[String] ~ attribute("param").optional).map { case ticketNo ~ param => val base = "http://tickets.service.com/"+ticketNo val url = base + (param map (p => "¶m="+p) getOrElse "") val link = SpanLink.external(url)("Ticket "+ticketNo).withOptions(Styles("ticket")) TemplateElement(link) } } ) val blockDirectives = Seq() val spanDirectives = Seq() val linkDirectives = Seq() } val transformer = Transformer.from(Markdown).to(HTML).using(MyDirectives).build
The code above registers a template directive that detects markup like
@:ticket(2356)
and turns it into an external link node for the URLhttp://tickets.service.com/2356
.For more details on implementing Laika directives see laika.directive.BuilderContext.dsl.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def acceptRawContent: Boolean
Indicates that this bundle deals with raw content embedded in text markup, like HTML.
Indicates that this bundle deals with raw content embedded in text markup, like HTML.
These kind of bundles 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.
Bundles which have this flag set to true need to be enabled explicitly by the user by calling
withRawContent
on theParse
orTransform
API:val transformer = Transformer.from(Markdown).to(HTML).withRawContent.build
- Definition Classes
- ExtensionBundle
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def baseConfig: Config
Base configuration that serves as a fallback for configuration files in the source directories and/or config headers in markup and template documents.
Base configuration that serves as a fallback for configuration files in the source directories and/or config headers in markup and template documents.
- Definition Classes
- ExtensionBundle
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- val description: String
Short string describing the extension for tooling and logging.
Short string describing the extension for tooling and logging.
- Definition Classes
- DirectiveRegistry → ExtensionBundle
- def docTypeMatcher: PartialFunction[Path, DocumentType]
Specifies the function to use for determining the document type of the input based on its path.
Specifies the function to use for determining the document type of the input based on its path.
Any path for which this function is not defined will be processed by the remaining defined bundles. The documents for paths for which none of the extensions provides a
DocumentType
will be treated as static files to be copied over to the target directory in transformations by default.- Definition Classes
- ExtensionBundle
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def origin: BundleOrigin
Indicates whether the bundle is a built-in default provided by the library, a collection of extensions installed by a markup format or user-defined.
Indicates whether the bundle is a built-in default provided by the library, a collection of extensions installed by a markup format or user-defined.
This is relevant for determining the precedence of installed bundles when merging them, as user-supplied functionality always overrides library defaults.
- Definition Classes
- ExtensionBundle
- def parsers: ParserBundle
Specifies extensions and/or replacements for parsers that deal with text markup, templates, CSS or configuration headers.
Specifies extensions and/or replacements for parsers that deal with text markup, templates, CSS or configuration headers.
- Definition Classes
- ExtensionBundle
- def processExtension: PartialFunction[ExtensionBundle, ExtensionBundle]
Internal API usually only called by other extension bundles.
Internal API usually only called by other extension bundles.
In some cases a bundle might be an extension of another bundle and needs the opportunity to process and modify that bundle without requiring a direct reference to it. An example is a registry for directives which needs to pass all its registered directives to the bundle which deals with finally creating all the directive parsers.
The partial function should match only on the types of bundles it intends to process and is then allowed to return a new, modified instance of that bundle.
- Definition Classes
- DirectiveRegistry → ExtensionBundle
- def renderOverrides: Seq[RenderOverrides]
The overrides for renderers defined by this bundle.
The overrides for renderers defined by this bundle.
An override is always specific to a particular output format like HTML or PDF. A bundle can contain multiple overrides for the same output format which will be merged before use.
- Definition Classes
- ExtensionBundle
- def rewriteRules: Seq[RewriteRulesBuilder]
Specifies rewrite rules to be applied to the document tree model between the parse and render operations.
Specifies rewrite rules to be applied to the document tree model between the parse and render operations.
The specified functions will be invoked for each document, allowing to capture information from the entire document tree before returning the actual rule, which is a partial function from
Element
toOption[Element]
that allows to remove or replace elements from the tree.- Definition Classes
- ExtensionBundle
- def slugBuilder: Option[(String) => String]
Function that receives the text of a headline, the name of a document or directory or a manually assigned identifier, and builds a slug from it that becomes part of the final URL or identifier (depending on output format).
Function that receives the text of a headline, the name of a document or directory or a manually assigned identifier, and builds a slug from it that becomes part of the final URL or identifier (depending on output format).
The result of the function must be:
- a valid identifier in HTML and XML - a valid path segment in a URL - a valid file name
- Definition Classes
- ExtensionBundle
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def useInStrictMode: Boolean
Indicates that this bundle should still be used if the user runs a transformation in strict mode.
Indicates that this bundle should still be used if the user runs a transformation in strict mode.
This setting is appropriate if a bundle contains features which are native elements of a text markup language as defined in its specification, but implemented as an extension for technical reasons.
- Definition Classes
- ExtensionBundle
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def withBase(base: ExtensionBundle): ExtensionBundle
Returns a new extension bundle by merging the content of this bundle with the content of the base bundle.
Returns a new extension bundle by merging the content of this bundle with the content of the base bundle.
The other bundle is treated as the base of this bundle, which means that:
- in case of optional features a feature defined in this bundle will overwrite a feature defined in the base
- in case of features applied in sequence, the features in this bundle will be applied before the features in the base bundle
- in case of feature collections, the features of this bundle will be merged with those of the base bundle
- Definition Classes
- ExtensionBundle