Markdown2

Markdown2

Documentation for the private Markdown2 module.

Index

Docstrings

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.

Note

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.
source
struct List <: MarkdownBlockNode

If .orderedstart is nothing then the list is unordered. Otherwise is specifies the first number in the list.

source
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.

source
abstract type MarkdownBlockNode <: MarkdownNode

Supertype for all block-level Markdown nodes.

source
abstract type MarkdownInlineNode <: MarkdownNode

Supertype for all inline Markdown nodes.

source
abstract type MarkdownNode

Supertype for all Markdown nodes.

source
struct Paragraph <: MarkdownBlockNode

Represents a paragraph block-type node. Its children are inline nodes.

source
struct ThematicBreak <: MarkdownBlockNode

A block node represeting a thematic break (a <hr> tag).

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

Converts a Markdown standard library AST into a Markdown2 AST.

source
walk(f, element)

Calls f(element) on element and any of its child elements. The elements are assumed to be Markdown2 elements.

source