Apply a Renderer to turn parsed Markdown.Blocks into your rendered markdown view.
This renders Html in an attempt to be as close as possible to
the HTML output in https://github.github.com/gfm/.
Render Tuples of Blocks with arbitrary metadata. See examples/src/Slugs.elm for a full example that shows how to
add metadata to blocks.
import Markdown.Parser
import Markdown.Renderer exposing (defaultHtmlRenderer)
markdownInput
|> Markdown.Parser.parse
|> Result.map gatherHeadingOccurrences
|> Result.mapError deadEndsToString
|> Result.andThen
(\ast ->
Markdown.Renderer.renderWithMeta
(\maybeSlug ->
{ defaultHtmlRenderer
| heading =
\{ level, children } ->
Html.h1
[ Attr.id (maybeSlug |> Maybe.withDefault "")
]
children
}
)
ast
)
A record with functions that define how to render all possible markdown blocks. These renderers are composed together to give you the final rendered output.
You could render to any type you want. Here are some useful things you might render to:
Html(using thedefaultHtmlRendererprovided by this module)HtmlElements frommdgriffith/elm-uirtfeldman/elm-cssortesk9/accessible-htmlStrings with ANSI color codes for setting rich colors in terminal (CLI) output