dillonkearns/elm-markdown/1.0.0

NOTE: the latest version is 7.0.1

Markdown.Block

type Block
= Heading Int (List Inline)
| Body (List Inline)
| Html String (List Attribute) (List Block)
| ListBlock (List (List Inline))
| CodeBlock CodeBlock
| ThematicBreak

This is the AST (abstract syntax tree) that represents your parsed markdown.

In the simplest case, you can pass this directly to a renderer:

module Main exposing (main)


import Markdown.Block exposing (Block)
import Markdown.Parser


markdown : String
markdown =
    "# This is a title!\n\nThis is the body."


astResult : Result (List (Advanced.DeadEnd String Parser.Problem)) (List Block)
astResult =
    markdown
        |> Markdown.Parser.parse


main : Html msg
main =
    case astResult of
        Ok ast ->
            Markdown.Parser.renderDefaultHtml ast


        Err errors ->
            Html.text "Encountered parsing errors."

Inlines

type alias Inline =
{ style : InlineStyle
, string : String
}

Represents styled inline text. For example, a header can include links, emphasis, etc.

type alias InlineStyle =
{ isCode : Bool
, isBold : Bool
, isItalic : Bool
, link :
Maybe
{ title : Maybe String
, destination : InlineLink
}
}

The style of a section of an inline block.