Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions R/display.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ display_raw <- function(mimetype, isbinary, data, file, metadata = NULL) {
content <- prepare_content(isbinary, data, file)
bundle <- list()
bundle[[mimetype]] <- content
# Isolating full html pages (putting them in an iframe)
if (identical(mimetype, 'text/html')) {
if (grepl('<html.*>', content, ignore.case = TRUE)) {
if (is.null(metadata)) {
metadata <- namedlist()
}
html_md <- metadata[[mimetype]]
if (is.null(html_md)) {
html_md <- list(isolated = TRUE)
} else {
html_md[['isolated']] <- TRUE
}
metadata[[mimetype]] <- html_md
}
}
publish_mimebundle(bundle, metadata)
}

Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test_display_functions.r
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ test_that('display_html works', {
expect_equal(get_last_data(), list(exp, NULL))
})

test_that('display_html with full html page', {
exp <- namedlist()
exp_md <- namedlist()
display_html('<html><body>text</body></html>')
exp[['text/html']] <- '<html><body>text</body></html>'
exp_md[['text/html']] <- list(isolated = TRUE)
expect_equal(get_last_data(),list(exp, exp_md))
})


test_that('display_markdown works', {
exp <- namedlist()
display_markdown('data')
Expand Down