jxxcarlson / elm-markdown / Markdown.Render

For simple applications, the function toHtml will be enough. The other functions are mostly for building apps, e.g., editors, in which the source text changes a lot. The best guide to using the code are the examples. See the folder examples and editors.

Types


type MarkdownOutput
    = Simple (Html MarkdownMsg)
    | Composite DocumentParts

the type of output


type MarkdownMsg
    = IDClicked String

Use Html MarkdownMsg so that user clicks on elements in the rendered text can be detected.


type alias DocumentParts =
{ title : Html MarkdownMsg
, toc : Html MarkdownMsg
, document : Html MarkdownMsg 
}

The parts of a composite document

Rendering

toHtml : Markdown.Option.MarkdownOption -> String -> Html MarkdownMsg

Render source test given an a Markdown flavor

toHtml_ : Markdown.Option.MarkdownOption -> String -> List (Html MarkdownMsg)

Like toHtml, but produces a List (Html MarkdownMsg) value.

withOptions : Markdown.Option.MarkdownOption -> Markdown.Option.OutputOption -> Markdown.Parse.Id -> Basics.Int -> String -> MarkdownOutput

Render content with Markdown and output options, given a selected Id and a version

Rendering from AST

fromAST : Markdown.Parse.Id -> Tree Markdown.Parse.MDBlockWithId -> Html MarkdownMsg

Render to Html from a parse tree

fromASTWithOptions : Markdown.Option.OutputOption -> Markdown.Parse.Id -> Tree Markdown.Parse.MDBlockWithId -> MarkdownOutput

Render from an AST

Getters

Get parts of a document from a MarkdownOutput value.

document : MarkdownOutput -> Html MarkdownMsg

document content

title : MarkdownOutput -> Html MarkdownMsg

toc : MarkdownOutput -> Html MarkdownMsg

Table of contents

Utility

numberOfMathElements : Tree Markdown.Parse.MDBlockWithId -> Basics.Int

Count the number of display math element blocks in the parse tree