pablohirafuji/elm-markdown/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Markdown.Config

Configure markdown to fit your needs.

Options

type alias Options =
{ softAsHardLineBreak : Bool
, rawHtml : HtmlOption
}

Some parser options so you can tweak things for your particular case.

  • softAsHardLineBreak: If set to True, will render \n as <br />.
  • rawHtml: This determine what to do with raw html elements.
= ParseUnsafe
| Sanitize SanitizeOptions
| DontParse

Choose what to do with raw html elements.

  • ParseUnsafe: Will parse any valid html tag and attribute. This includes malicious code like <script>alert("XSS ALERT!!");</script>.
  • Sanitize SanitizeOptions: Will parse only specific html elements and attributes.
  • DontParse: Do not parse any html tag. It will include the raw text in the output.
type alias SanitizeOptions =
{ allowedHtmlElements : List String
, allowedHtmlAttributes : List String
}

Choose what html elements and attributes are allowed to parse.

  • allowedHtmlElements: List of allowed html elements.
  • allowedHtmlAttributes: List of allowed attributes.
defaultOptions : Options

The Options used in Markdown.toHtml.

{ softAsHardLineBreak = False
, rawHtml = Sanitize defaultSanitizeOptions
}
defaultSanitizeOptions : SanitizeOptions

The SanitizeOptions used by defaultOptions.

{ allowedHtmlElements =
    [ "address", "article", "aside", "b", "blockquote"
    , "body","br", "caption", "center", "cite", "code", "col"
    , "colgroup", "dd", "details", "div", "dl", "dt", "figcaption"
    , "figure", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "hr"
    , "i", "legend", "li", "link", "main", "menu", "menuitem"
    , "nav", "ol", "optgroup", "option", "p", "pre", "section"
    , "strike", "summary", "small", "table", "tbody", "td"
    , "tfoot", "th", "thead", "title", "tr", "ul" ]
, allowedHtmlAttributes =
    [ "name", "class" ]
}

Elements

type alias Elements =
{ heading : Int -> List (Html Never) -> Html Never
, thematicBreak : Html Never
, paragraph : Bool -> List (Html Never) -> List (Html Never)
, blockQuote : List (Html Never) -> Html Never
, code : CodeBlock -> Html Never
, list : ListElement -> List (Html Never) -> Html Never
, emphasis : List (Html Never) -> Html Never
, strongEmphasis : List (Html Never) -> Html Never
, codeSpan : String -> Html Never
, link : Link -> List (Html Never) -> Html Never
, image : Image -> Html Never
, hardLineBreak : Html Never
}

A record to be used with customHtml of how each element is rendered to html.

defaultElements : Elements

The elements used in toHtml and withOptions.

type alias CodeBlock =
{ language : Maybe String
, code : String
}

Code block element model. If you want to use a highlight package, you have access to the code here.

= Unordered
| Ordered Int

List element model. The Int in Ordered Int is the first number used to start an ordered list.

type alias Image =
{ alt : String
, src : String
, title : Maybe String
}

Image element model.