The file suffixes recognized by this parser.
The file suffixes recognized by this parser. When transforming entire directories only files with names ending in one of the specified suffixes will be consired.
It is recommended not to support txt
or similarly common suffixes as this might interfere
with other installed formats.
The actual parser function, fully parsing the specified input and returning a document tree.
The actual parser function, fully parsing the specified input and returning a document tree.
Turns strict mode on for the returned parser, switching off any features not part of the reStructuredText specification.
Turns strict mode on for the returned parser, switching off any features not part of the reStructuredText specification. This includes the Laika variant of directives as well as configuration sections at the start of the document.
Adds the specified directives and returns a new instance of the parser.
Adds the specified directives and returns a new instance of the parser. These block directives may then be used anywhere in documents parsed by this instance.
Example:
case class Note (title: String, content: Seq[Block]) extends Block with BlockContainer[Note] val rst = ReStructuredText withBlockDirectives ( BlockDirective("note") { (argument() ~ blockContent)(Note) } ) Transform from rst to HTML fromFile "hello.rst" toFile "hello.html"
For more details on implementing directives see laika.parse.rst.Directives.
Specifies the name of the default text role to apply when interpreted text is used in markup without an explicit role name.
Adds the specified Laika directives and returns a new instance of the parser.
Adds the specified Laika directives and returns a new instance of the parser.
Example:
case class Note (title: String, content: Seq[Block], options: Options = NoOpt) extends Block with BlockContainer[Note] val rst = ReStructuredText withLaikaBlockDirectives ( Blocks.create("note") { (attribute(Default) ~ body(Default))(Note(_,_)) } ) Transform from rst to HTML fromFile "hello.rst" toFile "hello.html"
For more details on implementing Laika directives see laika.directives.Directives.
Adds the specified Laika directives and returns a new instance of the parser.
Adds the specified Laika directives and returns a new instance of the parser.
Example:
val rst = ReStructuredText withLaikaSpanDirectives ( Spans.create("ticket") { (attribute(Default) ~ attribute("param").optional) { (ticketNo, param) => val base = "http://tickets.service.com/"+ticketNo val url = base + (param map (p => "¶m="+p) getOrElse "") ExternalLink(Seq(Text("Ticket "+ticketNo)), url, options = Styles("ticket")) } } ) Transform from rst to HTML fromFile "hello.rst" toFile "hello.html"
For more details on implementing Laika directives see laika.directives.Directives.
Adds the raw
directive and text roles to the parser.
Adds the raw
directive and text roles to the parser.
These are disabled by default as they present a potential security risk.
Adds the specified directives and returns a new instance of the parser.
Adds the specified directives and returns a new instance of the parser. These span directives can then be referred to by substitution references.
Example:
val rst = ReStructuredText withSpanDirectives ( SpanDirective("replace") { spanContent map SpanSequence } ) Transform from rst to HTML fromFile "hello.rst" toFile "hello.html"
For more details on implementing directives see laika.parse.rst.Directives.
Adds the specified text roles and returns a new instance of the parser.
Adds the specified text roles and returns a new instance of the parser. These text roles may then be used in interpreted text spans.
Example:
val rst = ReStructuredText withTextRoles ( TextRole("link", "http://www.our-server.com/tickets/")(field("base-url")) { (base, text) => Link(List(Text(text)), base + text) } ) Transform from rst to HTML fromFile "hello.rst" toFile "hello.html"
For more details on implementing directives see laika.parse.rst.TextRoles.
A parser for text written in reStructuredText markup. Instances of this class may be passed directly to the
Parse
orTransform
APIs:reStructuredText has several types of extension points that are fully supported by Laika. In contrast to the original Python implementation, the API has been redesigned to be a more idiomatic, concise and type-safe Scala DSL.
The following extension types are available:
withBlockDirectives
method of this class to add directive implementations to the parser. Specification entry: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#directives|subst|
). Use thewithSpanDirectives
method of this class to add directive implementations to the parser that can be used as substitution definitions. Specification entry: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#substitution-definitionswithTextRoles
method of this class to add custom text role implementations to the parser that can be referred to by interpreted text. Specification entry: http://docutils.sourceforge.net/docs/ref/rst/directives.html#custom-interpreted-text-rolesIn addition to the standard reStructuredText directives, the API also supports a custom directive type unique to Laika. They represent a library-wide extension mechanism and allow you to implement tags which can be used in any of the supported markup formats or in templates. If you need this level of flexibility, it is recommended to use the Laika directives, if you want to stay compatible with the reStructuredText reference parser, you should pick the standard directives.
Laika directives can be registered with the
withLaikaSpanDirective
andwithLaikaBlockDirective
calls respectively. reStructuredText directives can be registered withwithSpanDirective
andwithBlockDirective
respectively. The DSLs for creating directives are similar, but still different, due to differences in the feature set of the two variants. The Laika directives try to avoid some of the unnecessary complexities of reStructuredText directives.