DisplayAs.jl
DisplayAs.DisplayAsDisplayAs.CSVDisplayAs.EPSDisplayAs.GIFDisplayAs.HTMLDisplayAs.JPEGDisplayAs.JSONDisplayAs.LaTeXDisplayAs.MDDisplayAs.PDFDisplayAs.PNGDisplayAs.PSDisplayAs.Raw.CSVDisplayAs.Raw.EPSDisplayAs.Raw.GIFDisplayAs.Raw.HTMLDisplayAs.Raw.JPEGDisplayAs.Raw.JSONDisplayAs.Raw.LaTeXDisplayAs.Raw.MDDisplayAs.Raw.PDFDisplayAs.Raw.PNGDisplayAs.Raw.PSDisplayAs.Raw.SVGDisplayAs.Raw.ShowableDisplayAs.Raw.TSVDisplayAs.Raw.TextDisplayAs.SVGDisplayAs.ShowableDisplayAs.TSVDisplayAs.TextDisplayAs.setcontextDisplayAs.unlimitedDisplayAs.withcontextDisplayAs.@mime_strDisplayAs.Raw.@mime_str
DisplayAs.DisplayAs — ModuleDisplayAs
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)
trueIt 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)
falseDisplayAs.CSV — TypeDisplayAs.CSV(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type text/csv. That is to say, display(DisplayAs.CSV(x)) is equivalent to display("text/csv", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.EPS — TypeDisplayAs.EPS(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type application/eps. That is to say, display(DisplayAs.EPS(x)) is equivalent to display("application/eps", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.GIF — TypeDisplayAs.GIF(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type image/gif. That is to say, display(DisplayAs.GIF(x)) is equivalent to display("image/gif", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.HTML — TypeDisplayAs.HTML(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type text/html. That is to say, display(DisplayAs.HTML(x)) is equivalent to display("text/html", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.JPEG — TypeDisplayAs.JPEG(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type image/jpeg. That is to say, display(DisplayAs.JPEG(x)) is equivalent to display("image/jpeg", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.JSON — TypeDisplayAs.JSON(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type application/json. That is to say, display(DisplayAs.JSON(x)) is equivalent to display("application/json", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.LaTeX — TypeDisplayAs.LaTeX(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type text/latex. That is to say, display(DisplayAs.LaTeX(x)) is equivalent to display("text/latex", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.MD — TypeDisplayAs.MD(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type text/markdown. That is to say, display(DisplayAs.MD(x)) is equivalent to display("text/markdown", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.PDF — TypeDisplayAs.PDF(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type application/pdf. That is to say, display(DisplayAs.PDF(x)) is equivalent to display("application/pdf", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.PNG — TypeDisplayAs.PNG(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type image/png. That is to say, display(DisplayAs.PNG(x)) is equivalent to display("image/png", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.PS — TypeDisplayAs.PS(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type application/postscript. That is to say, display(DisplayAs.PS(x)) is equivalent to display("application/postscript", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.SVG — TypeDisplayAs.SVG(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type image/svg+xml. That is to say, display(DisplayAs.SVG(x)) is equivalent to display("image/svg+xml", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.Showable — TypeShowable{mime <: MIME}Examples
julia> using DisplayAs
julia> DisplayAs.Showable{MIME"text/html"} === DisplayAs.HTML
true
julia> using Markdown
julia> md = Markdown.parse("hello");
julia> showable("text/html", md)
true
julia> showable("text/markdown", md)
true
julia> showable("text/html", DisplayAs.HTML(md))
true
julia> showable("text/markdown", DisplayAs.HTML(md))
false
julia> showable("text/html", DisplayAs.MD(md))
false
julia> showable("text/markdown", DisplayAs.MD(md))
trueDisplayAs.TSV — TypeDisplayAs.TSV(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type text/tab-separated-values. That is to say, display(DisplayAs.TSV(x)) is equivalent to display("text/tab-separated-values", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.Text — TypeDisplayAs.Text(x; options...)Wrap an object x in another object that prefers to be displayed as MIME type text/plain. That is to say, display(DisplayAs.Text(x)) is equivalent to display("text/plain", x) (except some corner cases).
If x is already of type Showable the result will allow displaying in both the original and the new MIME type.
The named arguments options are passed to the 3-argument show method of x.
See also Showable.
DisplayAs.setcontext — MethodDisplayAs.setcontext(obj, kvs::Pair...)Bundle arguments for IOContext with the object x.
Examples
julia> import DisplayAs
julia> data = rand(2, 2)
2×2 Array{Float64,2}:
0.786992 0.576265
0.321868 0.791263
julia> DisplayAs.setcontext(data, :compact => false)
2×2 Array{Float64,2}:
0.7869920812675713 0.5762653628115182
0.32186846202784314 0.791263230914472See also DisplayAs.withcontext.
DisplayAs.unlimited — MethodDisplayAs.unlimited(x)Unlimit display size of object x. Useful for, e.g., printing all contents of dataframes in a Jupyter notebook.
Examples
julia> using DisplayAs, VegaDatasets
julia> data = dataset("cars");
julia> data |> DisplayAs.unlimitedDisplayAs.withcontext — MethodDisplayAs.withcontext(kvs::Pair...)Convenience method equivalent to obj -> DisplayAs.setcontext(obj, kvs...) useful for "piping".
Examples
julia> import DisplayAs
julia> rand(2, 2) |> DisplayAs.withcontext(:compact => false)
2×2 Array{Float64,2}:
0.7869920812675713 0.5762653628115182
0.32186846202784314 0.791263230914472See also DisplayAs.setcontext.
DisplayAs.@mime_str — Macromime"..." :: Type{<:Showable}Examples
julia> using DisplayAs
julia> DisplayAs.mime"text/plain" === DisplayAs.Text
trueDisplayAs.Raw.CSV — TypeDisplayAs.Raw.CSV(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type text/csv.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.EPS — TypeDisplayAs.Raw.EPS(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type application/eps.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.GIF — TypeDisplayAs.Raw.GIF(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type image/gif.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.HTML — TypeDisplayAs.Raw.HTML(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type text/html.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.JPEG — TypeDisplayAs.Raw.JPEG(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type image/jpeg.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.JSON — TypeDisplayAs.Raw.JSON(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type application/json.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.LaTeX — TypeDisplayAs.Raw.LaTeX(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type text/latex.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.MD — TypeDisplayAs.Raw.MD(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type text/markdown.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.PDF — TypeDisplayAs.Raw.PDF(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type application/pdf.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.PNG — TypeDisplayAs.Raw.PNG(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type image/png.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.PS — TypeDisplayAs.Raw.PS(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type application/postscript.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.SVG — TypeDisplayAs.Raw.SVG(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type image/svg+xml.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.Showable — TypeDisplayAs.Raw.Showable{mime}(bytes::Vector{UInt8})An object that prints bytes for rendering show on mime; i.e., this object defines show(io::IO, ::mime, DisplayAs.Raw.Showable{mime}(bytes)) as write(io, bytes).
DisplayAs.Raw.TSV — TypeDisplayAs.Raw.TSV(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type text/tab-separated-values.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.Text — TypeDisplayAs.Raw.Text(bytes::Vector{UInt8})Wrap a pre-rendered bytes into an object that defines show for MIME type text/plain.
See also DisplayAs.Raw.Showable.
DisplayAs.Raw.@mime_str — MacroDisplayAs.Raw.mime"..." :: Type{<:DisplayAs.Raw.Showable}Examples
julia> using DisplayAs
julia> DisplayAs.Raw.mime"text/plain" === DisplayAs.Raw.Text
true