DisplayAs.jl provides functions to show objects in a chosen MIME type.
julia> using DisplayAs
using Markdown
julia> md_as_html = Markdown.parse("hello") |> DisplayAs.HTML;
julia> showable("text/html", md_as_html)
true
julia> showable("text/markdown", md_as_html)
false
julia> md_as_md = Markdown.parse("hello") |> DisplayAs.MD;
julia> showable("text/html", md_as_md)
false
julia> showable("text/markdown", md_as_md)
true
It is also possible to use nesting in order to allow the object to be displayed as multiple MIME types:
julia> md_as_html_or_text = Markdown.parse("hello") |> DisplayAs.HTML |> DisplayAs.Text;
julia> showable("text/html", md_as_html_or_text)
true
julia> showable("text/plain", md_as_html_or_text)
true
julia> showable("text/markdown", md_as_html_or_text)
false