Trait

laika.rst.bundle

RstExtensionRegistry

Related Doc: package bundle

Permalink

trait RstExtensionRegistry extends ExtensionBundle

Registry for custom reStructuredText extensions. Application code can define any number of instances mixing in this trait and then pass them to Parse, Render or Transform operations:

object MyExtensions extends RstExtensionRegistry {
  val spanDirectives = Seq(...)
  val blockDirectives = Seq(...)
  val textRoles = Seq(...)
}
object OtherExtensions extends RstExtensionRegistry {
  [...]
}

Transform
  .from(ReStructuredText)
  .to(HTML)
  .using(MyDirectives, OtherDirectives)
  .fromFile("hello.rst")
  .toFile("hello.html")

In contrast to the original Python implementation, this API has been redesigned to be a more idiomatic, concise and type-safe Scala DSL. See the documentation for the methods of this trait for concrete examples on how to implement an extension.

The following extension types are available:

Linear Supertypes
ExtensionBundle, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. RstExtensionRegistry
  2. ExtensionBundle
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def blockDirectives: Seq[Directive[Block]]

    Permalink

    Registers the specified block directives.

    Registers the specified block directives.

    Example:

    case class Note (title: String, content: Seq[Block]) extends Block with BlockContainer[Note]
    
    object MyDirectives extends RstExtensionRegistry {
      val blockDirectives = Seq(
        BlockDirective("note") {
          (argument() ~ blockContent)(Note)
        }
      )
      val spanDirectives = Seq()
      val textRoles = Seq()
    }
    
    Transform.from(ReStructuredText).to(HTML)
      .using(MyDirectives)
      .fromFile("hello.rst").toFile("hello.html")

    For more details on implementing directives see laika.rst.ext.Directives.

  2. abstract def spanDirectives: Seq[Directive[Span]]

    Permalink

    Registers the specified span directives.

    Registers the specified span directives. These span directives can then be referred to by substitution references.

    Example:

    object MyDirectives extends RstExtensionRegistry {
      val spanDirectives = Seq(
        SpanDirective("replace") {
          spanContent map SpanSequence
        }
      )
      val blockDirectives = Seq()
      val textRoles = Seq()
    }
    
    Transform.from(ReStructuredText).to(HTML)
      .using(MyDirectives)
      .fromFile("hello.rst").toFile("hello.html")

    For more details on implementing directives see laika.rst.ext.Directives.

  3. abstract def textRoles: Seq[TextRole]

    Permalink

    Registers the specified text roles.

    Registers the specified text roles. These text roles may then be used in interpreted text spans.

    Example:

    val textRole = TextRole("link", "http://www.company.com/main/")(field("base-url")) {
      (base, text) => Link(List(Text(text)), base + text)
    }
    
    object MyDirectives extends RstExtensionRegistry {
      val textRoles = Seq(textRole)
      val spanDirectives = Seq()
      val blockDirectives = Seq()
    }
    
    Transform from ReStructuredText to HTML using
      MyDirectives fromFile "hello.rst" toFile "hello.html"

    For more details on implementing directives see laika.rst.ext.TextRoles.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def acceptRawContent: Boolean

    Permalink

    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 the Parse or Transform API:

    Transform.from(Markdown).to(HTML).withRawContent
      .fromFile("hello.md").toFile("hello.html")
    Definition Classes
    ExtensionBundle
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def baseConfig: Config

    Permalink

    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
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def defaultTextRole: Option[String]

    Permalink

    Overrides the name of the default text role to apply when interpreted text is used in markup without an explicit role name.

  9. def docTypeMatcher: PartialFunction[Path, DocumentType]

    Permalink

    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
  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. def parsers: ParserBundle

    Permalink

    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
  20. def processExtension: PartialFunction[ExtensionBundle, ExtensionBundle]

    Permalink

    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
    RstExtensionRegistryExtensionBundle
  21. def rewriteRules: Seq[(DocumentCursor) ⇒ RewriteRule]

    Permalink

    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 to Option[Element] that allows to remove or replace elements from the tree.

    Definition Classes
    ExtensionBundle
  22. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  23. def themes: Seq[RenderTheme]

    Permalink

    The themes defined by this bundle, which are a collection of templates, styles and custom render functions.

    The themes defined by this bundle, which are a collection of templates, styles and custom render functions.

    A theme is always specific to a particular output format like HTML or PDF. A bundle can contain multiple themes for the same output format which will be merged before use.

    Definition Classes
    ExtensionBundle
  24. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  25. val useInStrictMode: Boolean

    Permalink

    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
    RstExtensionRegistryExtensionBundle
  26. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. def withBase(base: ExtensionBundle): ExtensionBundle

    Permalink

    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

Inherited from ExtensionBundle

Inherited from AnyRef

Inherited from Any

Ungrouped