text')
exp_md <- list('text/html' = list(isolated = TRUE))
display_html('text')
expect_equal(get_last_data(), list(exp, exp_md))
})
test_that('display_markdown works', {
exp <- list('text/markdown' = 'data')
display_markdown('data')
expect_equal(get_last_data(), list(exp, NULL))
})
test_that('display_latex works', {
exp <- list('text/latex' = 'data')
display_latex('data')
expect_equal(get_last_data(), list(exp, NULL))
})
})
IRdisplay/tests/testthat/test_display_functions.r 0000644 0001762 0000144 00000005427 12737425622 022155 0 ustar ligges users context('general display functions')
library(repr)
last_data <- NULL
test_display_func <- function(data, metadata = NULL) {
last_data <<- list(data, metadata)
}
get_last_data <- function() {
ret <- last_data
last_data <<- NULL
ret
}
test_that('display without a jupyter.base_display_func raises a warning', {
expect_warning(display(NULL), regexp = 'can only be used from')
})
withr::with_options(list(jupyter.base_display_func = test_display_func), {
test_that('publish_mimebundle works', {
publish_mimebundle(NULL)
expect_equal(get_last_data(), list(NULL, NULL))
publish_mimebundle(1, 1)
expect_equal(get_last_data(), list(1, 1))
})
test_that('display works', {
# NULL only displays in text/plain
exp <- list('text/plain' = repr_text(NULL))
display(NULL)
expect_equal(get_last_data(), list(exp, NULL))
})
test_that('display only creates the jupyter.display_mimetypes', {
exp <- list(
'text/plain' = repr_text(1),
'text/html' = repr_html(1))
withr::with_options(
list(jupyter.display_mimetypes = c('text/plain', 'text/html')),
display(1))
expect_equal(get_last_data(), list(exp, NULL))
})
test_that('display attaches metadata', {
exp <- list(
'text/plain' = 'x',
'text/html' = 'x')
exp_md <- list('text/html' = list(isolated = TRUE))
withr::with_options(list(jupyter.display_mimetypes = c('text/plain', 'text/html')), {
.GlobalEnv$repr_text.html_literal <- .GlobalEnv$repr_html.html_literal <- function(obj, ...) unclass(obj)
display(structure('x', class = 'html_literal'))
})
expect_equal(get_last_data(), list(exp, exp_md))
})
test_that('display handles raw data', {
dta <- as.raw(1:10)
exp <- list(
'text/plain' = 'PNG data: 01 02 03 04 05...',
'image/png' = dta)
withr::with_options(list(jupyter.display_mimetypes = c('text/plain', 'image/png')), {
.GlobalEnv$repr_text.raw_png <- function(obj, ...) sprintf('PNG data: %s...', paste(obj[1:5], collapse = ' '))
.GlobalEnv$repr_png.raw_png <- function(obj, ...) unclass(obj)
display(structure(dta, class = 'raw_png'))
})
expect_equal(get_last_data(), list(exp, NULL))
})
test_that('display needs > 0 display_mimetypes', {
withr::with_options(
list(jupyter.display_mimetypes = character(0L)),
expect_error(display(1), 'may not be NULL or of length 0'))
withr::with_options(
list(jupyter.display_mimetypes = NULL),
expect_error(display(1), 'may not be NULL or of length 0'))
})
test_that('display_raw works', {
exp <- list('text/plain' = 'data')
display_raw('text/plain', FALSE, 'data', NULL)
expect_equal(get_last_data(), list(exp, NULL))
})
})
IRdisplay/tests/testthat/test-options.r 0000644 0001762 0000144 00000000215 13377730160 020014 0 ustar ligges users context('default options')
test_that('default options are set', {
expect_equal(length(getOption('jupyter.display_mimetypes')), 15L)
})
IRdisplay/tests/testthat/test_display_functions_images.r 0000644 0001762 0000144 00000002434 12737425622 023475 0 ustar ligges users context('image display functions')
last_data <- NULL
test_display_func <- function(data, metadata = NULL) {
last_data <<- list(data, metadata)
}
get_last_data <- function() {
ret <- last_data
last_data <<- NULL
ret
}
withr::with_options(list(jupyter.base_display_func = test_display_func), {
test_that('display_png works', {
dta <- as.raw(1:3)
exp <- list('image/png' = dta)
exp_md <- list(width = 1, height = 2)
display_png(dta)
expect_equal(get_last_data(), list(exp, NULL))
display_png(dta, width = 1, height = 2)
expect_equal(get_last_data(), list(exp, exp_md))
})
test_that('display_jpeg works', {
dta <- as.raw(1:3)
exp <- list('image/jpeg' = dta)
exp_md <- list(width = 1, height = 2)
display_jpeg(dta)
expect_equal(get_last_data(), list(exp, NULL))
display_jpeg(dta, width = 1, height = 2)
expect_equal(get_last_data(), list(exp, exp_md))
})
test_that('display_pdf works', {
dta <- as.raw(1:3)
exp <- list('application/pdf' = dta)
display_pdf(dta)
expect_equal(get_last_data(), list(exp, NULL))
})
test_that('display_svg works', {
exp <- list('image/svg+xml' = '')
display_svg('')
expect_equal(get_last_data(), list(exp, NULL))
})
})
IRdisplay/NAMESPACE 0000644 0001762 0000144 00000000615 13377731275 013412 0 ustar ligges users # Generated by roxygen2: do not edit by hand
export(display)
export(display_html)
export(display_javascript)
export(display_jpeg)
export(display_json)
export(display_latex)
export(display_markdown)
export(display_pdf)
export(display_png)
export(display_svg)
export(irdisplay_option_defaults)
export(prepare_mimebundle)
export(publish_mimebundle)
importFrom(methods,is)
importFrom(repr,mime2repr)
IRdisplay/R/ 0000755 0001762 0000144 00000000000 13377727742 012376 5 ustar ligges users IRdisplay/R/display_images.r 0000644 0001762 0000144 00000003043 13277264546 015550 0 ustar ligges users #' Display a specific image output
#'
#' Either \code{data} or \code{file} must be passed.
#'
#' @param data The data as a \code{\link[base]{raw}} vector (\code{\link[base]{character}} vector for \code{display_svg})
#' @param file The path to a file or a \code{\link[base]{connection}} containing the content
#' @param width The width to display the image
#' @param height The height to display the image
#'
#' @seealso \code{\link{display_}}
#'
#' @examples \dontrun{## (Run inside of an IRkernel)
#' display_png(file = 'image.png')
#' display_svg('
#'
#' ')
#' display_jpeg(file = url('https://dummyimage.com/600x400.jpg', 'wb'), width = 100)}
#'
#' @name display_
NULL
#' @name display_
#' @export
display_png <- function(data = NULL, file = NULL, width = NULL, height = NULL)
display_raw('image/png', TRUE, data, file, img_metadata(width, height))
#' @name display_
#' @export
display_jpeg <- function(data = NULL, file = NULL, width = NULL, height = NULL)
display_raw('image/jpeg', TRUE, data, file, img_metadata(width, height))
#' @name display_
#' @export
display_pdf <- function(data = NULL, file = NULL, width = NULL, height = NULL)
display_raw('application/pdf', TRUE, data, file, img_metadata(width, height))
#' @name display_
#' @export
display_svg <- function(data = NULL, file = NULL, width = NULL, height = NULL)
display_raw('image/svg+xml', FALSE, data, file, img_metadata(width, height))
IRdisplay/R/display_textual.r 0000644 0001762 0000144 00000002400 12747650620 015756 0 ustar ligges users #' Display a specific textual output
#'
#' Either \code{data} or \code{file} must be passed.
#'
#' @param data The code or markup content as a \code{\link[base]{character}} vector
#' @param file The path to a file or a \code{\link[base]{connection}} containing the content
#'
#' @seealso \code{\link{display_}}
#'
#' @examples \dontrun{## (Run inside of an IRkernel)
#' display_text('Just text')
#' display_markdown('[MD](http://commonmark.org) *formatted*')
#' display_javascript('execute(this)')}
#'
#' @name display_
NULL
#' @name display_
#' @export
display_json <- function(data = NULL, file = NULL) display_raw('application/json', FALSE, data, file)
#' @name display_
#' @export
display_javascript <- function(data = NULL, file = NULL) display_raw('application/javascript', FALSE, data, file)
#' @name display_
#' @export
display_html <- function(data = NULL, file = NULL) display_raw('text/html', FALSE, data, file, isolate_full_html(list('text/html' = data)))
#' @name display_
#' @export
display_markdown <- function(data = NULL, file = NULL) display_raw('text/markdown', FALSE, data, file)
#' @name display_
#' @export
display_latex <- function(data = NULL, file = NULL) display_raw('text/latex', FALSE, data, file)
IRdisplay/R/utils.r 0000644 0001762 0000144 00000003103 13352110075 013670 0 ustar ligges users # maps a function and return a named list with the NULL results removed
filter_map <- function(x, f, simplify = FALSE)
Filter(Negate(is.null), sapply(x, f, simplify = simplify))
# create metadata bundle for images
img_metadata <- function(width, height) {
if (is.null(width) && is.null(height))
return(NULL)
metadata <- list()
if (!is.null(width)) metadata$width <- width
if (!is.null(height)) metadata$height <- height
metadata
}
# add an "isolate" flag to -containing data, or the unchanged metadata
isolate_full_html <- function(data, metadata = NULL) {
if (!('text/html' %in% names(data)) || !isTRUE(grepl('', data[['text/html']], ignore.case = TRUE)))
return(metadata)
if (is.null(metadata)) metadata <- list()
if (is.null(metadata[['text/html']])) metadata[['text/html']] <- list()
metadata[['text/html']]$isolated <- TRUE
metadata
}
#' @importFrom methods is
read_all <- function(file, isbinary) {
read <- if (isbinary)
function(s) readBin(file, 'raw', s)
else
function(s) readChar(file, s)
size <- tryCatch(file.info(file)$size, error = function(e) NULL)
if (!is.null(size)) {
read(size)
} else {
if (is.character(file)) file <- base::file(file, 'rb')
stopifnot(is(file, 'connection'))
if (!isOpen(file)) open(file)
rv <- if (isbinary) raw() else character()
chunk <- read(1024)
while (length(chunk) > 0) {
rv <- c(rv, chunk)
chunk <- read(1024)
}
rv
}
}
IRdisplay/R/display.r 0000644 0001762 0000144 00000007744 13377727742 014242 0 ustar ligges users #' Display data by mimetype, with optional alternative representations.
#'
#' Calls the function stored as option value of \code{jupyter.base_display_func}. (see: \link{IRdisplay-options})
#'
#' @param data A named list mapping mimetypes to content (\code{\link[base]{character}} or \code{\link[base]{raw} vectors})
#' @param metadata A named list mapping mimetypes to named lists of metadata, e.g. \code{list('image/png' = list(width = 5))}
#'
#' @seealso \code{\link{prepare_mimebundle}}
#'
#' @examples \dontrun{## (Run inside of an IRkernel)
#' publish_mimebundle(list('text/html' = '
Hi!
'))
#' publish_mimebundle(
#' list('image/svg+xml' = ''),
#' list('image/svg+xml' = list(width = 100, height = 100)))}
#'
#' @export
publish_mimebundle <- function(data, metadata = NULL) {
getOption('jupyter.base_display_func')(data, metadata)
}
#' Create and use multiple available reprs
#'
#' Both functions create a mimebundle for multiple reprs.
#' \code{display} proceeds to publish it using \code{\link{publish_mimebundle}}.
#' \code{prepare_mimebundle} returns it (see \emph{Value} for details)
#'
#' @param obj The object to create representations for
#' @param mimetypes Mimetypes to create reprs for. The defaults are defined by the option \code{jupyter.display_mimetypes}. (see: \link{IRdisplay-options})
#' @param metadata,... Metadata to attach to the result (can be expanded by additional metadata)
#' @param error_handler Function used when errors in individual reprs occur
#'
#' @return \code{prepare_mimebundle} returns a list with items corresponding to the parameters of \code{\link{publish_mimebundle}} (\code{data} and \code{metadata})
#'
#' @seealso \code{\link{publish_mimebundle}}
#'
#' @examples
#' bundle <- prepare_mimebundle(diag(3))
#'
#' \dontrun{## (Run inside of an IRkernel)
#' display(help(display))}
#'
#' @name display
#' @export
display <- function(
obj,
...,
mimetypes = getOption('jupyter.display_mimetypes'),
error_handler = stop
) {
metadata <- list(...)
if (length(metadata) == 0L) metadata <- NULL
bundle <- prepare_mimebundle(obj, mimetypes, metadata, error_handler)
publish_mimebundle(bundle$data, bundle$metadata)
}
#' @importFrom repr mime2repr
#' @name display
#' @export
prepare_mimebundle <- function(
obj,
mimetypes = getOption('jupyter.display_mimetypes'),
metadata = NULL,
error_handler = stop
) {
if (length(mimetypes) == 0L)
stop('option jupyter.display_mimetypes may not be NULL or of length 0')
outer_handler <- if (identical(error_handler, stop)) stop else function(e) {}
# Use withCallingHandlers as that shows the inner stacktrace:
# https://stackoverflow.com/questions/15282471/get-stack-trace-on-trycatched-error-in-r
# the tryCatch is still needed to prevent the error from showing
# up outside further up the stack :-/
data <- filter_map(mimetypes, function(mime) {
tryCatch(withCallingHandlers({
if (! mime %in% names(repr::mime2repr)) stop('No repr_* for mimetype ', mime, ' in repr::mime2repr')
rpr <- repr::mime2repr[[mime]](obj)
if (is.null(rpr)) return(NULL)
prepare_content(is.raw(rpr), rpr)
}, error = error_handler),
error = outer_handler)
})
list(data = data, metadata = isolate_full_html(data, metadata))
}
prepare_content <- function(isbinary, data = NULL, file = NULL) {
if (is.null(file) == is.null(data))
stop('Either need to specify data or file, but not both')
if (is.null(file)) {
if (isbinary) {
if (!is.raw(data)) stop('Data needs to be a raw vector')
}
data
} else {
read_all(file, isbinary)
}
}
display_raw <- function(mimetype, isbinary, data, file, metadata = NULL) {
content <- prepare_content(isbinary, data, file)
data <- list()
data[[mimetype]] <- content
publish_mimebundle(data, metadata)
}
IRdisplay/R/options.r 0000644 0001762 0000144 00000003205 13377724763 014254 0 ustar ligges users #' IRdisplay options
#'
#' Some \link{options} to control the formats \code{\link{display}} and \code{\link{prepare_mimebundle}} emit,
#' and the function they use to display them.
#'
#' @section Options:
#'
#' \describe{
#'
#' \item{\code{jupyter.display_mimetypes}}{
#' The default is all MIME types supported by Jupyter.
#' }
#' \item{\code{jupyter.base_display_func}}{
#' Function used by \code{\link{display}} and all \code{\link{display_}} / \code{\link{display_}} functions.
#' Has the signature \code{function(data, metadata = NULL)}.
#' Per default emits a \code{\link{warning}}, and is set when running an \code{IRkernel}.
#' }
#'
#' }
#'
#' @name IRdisplay-options
#' @export
irdisplay_option_defaults <- list(
jupyter.display_mimetypes = c(
'text/plain',
'text/html',
'text/markdown',
'text/latex',
'application/json',
'application/javascript',
'application/geo+json',
'application/vdom.v1+json',
'application/vnd.plotly.v1+json',
'application/vnd.vegalite.v2+json',
'application/vnd.vega.v4+json',
'application/pdf',
'image/png',
'image/jpeg',
'image/svg+xml'),
jupyter.base_display_func = function(data, metadata = NULL) {
warning('IRdisplay can only be used from the IPython R kernel and R magic.')
})
.onLoad <- function(libname = NULL, pkgname = NULL) {
for (option in names(irdisplay_option_defaults)) {
if (is.null(getOption(option))) {
do.call(options, irdisplay_option_defaults[option]) # single []: preserve name
}
}
}
IRdisplay/README.md 0000644 0001762 0000144 00000003434 13377727742 013460 0 ustar ligges users IRdisplay [![b-Travis]][Travis] [![b-CRAN]][CRAN]
=========
[b-Travis]: https://travis-ci.org/IRkernel/IRdisplay.svg?branch=master "Build status"
[Travis]: https://travis-ci.org/IRkernel/IRdisplay
[b-CRAN]: https://www.r-pkg.org/badges/version/IRdisplay "Comprehensive R Archive Network"
[CRAN]: https://cran.r-project.org/package=IRdisplay
IRdisplay is a front-end package for Jupyter.
It’s automatically integrated into [IRkernel][] when you open a Jupyter notebook using that kernel.
The primary, high level functions are:
```r
display(obj, ..., mimetypes=, error_handler=stop)
display_png(data = NULL, file = NULL, width = NULL, height = NULL)
# display_jpeg(…); display_pdf(…); display_svg(…)
display_html(data = NULL, file = NULL)
# display_javascript(…), display_json(…), display_markdown(…), display_latex(…)
```
Use `display` to display an object in all configured mime types (see **Configuration**),
and the `display_*` functions to display raw data you have in form of a file or a variable.
Manual use is possible via the `*_mimebundle` functions:
```r
prepare_mimebundle(obj, mimetypes=, metadata=NULL, error_handler=stop)
publish_mimebundle(data, metadata = NULL)
```
Where `prepare_mimebundle` uses `repr` to create a mimebundle containing representations of objects,
and `publish_mimebundle` sends such mimebundles to Jupyter.
[IRkernel]: https://irkernel.github.io/running/
Configuration
-------------
You can add your own mime types that should be displayed via:
```r
options(jupyter.display_mimetypes = union(getOption('jupyter.display_mimetypes'), ...))
```
If you want to create your own kernel reacting to `display` / `publish_mimebundle` calls, you can use:
```r
options(jupyter.base_display_func = function(data, metadata = NULL) ...)
```
IRdisplay/MD5 0000644 0001762 0000144 00000002215 13377754572 012506 0 ustar ligges users 90dcd4df1b0945b1b11584d0b18a257f *DESCRIPTION
3fd4786bf5351f2b5fa63d036ae8e5b2 *LICENSE
cff9eaa100b9446d081cf29c1931e994 *NAMESPACE
34d6544d7cd7889ee948e112ff1e3b06 *R/display.r
0d4f129a1b2a1667c0475edff934d844 *R/display_images.r
d401d364d5f881e9e82a5e9035aca434 *R/display_textual.r
4ee9aa59f6227853f5088d3350f6251d *R/options.r
a65a898d0b87a50b6dbcf53535358be9 *R/utils.r
325abb69812eb81bc580104fd733fb69 *README.md
3ae675702486c2db25d79987138a6550 *man/IRdisplay-options.Rd
0e37d9b38b2b3ddd51d12d09bf15cd06 *man/display.Rd
0e2ee4c9d802876a0107b28e43e4135d *man/display_-less-than-image-greater-than.Rd
b7bce1266af9836919d05548c44b0943 *man/display_-less-than-text-greater-than.Rd
7984f21effb42ea187e9b9cb9004a903 *man/publish_mimebundle.Rd
4fd1af4a33f903a0fbaba13bedd228e4 *tests/testthat.R
f678acbe698354e19e40e1f53919bd2f *tests/testthat/test-options.r
5364bff55fac94ed7a91ae0811c7efc3 *tests/testthat/test_base_display.r
5e5473056c2bed085d656c147211a059 *tests/testthat/test_display_functions.r
8a143f86d38a8cde552e2513a8ba89a1 *tests/testthat/test_display_functions_images.r
22fe2c09e5910d045528110fd03d8cd8 *tests/testthat/test_display_functions_textual.r
IRdisplay/DESCRIPTION 0000644 0001762 0000144 00000002072 13377754572 013705 0 ustar ligges users Package: IRdisplay
Title: 'Jupyter' Display Machinery
Description:
An interface to the rich display capabilities of 'Jupyter' front-ends (e.g. 'Jupyter Notebook') .
Designed to be used from a running 'IRkernel' session .
Version: 0.7.0
Authors@R: c(
person('Thomas', 'Kluyver', role = c('aut', 'cph'), email = 'thomas@kluyver.me.uk'),
person('Philipp', 'Angerer', role = c('aut', 'cph', 'cre'), email = 'phil.angerer@gmail.com', comment = c(ORCID = "0000-0002-0369-2888")),
person('Jan', 'Schulz', role = c('aut', 'cph'), email = 'jasc@gmx.net'))
Depends: R (>= 3.0.1)
Suggests: testthat, withr
Imports: methods, repr
License: MIT + file LICENSE
LazyData: true
Encoding: UTF-8
RoxygenNote: 6.1.1
NeedsCompilation: no
Packaged: 2018-11-29 09:34:55 UTC; angerer
Author: Thomas Kluyver [aut, cph],
Philipp Angerer [aut, cph, cre]
(),
Jan Schulz [aut, cph]
Maintainer: Philipp Angerer
Repository: CRAN
Date/Publication: 2018-11-29 12:20:10 UTC
IRdisplay/man/ 0000755 0001762 0000144 00000000000 13372304174 012731 5 ustar ligges users IRdisplay/man/publish_mimebundle.Rd 0000644 0001762 0000144 00000001731 13277264546 017105 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/display.r
\name{publish_mimebundle}
\alias{publish_mimebundle}
\title{Display data by mimetype, with optional alternative representations.}
\usage{
publish_mimebundle(data, metadata = NULL)
}
\arguments{
\item{data}{A named list mapping mimetypes to content (\code{\link[base]{character}} or \code{\link[base]{raw} vectors})}
\item{metadata}{A named list mapping mimetypes to named lists of metadata, e.g. \code{list('image/png' = list(width = 5))}}
}
\description{
Calls the function stored as option value of \code{jupyter.base_display_func}. (see: \link{IRdisplay-options})
}
\examples{
\dontrun{## (Run inside of an IRkernel)
publish_mimebundle(list('text/html' = '
Hi!
'))
publish_mimebundle(
list('image/svg+xml' = ''),
list('image/svg+xml' = list(width = 100, height = 100)))}
}
\seealso{
\code{\link{prepare_mimebundle}}
}
IRdisplay/man/display_-less-than-text-greater-than.Rd 0000644 0001762 0000144 00000001740 13277264546 022277 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/display_textual.r
\name{display_}
\alias{display_}
\alias{display_json}
\alias{display_javascript}
\alias{display_html}
\alias{display_markdown}
\alias{display_latex}
\title{Display a specific textual output}
\usage{
display_json(data = NULL, file = NULL)
display_javascript(data = NULL, file = NULL)
display_html(data = NULL, file = NULL)
display_markdown(data = NULL, file = NULL)
display_latex(data = NULL, file = NULL)
}
\arguments{
\item{data}{The code or markup content as a \code{\link[base]{character}} vector}
\item{file}{The path to a file or a \code{\link[base]{connection}} containing the content}
}
\description{
Either \code{data} or \code{file} must be passed.
}
\examples{
\dontrun{## (Run inside of an IRkernel)
display_text('Just text')
display_markdown('[MD](http://commonmark.org) *formatted*')
display_javascript('execute(this)')}
}
\seealso{
\code{\link{display_}}
}
IRdisplay/man/IRdisplay-options.Rd 0000644 0001762 0000144 00000001646 13277264546 016634 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/options.r
\docType{data}
\name{IRdisplay-options}
\alias{IRdisplay-options}
\alias{irdisplay_option_defaults}
\title{IRdisplay options}
\format{An object of class \code{list} of length 2.}
\usage{
irdisplay_option_defaults
}
\description{
Some \link{options} to control the formats \code{\link{display}} and \code{\link{prepare_mimebundle}} emit,
and the function they use to display them.
}
\section{Options}{
\describe{
\item{\code{jupyter.display_mimetypes}}{
The default is all MIME types supported by Jupyter.
}
\item{\code{jupyter.base_display_func}}{
Function used by \code{\link{display}} and all \code{\link{display_}} / \code{\link{display_}} functions.
Has the signature \code{function(data, metadata = NULL)}.
Per default emits a \code{\link{warning}}, and is set when running an \code{IRkernel}.
}
}
}
\keyword{datasets}
IRdisplay/man/display.Rd 0000644 0001762 0000144 00000002513 13372304744 014671 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/display.r
\name{display}
\alias{display}
\alias{prepare_mimebundle}
\title{Create and use multiple available reprs}
\usage{
display(obj, ..., mimetypes = getOption("jupyter.display_mimetypes"),
error_handler = stop)
prepare_mimebundle(obj,
mimetypes = getOption("jupyter.display_mimetypes"), metadata = NULL,
error_handler = stop)
}
\arguments{
\item{obj}{The object to create representations for}
\item{mimetypes}{Mimetypes to create reprs for. The defaults are defined by the option \code{jupyter.display_mimetypes}. (see: \link{IRdisplay-options})}
\item{error_handler}{Function used when errors in individual reprs occur}
\item{metadata, ...}{Metadata to attach to the result (can be expanded by additional metadata)}
}
\value{
\code{prepare_mimebundle} returns a list with items corresponding to the parameters of \code{\link{publish_mimebundle}} (\code{data} and \code{metadata})
}
\description{
Both functions create a mimebundle for multiple reprs.
\code{display} proceeds to publish it using \code{\link{publish_mimebundle}}.
\code{prepare_mimebundle} returns it (see \emph{Value} for details)
}
\examples{
bundle <- prepare_mimebundle(diag(3))
\dontrun{## (Run inside of an IRkernel)
display(help(display))}
}
\seealso{
\code{\link{publish_mimebundle}}
}
IRdisplay/man/display_-less-than-image-greater-than.Rd 0000644 0001762 0000144 00000002334 13277264546 022375 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/display_images.r
\name{display_}
\alias{display_}
\alias{display_png}
\alias{display_jpeg}
\alias{display_pdf}
\alias{display_svg}
\title{Display a specific image output}
\usage{
display_png(data = NULL, file = NULL, width = NULL, height = NULL)
display_jpeg(data = NULL, file = NULL, width = NULL, height = NULL)
display_pdf(data = NULL, file = NULL, width = NULL, height = NULL)
display_svg(data = NULL, file = NULL, width = NULL, height = NULL)
}
\arguments{
\item{data}{The data as a \code{\link[base]{raw}} vector (\code{\link[base]{character}} vector for \code{display_svg})}
\item{file}{The path to a file or a \code{\link[base]{connection}} containing the content}
\item{width}{The width to display the image}
\item{height}{The height to display the image}
}
\description{
Either \code{data} or \code{file} must be passed.
}
\examples{
\dontrun{## (Run inside of an IRkernel)
display_png(file = 'image.png')
display_svg('
')
display_jpeg(file = url('https://dummyimage.com/600x400.jpg', 'wb'), width = 100)}
}
\seealso{
\code{\link{display_}}
}
IRdisplay/LICENSE 0000644 0001762 0000144 00000000111 12750101502 013141 0 ustar ligges users YEAR: 2014
COPYRIGHT HOLDER: Thomas Kluyver, Philipp Angerer, Jan Schulz