Documentation for the private Markdown2 module.




Provides types and functions to work with Markdown syntax trees.

The module is similar to the Markdown standard library, but aims to be stricter and provide a more well-defined API.


Markdown2 does not provide a parser, just a data structure to represent Markdown ASTs.

Markdown nodes

The types in this module represent the different types of nodes you can have in a Markdown abstract syntax tree (AST). Currently it supports all the nodes necessary to represent Julia flavored Markdown. But having this as a separate module from the Markdown standard library allows us to consistently extend the node type we support (e.g. to support the raw HTML nodes from CommonMark, or strikethrough text from GitHub Flavored Markdown).

Markdown nodes split into to two different classes: block nodes and inline nodes. Generally, the direct children of a particular node can only be either inline or block (e.g. paragraphs contain inline nodes, admonitions contain block nodes as direct children).

In Markdown2, this is represented using a simple type hierarchy. All Markdown nodes are subtypes of either the MarkdownBlockNode or the MarkdownInlineNode abstract type. Both of these abstract types themselves are a subtype of the MarkdownNode.

Additional methods

  • The Base.convert(::Type{Markdown2.MD}, md::Markdown.MD) method can be used to convert the Julia Markdown standard libraries ASTs into Markdown2 ASTs.
  • The walk function can be used for walking over a Markdown2.MD tree.
struct MD

The root node of a Markdown document. Its children are a list of top-level block-type nodes. Note that MD is not a subtype of MarkdownNode.

convert(::Type{MD}, md::Markdown.MD) -> Markdown2.MD

Converts a Markdown standard library AST into a Markdown2 AST.