Inline rendering and helpers.
Transform an Inline into Html using the default html elements.
toHtml (Text "Inner text") == Html.text "Inner text"
toHtml HardLineBreak == Html.br [] []
toHtml (CodeInline code) == Html.code [] [ Html.text code ]Transform an Inline into a Html, optionally using custom html elements to render inner inlines.
upperText : Inline i -> Html msg
upperText inline =
case inline of
Text str ->
Html.text (String.toUpper str)
_ ->
defaultHtml (Just upperText) inline
defaultHtml (Just upperText) (Text "hello") == text "hello"
defaultHtml (Just upperText) (Emphasis 2 [ Text "hello" ]) == strong [] [ text "HELLO" ]
upperText (Text "hello") == text "HELLO"Note: If the first argument is Nothing,
the default html elements will be used to render
the inner inlines.
Extract the text from a list of inlines.
inlines : List (Inline i)
inlines =
[ Text "Heading with "
, Emphasis 1
[ Text "emphasis" ]
]
extractText inlines == "Heading with emphasis"
-- Original string: "Heading with *emphasis*"
The inline type.