laika.parse.markdown

Markdown

class Markdown extends ParserFactory

A parser for Markdown text. Instances of this class may be passed directly to the Parse or Transform APIs:

val document = Parse as Markdown fromFile "hello.md"

Transform from Markdown to HTML fromFile "hello.md" toFile "hello.html"

Since this library is not solely focused on producing HTML output, parsing verbatim HTML elements like defined by the official Markdown syntax description is an optional feature, as some types of renderers would not know what to do with HTML nodes in the document tree. It must be enabled explicitly:

val document = Parse as (Markdown withVerbatimHTML) fromFile "hello.md"

The methods withSpanDirectives and withBlockDirectives allow to register custom tags which will be processed by the parser in addition to standard Markdown markup. For more details on directives see laika.directives.Directives.

To switch this feature off alongside other custom extensions like configuration sections at the start of the document or automatic id generation for headers, you can run the parser in strict mode:

Transform from Markdown.strict to HTML fromFile "hello.md" toFile "hello.html"
Linear Supertypes
ParserFactory, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Markdown
  2. ParserFactory
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  10. val fileSuffixes: Set[String]

    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.

    Definition Classes
    MarkdownParserFactory
  11. def finalize(): Unit

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

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

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

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

    Definition Classes
    AnyRef
  16. val newParser: (Input) ⇒ Document

    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.

    Definition Classes
    MarkdownParserFactory
  17. final def notify(): Unit

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

    Definition Classes
    AnyRef
  19. def strict: Markdown

    Turns strict mode on for the returned parser, switching off any features not part of the original Markdown syntax.

    Turns strict mode on for the returned parser, switching off any features not part of the original Markdown syntax. This includes the registration of directives (custom tags) as well as configuration sections at the start of the document or id generation for all headers.

  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  21. def toString(): String

    Definition Classes
    AnyRef → Any
  22. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. def withBlockDirectives(directives: directive.Directives.Blocks.Directive*): Markdown

    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 md = Markdown withBlockDirectives (
      Blocks.create("note") {
        (attribute(Default) ~ body(Default))(Note(_,_))
      }
    )
    Transform from md to HTML fromFile "hello.md" toFile "hello.html"

    For more details on implementing Laika directives see laika.directives.Directives.

  26. def withSpanDirectives(directives: directive.Directives.Spans.Directive*): Markdown

    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 md = Markdown withSpanDirectives (
      Spans.create("ticket") {
        (attribute(Default) ~ attribute("param").optional) { (ticketNo, param) =>
          val base = "http://tickets.service.com/"+ticketNo
          val url = base + (param map (p => "?param="+p) getOrElse "")
          ExternalLink(Seq(Text("Ticket "+ticketNo)), url, options = Styles("ticket"))
        }
      }
    )
    
    Transform from md to HTML fromFile "hello.md" toFile "hello.html"

    The code above registers a span directive that detects markup like @:ticket 2356. and turns it into an external link node for the URL http://tickets.service.com/2356.

    For more details on implementing Laika directives see laika.directives.Directives.

  27. def withVerbatimHTML: Markdown

    Returns a Markdown parser that also parses verbatim HTML elements alongside the standard Markdown markup.

    Returns a Markdown parser that also parses verbatim HTML elements alongside the standard Markdown markup. Usually only recommended when used together with an HTML renderer, as such a parser returns a document tree that contains HTML elements which some parsers would not know how to handle.

Inherited from ParserFactory

Inherited from AnyRef

Inherited from Any

Ungrouped