Markdown

:= [
    Heading({ level : Level, content : List(Inline) }),
    Paragraph(List(Inline)),
    Blockquote(List(Markdown)),
    ListBlock({ kind : ListKind, loose : Bool, items : List({ task : TaskState, blocks : List(Markdown) }) }),
    Code({ info : Str, pre : Str }),
    ThematicBreak,
    Table({ header : List(List(Inline)), align : List(Alignment), rows : List(List(List(Inline))) }),
    HtmlBlock(Str),
    Frontmatter({ raw : Str }),
    TODO(Str),
]

Markdown syntax tree and parsers for documents and inline content.

The block parser preserves frontmatter, headings, paragraphs, blockquotes, lists, code blocks, thematic breaks, tables, and raw HTML. Inline parsing supports emphasis, links, images, code, hard breaks, and raw HTML.

to_inspect : Markdown -> Str

Render a Markdown block in Roc source-like notation for inspection.

is_eq : _

Compare two Markdown syntax trees structurally.

to_debug_str : Markdown -> Str

Render a Markdown block as a stable debug string.

all : Parser(Utf8, List(Markdown))

Parse a complete Markdown document into block nodes.

inlines : Parser(Utf8, List(Inline))

Parse inline Markdown content.

heading : Parser(Utf8, Markdown)

Parse an ATX or Setext heading.

link : Parser(Utf8, Inline)

Parse an inline link with a destination in parentheses.

image : Parser(Utf8, Inline)

Parse an inline image with a destination in parentheses.

code : Parser(Utf8, Markdown)

Parse a fenced code block delimited by triple backticks.

Level

:= [One, Two, Three, Four, Five, Six]

Heading levels from one through six.

to_inspect : Level -> Str

Render a heading level for inspection.

to_str : Level -> Str

Convert a heading level to its decimal representation.

is_eq : _

Compare two heading levels.

ListKind

:= [
    Unordered,
    Ordered({ start : U64 }),
]

The marker and starting number of a Markdown list.

to_inspect : ListKind -> Str

Render a list kind for inspection.

to_str : ListKind -> Str

Convert a list kind to a compact string.

is_eq : _

Compare two list kinds structurally.

TaskState

:= [
    NoTask,
    Unchecked,
    Checked,
]

Whether a list item is a task and, if so, whether it is checked.

to_inspect : TaskState -> Str

Render a task state for inspection.

to_str : TaskState -> Str

Convert a task state to a compact string.

is_eq : _

Compare two task states.

Alignment

:= [
    Default,
    Left,
    Center,
    Right,
]

Column alignment declared by a Markdown table delimiter row.

to_inspect : Alignment -> Str

Render a table alignment for inspection.

to_str : Alignment -> Str

Convert a table alignment to a compact string.

is_eq : _

Compare two table alignments.

LinkTarget : {
    href : Str,
    title : [Some(Str), None],
}

Destination and optional title of a link or image.

Inline

:= [
    Text(Str),
    Strong(List(Inline)),
    Emphasis(List(Inline)),
    Strikethrough(List(Inline)),
    InlineCode(Str),
    Link({ label : List(Inline), target : LinkTarget }),
    Image({ alt : List(Inline), target : LinkTarget }),
    HardBreak,
    HtmlInline(Str),
]

Inline Markdown syntax nodes.

to_inspect : Inline -> Str

Render an inline node in Roc source-like notation for inspection.

is_eq : _

Compare two inline syntax trees structurally.