jxxcarlson/elm-markdown/2.4.0

NOTE: the latest version is 10.1.0

Parse

The purpose of this module is to parse a Document, that is, a string, into an abstract syntax tree (AST) which can then be further transformed or passed on to a rendering function. The AST is a rose tree of MBlock -- short for "Markdown Blocks."

toMDBlockTree : Option -> Document -> Tree MDBlock

Parse a string using a Markdown flavor option, returning the AST. Example:

parseToMDBlockTree Extended "This **is** a test."
--> Tree (MDBlock (MarkdownBlock Root) 0 (M (Paragraph [Line [OrdinaryText "DOCUMENT"]]))) [Tree (MDBlock (MarkdownBlock Plain) 1 (M (Paragraph [Line [OrdinaryText ("This "),BoldText ("is "),OrdinaryText ("a test.")],Line []]))) []]
type MDBlock
= MDBlock BlockType Level BlockContent

An MBlock differs from the a Block in that the Content, which is a type alias for String, has been parsed into a BlockContent value by applying

MDInline.parse : Option -> String -> MDInline
| T String

The type of a parsed Block

stringOfMDBlockTree : Tree MDBlock -> String

A string representation of an MDBlockTree. Useful for verifying the validity of the AST.