This is an automated email from the git hooks/post-receive script. tille pushed a commit to branch master in repository r-cran-htmltools.
commit 69ffeb1b5248527bb7940d3192dcface539cfb61 Author: Andreas Tille <[email protected]> Date: Tue Oct 10 12:47:55 2017 +0200 New upstream version 0.3.6 --- DESCRIPTION | 10 ++--- MD5 | 82 +++++++++++++++++++------------------- NAMESPACE | 2 +- NEWS | 13 ++++++ R/RcppExports.R | 2 +- R/html_dependency.R | 8 ++++ R/tags.R | 48 +++++++++++++++------- R/template.R | 17 +++++--- man/HTML.Rd | 1 - man/as.tags.Rd | 1 - man/browsable.Rd | 1 - man/builder.Rd | 21 +++++----- man/copyDependencyToDir.Rd | 1 - man/css.Rd | 1 - man/findDependencies.Rd | 5 ++- man/htmlDependencies.Rd | 3 +- man/htmlDependency.Rd | 8 +++- man/htmlEscape.Rd | 1 - man/htmlPreserve.Rd | 3 +- man/htmlTemplate.Rd | 1 - man/html_print.Rd | 1 - man/include.Rd | 5 +-- man/knitr_methods.Rd | 5 +-- man/makeDependencyRelative.Rd | 1 - man/print.html.Rd | 3 +- man/renderDependencies.Rd | 1 - man/renderDocument.Rd | 1 - man/renderTags.Rd | 3 +- man/resolveDependencies.Rd | 7 +++- man/save_html.Rd | 1 - man/singleton.Rd | 3 +- man/singleton_tools.Rd | 1 - man/subtractDependencies.Rd | 1 - man/suppressDependencies.Rd | 1 - man/tag.Rd | 8 ++-- man/urlEncodePath.Rd | 1 - man/validateCssUnit.Rd | 5 +-- man/withTags.Rd | 1 - src/RcppExports.cpp | 10 ++--- src/init.c | 18 +++++++++ tests/testthat/template-basic.html | 8 ++++ tests/testthat/test-tags.r | 14 ++++++- tests/testthat/test-template.R | 21 ++++++++++ 43 files changed, 219 insertions(+), 130 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5fc1fae..460e91e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: htmltools Type: Package Title: Tools for HTML -Version: 0.3.5 -Date: 2016-03-19 +Version: 0.3.6 +Date: 2017-04-26 Author: RStudio, Inc. Maintainer: Joe Cheng <[email protected]> Description: Tools for HTML generation and output. @@ -13,9 +13,9 @@ Enhances: knitr License: GPL (>= 2) URL: https://github.com/rstudio/htmltools BugReports: https://github.com/rstudio/htmltools/issues -RoxygenNote: 5.0.1 +RoxygenNote: 6.0.1 LinkingTo: Rcpp NeedsCompilation: yes -Packaged: 2016-03-21 21:26:31 UTC; jcheng +Packaged: 2017-04-27 00:04:32 UTC; jcheng Repository: CRAN -Date/Publication: 2016-03-21 23:36:11 +Date/Publication: 2017-04-28 07:41:46 UTC diff --git a/MD5 b/MD5 index 134ba3b..a48ebc9 100644 --- a/MD5 +++ b/MD5 @@ -1,46 +1,48 @@ -72c03ca6886933e00b494cea3217e13f *DESCRIPTION -3eff63e6ff5eb3d2749b77f1e1a13ae1 *NAMESPACE -6f4e14ce9f5b4301c0b44af926525e9b *NEWS -c1e4413f5fc7eba2f785e76fdda026be *R/RcppExports.R -9328debfe564d97e4c59eb9e02ad2235 *R/html_dependency.R +630310adf5be92835b9544240f92376c *DESCRIPTION +41ac34eea891be5f999ed8b44f87e476 *NAMESPACE +738bee7e0dd52e6d69ccfe44c8dc0394 *NEWS +aa9302feb5eec2cedcb00f9d88e5af74 *R/RcppExports.R +411239656a10eb50c5d1d217b9b57ede *R/html_dependency.R 7bee8b23618adb2848412fedc7164709 *R/html_escape.R b3e3d3353ebc757321b60abcad04397c *R/html_print.R -6a300f33f56fc7d5a8ea0fb5c7634d77 *R/tags.R -06648459a4195a4c81282ae5729edc97 *R/template.R -747b00f84aac5d38d90c382b7acea766 *man/HTML.Rd -5f6685813bb68b37c2cef66dc64ec6b4 *man/as.tags.Rd -93da0c851632d533098dfa737ef69274 *man/browsable.Rd -a1f0a58f58e94685b9fe09314dc949ef *man/builder.Rd -9eb6d8d33eb3d7278c44f08a52c4c153 *man/copyDependencyToDir.Rd -8487ea5a1d6d5d5a37f14e56776b263d *man/css.Rd -033d3ca20f2ca5598f1a146aabe59184 *man/findDependencies.Rd -2af4b1961a102b3ae97d80bfc652ebe2 *man/htmlDependencies.Rd -ee1b263b7ca40387a68f9fca8e2eadb1 *man/htmlDependency.Rd -e204dbba8c1854906529114e0d2e47f2 *man/htmlEscape.Rd -4e6d962c82d788fbb49b51264eeb9123 *man/htmlPreserve.Rd -c12e2e060c1f0a252c7339bbd946d3c2 *man/htmlTemplate.Rd -823f31b10e4c759bd944eed49f8224da *man/html_print.Rd -6ef8c0f2ba87b45f17817f7febda6365 *man/include.Rd -4ee94c21c8d63531903bbff3bb75926f *man/knitr_methods.Rd -26aa8ef492ac58d38483f14c8897a077 *man/makeDependencyRelative.Rd -958b662a2a54e8030649e391e9ed1ded *man/print.html.Rd -9e4c782f5ad5aed1b31f1bf70beca638 *man/renderDependencies.Rd -8478bfe350d31adff0e94ebf5a3aea65 *man/renderDocument.Rd -3f71ee0061e139ac0fc10f0e38e0765c *man/renderTags.Rd -bf9c821c3fcac5b092940b1acbe8f4df *man/resolveDependencies.Rd -517d1ed333b880fc0846d82f09d86f96 *man/save_html.Rd -03a6dd0aab6a1150f8c0b575aacc0806 *man/singleton.Rd -ef71b945ad76fb3a1d8e8d89fbecc19b *man/singleton_tools.Rd -c27574242254c7379b602e957ecfb7d9 *man/subtractDependencies.Rd -0b686655aaa750cff5d37a674207f6bd *man/suppressDependencies.Rd -e7721483d5e136d7652edba62e64e54d *man/tag.Rd -cb34418668e63388d3edd67d2dd90c52 *man/urlEncodePath.Rd -60be5348923d73ebf9235e6e790628e3 *man/validateCssUnit.Rd -4a499bda5c52e3a41a9d0d01e29b3536 *man/withTags.Rd -978ffdd268a174b06c94b067b18c46d7 *src/RcppExports.cpp +f02106c1cda38dbdd97d40370f99e4e1 *R/tags.R +31064a678bc8589cfd29497262ba2110 *R/template.R +ebcfaa458d3bdefadded43a4d64cfff9 *man/HTML.Rd +c00712c215b7bbb80a6287fee17f3c24 *man/as.tags.Rd +88494342535e91fa8972fd2fc3f1fde5 *man/browsable.Rd +6bfa2d7cdaca48f17caaa6b11902e28e *man/builder.Rd +bcfebb5f9577a5013fe33242fdec9645 *man/copyDependencyToDir.Rd +11bd91091ffdde442e05a6a26823a84d *man/css.Rd +83f5a6962792ba50b19b48dc1c65fd39 *man/findDependencies.Rd +b1b2d807ab611007bdf9b582b64e5f24 *man/htmlDependencies.Rd +9f7aaeaaa75598fbb0ab71e20359965d *man/htmlDependency.Rd +91c1824deb08f57376108765fd29dbaa *man/htmlEscape.Rd +475bf569370053b828bf69e4bb283825 *man/htmlPreserve.Rd +516afef01fac034a4e414e7515a7b71e *man/htmlTemplate.Rd +f0a6e81826dcaf3e212e70c63e67189e *man/html_print.Rd +4f34e99b07220d7a2fa41b9029a16862 *man/include.Rd +93bd5afcdac04bc4c5322122f0710e75 *man/knitr_methods.Rd +2b18a3612062f7783435b8dfd1e215f4 *man/makeDependencyRelative.Rd +16159aa45a251fb364e5fd1fd144d1d7 *man/print.html.Rd +504914f9f04e3a96f20d707b5acc341f *man/renderDependencies.Rd +dee26db7dd1d20fc2f13746ef9e9ae1d *man/renderDocument.Rd +5943238916b4b5866e49846183c95f98 *man/renderTags.Rd +3d7d639046044b164f7dabe61158c67d *man/resolveDependencies.Rd +3e8fac6287e21baa2e492fb2e581689b *man/save_html.Rd +72d8cd938a5a644116813539b07d0576 *man/singleton.Rd +0c319382fa19718f0d0da795c20501ce *man/singleton_tools.Rd +f0de725705e4f99a532bc4a9cc58664c *man/subtractDependencies.Rd +127fb8880888366a5c37c0b3b7eac069 *man/suppressDependencies.Rd +c36b122e98a5f4a6e89892f9cf8336ba *man/tag.Rd +cd3894dd85e4d84cc4ff5dc2a567fd4b *man/urlEncodePath.Rd +b107695e665e7daf7fb074bfd1ad4d94 *man/validateCssUnit.Rd +dec0c8e4a1f951e26daa06e9c07f986b *man/withTags.Rd +3305b464312f0fccbc917c491e79201d *src/RcppExports.cpp +a941e5cc1f933a4245b62b772a9263c5 *src/init.c f7dbf02b3735f8a64fb1cc9264416713 *src/template.cpp d5386f261693f9f4a5dda7b6fe0aa9f0 *tests/test-all.R +4de059d582d96a7c86907beb670b819d *tests/testthat/template-basic.html ce9c101bbebef449d432567b9a29e9f9 *tests/testthat/template-document.html bd23b1f0bd8705c3fe39c9f537cd1305 *tests/testthat/test-deps.r -2d382055a6affd4f39407b0664c04041 *tests/testthat/test-tags.r -0c93372a28e38db6c9e7146c6a1644af *tests/testthat/test-template.R +f619582da6617e70858b2c462f956f9b *tests/testthat/test-tags.r +2d57750590f71f1bb6a96604a05a7d23 *tests/testthat/test-template.R diff --git a/NAMESPACE b/NAMESPACE index 98c7a22..d36fd06 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -86,4 +86,4 @@ export(withTags) import(digest) import(utils) importFrom(Rcpp,sourceCpp) -useDynLib(htmltools) +useDynLib(htmltools, .registration = TRUE) diff --git a/NEWS b/NEWS index 1d3bf0e..6074313 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,16 @@ +htmltools 0.3.6 +-------------------------------------------------------------------------------- + +* `validateCssUnit()` now accepts viewport units (vw, vh, vmin, vmax). (#56) + +* `restorePreserveChunks()` marks the output with the correct encoding now + (UTF-8). + +* Length-0 attributes are now dropped, like NULLs. (#65) + +* Fixed #69: On Windows, `renderDocument()` did not mark output as UTF-8 if the + head was UTF-8 but body was ASCII. (#71) + htmltools 0.3.5 -------------------------------------------------------------------------------- diff --git a/R/RcppExports.R b/R/RcppExports.R index a7bbf42..5cb5287 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1,4 +1,4 @@ -# This file was generated by Rcpp::compileAttributes +# Generated by using Rcpp::compileAttributes() -> do not edit by hand # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 template_dfa <- function(x) { diff --git a/R/html_dependency.R b/R/html_dependency.R index 0f2011e..9db9405 100644 --- a/R/html_dependency.R +++ b/R/html_dependency.R @@ -19,6 +19,9 @@ #' @param head Arbitrary lines of HTML to insert into the document head #' @param attachment Attachment(s) to include within the document head. See #' Details. +#' @param package An R package name to indicate where to find the \code{src} +#' directory when \code{src} is a relative path (see +#' \code{\link{resolveDependencies}}). #' @param all_files Whether all files under the \code{src} directory are #' dependency files. If \code{FALSE}, only the files specified in #' \code{script}, \code{stylesheet}, and \code{attachment} are treated as @@ -67,6 +70,7 @@ htmlDependency <- function(name, stylesheet = NULL, head = NULL, attachment = NULL, + package = NULL, all_files = TRUE) { # This function shouldn't be called from a namespace environment with @@ -99,6 +103,7 @@ htmlDependency <- function(name, stylesheet = stylesheet, head = head, attachment = attachment, + package = package, all_files = all_files )) } @@ -270,6 +275,9 @@ copyDependencyToDir <- function(dependency, outputDir, mustWork = TRUE) { return(dependency) } } + # resolve the relative file path to absolute path in package + if (!is.null(dependency$package)) + dir <- system.file(dir, package = dependency$package) if (length(outputDir) != 1 || outputDir %in% c("", "/")) stop('outputDir must be of length 1 and cannot be "" or "/"') diff --git a/R/tags.R b/R/tags.R index 1bcb86e..6481447 100644 --- a/R/tags.R +++ b/R/tags.R @@ -68,11 +68,14 @@ depListToNamedDepList <- function(dependencies) { #' the latest version number is used. #' #' @param dependencies A list of \code{\link{htmlDependency}} objects. +#' @param resolvePackageDir Whether to resolve the relative path to an absolute +#' path via \code{\link{system.file}} when the \code{package} attribute is +#' present in a dependency object. #' @return dependencies A list of \code{\link{htmlDependency}} objects with #' redundancies removed. #' #' @export -resolveDependencies <- function(dependencies) { +resolveDependencies <- function(dependencies, resolvePackageDir = TRUE) { # Remove nulls deps <- dependencies[!sapply(dependencies, is.null)] @@ -88,7 +91,13 @@ resolveDependencies <- function(dependencies) { sorted <- order(ifelse(depnames == depname, TRUE, NA), depvers, na.last = NA, decreasing = TRUE) # The first element in the list is the one with the largest version. - deps[[sorted[[1]]]] + dep <- deps[[sorted[[1]]]] + if (resolvePackageDir && !is.null(dep$package)) { + dir <- dep$src$file + if (!is.null(dir)) dep$src$file <- system.file(dir, package = dep$package) + dep$package <- NULL + } + dep })) } @@ -150,9 +159,10 @@ dropNulls <- function(x) { } nullOrEmpty <- function(x) { - is.null(x) || length(x) == 0 + length(x) == 0 } -# Given a vector or list, drop all the NULL items in it + +# Given a vector or list, drop all the NULL or length-0 items in it dropNullsOrEmpty <- function(x) { x[!vapply(x, nullOrEmpty, FUN.VALUE=logical(1))] } @@ -333,9 +343,9 @@ tag <- function(`_tag_name`, varArgs) { if (is.null(varArgsNames)) varArgsNames <- character(length=length(varArgs)) - # Named arguments become attribs, dropping NULL values + # Named arguments become attribs, dropping NULL and length-0 values named_idx <- nzchar(varArgsNames) - attribs <- dropNulls(varArgs[named_idx]) + attribs <- dropNullsOrEmpty(varArgs[named_idx]) # Unnamed arguments are flattened and added as children. # Use unname() to remove the names attribute from the list, which would @@ -472,7 +482,7 @@ renderTags <- function(x, singletons = character(0), indent = 0) { # Do singleton and head processing before rendering singletonInfo <- takeSingletons(x, singletons) headInfo <- takeHeads(singletonInfo$ui) - deps <- resolveDependencies(findDependencies(singletonInfo$ui)) + deps <- resolveDependencies(findDependencies(singletonInfo$ui, tagify = FALSE)) headIndent <- if (is.numeric(indent)) indent + 1 else indent headHtml <- doRenderTags(headInfo$head, indent = headIndent) @@ -636,12 +646,16 @@ takeHeads <- function(ui) { #' Walks a hierarchy of tags looking for attached dependencies. #' #' @param tags A tag-like object to search for dependencies. +#' @param tagify Whether to tagify the input before searching for dependencies. #' #' @return A list of \code{\link{htmlDependency}} objects. #' #' @export -findDependencies <- function(tags) { - dep <- htmlDependencies(tagify(tags)) +findDependencies <- function(tags, tagify = TRUE) { + if (isTRUE(tagify)) { + tags <- tagify(tags) + } + dep <- htmlDependencies(tags) if (!is.null(dep) && inherits(dep, "html_dependency")) dep <- list(dep) children <- if (is.list(tags)) { @@ -651,7 +665,7 @@ findDependencies <- function(tags) { tags } } - childDeps <- unlist(lapply(children, findDependencies), recursive = FALSE) + childDeps <- unlist(lapply(children, findDependencies, tagify = FALSE), recursive = FALSE) c(childDeps, if (!is.null(dep)) dep) } @@ -1140,8 +1154,11 @@ extractPreserveChunks <- function(strval) { #' @rdname htmlPreserve #' @export restorePreserveChunks <- function(strval, chunks) { + strval <- enc2utf8(strval) + chunks <- enc2utf8(chunks) for (id in names(chunks)) strval <- gsub(id, chunks[[id]], strval, fixed = TRUE, useBytes = TRUE) + Encoding(strval) <- 'UTF-8' strval } @@ -1160,7 +1177,7 @@ NULL knit_print.shiny.tag <- function(x, ...) { x <- tagify(x) output <- surroundSingletons(x) - deps <- resolveDependencies(findDependencies(x)) + deps <- resolveDependencies(findDependencies(x, tagify = FALSE), resolvePackageDir = FALSE) content <- takeHeads(output) head_content <- doRenderTags(tagList(content$head)) @@ -1177,7 +1194,7 @@ knit_print.shiny.tag <- function(x, ...) { #' @rdname knitr_methods #' @export knit_print.html <- function(x, ...) { - deps <- resolveDependencies(findDependencies(x)) + deps <- resolveDependencies(findDependencies(x, tagify = FALSE)) knitr::asis_output(htmlPreserve(as.character(x)), meta = if (length(deps)) list(deps)) } @@ -1354,8 +1371,9 @@ is.singleton <- function(x) { #' Single element character vectors must be \code{"auto"} or \code{"inherit"}, #' or a number. If the number has a suffix, it must be valid: \code{px}, #' \code{\%}, \code{em}, \code{pt}, \code{in}, \code{cm}, \code{mm}, \code{ex}, -#' or \code{pc}. If the number has no suffix, the suffix \code{"px"} is -#' appended. +#' \code{pc}, \code{vh}, \code{vw}, \code{vmin}, or \code{vmax}. +#' If the number has no suffix, the suffix \code{"px"} is appended. +#' #' #' Any other value will cause an error to be thrown. #' @@ -1380,7 +1398,7 @@ validateCssUnit <- function(x) { x <- as.numeric(x) pattern <- - "^(auto|inherit|((\\.\\d+)|(\\d+(\\.\\d+)?))(%|in|cm|mm|em|ex|pt|pc|px))$" + "^(auto|inherit|((\\.\\d+)|(\\d+(\\.\\d+)?))(%|in|cm|mm|em|ex|pt|pc|px|vh|vw|vmin|vmax))$" if (is.character(x) && !grepl(pattern, x)) { diff --git a/R/template.R b/R/template.R index 24d8022..f3fd18b 100644 --- a/R/template.R +++ b/R/template.R @@ -17,7 +17,7 @@ #' #' @seealso \code{\link{renderDocument}} #' @export -#' @useDynLib htmltools +#' @useDynLib htmltools, .registration = TRUE #' @importFrom Rcpp sourceCpp htmlTemplate <- function(filename = NULL, ..., text_ = NULL, document_ = "auto") { if (!xor(is.null(filename), is.null(text_))) { @@ -120,15 +120,22 @@ renderDocument <- function(x, deps = NULL, processDep = identity) { # Put content in the <head> section head_content <- paste0( - ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>', - sprintf(' <script type="application/shiny-singletons">%s</script>', + ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n', + sprintf(' <script type="application/shiny-singletons">%s</script>\n', paste(result$singletons, collapse = ',') ), - sprintf(' <script type="application/html-dependencies">%s</script>', + sprintf(' <script type="application/html-dependencies">%s</script>\n', depStr ), depHtml, c(result$head, recursive = TRUE) ) - sub("<!-- HEAD_CONTENT -->", head_content, result$html, fixed = TRUE) + # Need to mark result as UTF-8. If body is ASCII, it will be marked with + # encoding "unknown". If the head has UTF-8 characters and is marked as + # "UTF-8", the output string here will have the correct UTF-8 byte sequences, + # but will be marked as "unknown", which causes the wrong text to be + # displayed. See https://github.com/rstudio/shiny/issues/1395 + res <- sub("<!-- HEAD_CONTENT -->", head_content, result$html, fixed = TRUE) + Encoding(res) <- "UTF-8" + res } diff --git a/man/HTML.Rd b/man/HTML.Rd index 48cd613..35dbebb 100644 --- a/man/HTML.Rd +++ b/man/HTML.Rd @@ -24,4 +24,3 @@ el <- div(HTML("I like <u>turtles</u>")) cat(as.character(el)) } - diff --git a/man/as.tags.Rd b/man/as.tags.Rd index 7b056fd..49ff125 100644 --- a/man/as.tags.Rd +++ b/man/as.tags.Rd @@ -16,4 +16,3 @@ An S3 method for converting arbitrary values to a value that can be used as the child of a tag or \code{tagList}. The default implementation simply calls \code{\link[base]{as.character}}. } - diff --git a/man/browsable.Rd b/man/browsable.Rd index 1b0c68a..b2d186e 100644 --- a/man/browsable.Rd +++ b/man/browsable.Rd @@ -30,4 +30,3 @@ by default when printed at the console. You can override the default browsability of an HTML object by explicitly passing \code{browse = TRUE} (or \code{FALSE}) to the \code{print} function. } - diff --git a/man/builder.Rd b/man/builder.Rd index 9a79291..d375421 100644 --- a/man/builder.Rd +++ b/man/builder.Rd @@ -1,25 +1,25 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/tags.R \name{builder} -\alias{a} -\alias{br} \alias{builder} -\alias{code} -\alias{div} -\alias{em} +\alias{tags} +\alias{p} \alias{h1} \alias{h2} \alias{h3} \alias{h4} \alias{h5} \alias{h6} -\alias{hr} -\alias{img} -\alias{p} -\alias{pre} +\alias{a} +\alias{br} +\alias{div} \alias{span} +\alias{pre} +\alias{code} +\alias{img} \alias{strong} -\alias{tags} +\alias{em} +\alias{hr} \title{HTML Builder Functions} \usage{ tags @@ -95,4 +95,3 @@ doc <- tags$html( ) cat(as.character(doc)) } - diff --git a/man/copyDependencyToDir.Rd b/man/copyDependencyToDir.Rd index 99b27b4..9ac765c 100644 --- a/man/copyDependencyToDir.Rd +++ b/man/copyDependencyToDir.Rd @@ -36,4 +36,3 @@ easier to perform that copy. \code{\link{makeDependencyRelative}} can be used with the returned value to make the path relative to a specific directory. } - diff --git a/man/css.Rd b/man/css.Rd index 3921316..0ceac7e 100644 --- a/man/css.Rd +++ b/man/css.Rd @@ -45,4 +45,3 @@ css( ) } - diff --git a/man/findDependencies.Rd b/man/findDependencies.Rd index 37e0834..1402723 100644 --- a/man/findDependencies.Rd +++ b/man/findDependencies.Rd @@ -4,10 +4,12 @@ \alias{findDependencies} \title{Collect attached dependencies from HTML tag object} \usage{ -findDependencies(tags) +findDependencies(tags, tagify = TRUE) } \arguments{ \item{tags}{A tag-like object to search for dependencies.} + +\item{tagify}{Whether to tagify the input before searching for dependencies.} } \value{ A list of \code{\link{htmlDependency}} objects. @@ -15,4 +17,3 @@ A list of \code{\link{htmlDependency}} objects. \description{ Walks a hierarchy of tags looking for attached dependencies. } - diff --git a/man/htmlDependencies.Rd b/man/htmlDependencies.Rd index 7e1fcf5..326f5ea 100644 --- a/man/htmlDependencies.Rd +++ b/man/htmlDependencies.Rd @@ -1,9 +1,9 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/html_dependency.R \name{htmlDependencies} -\alias{attachDependencies} \alias{htmlDependencies} \alias{htmlDependencies<-} +\alias{attachDependencies} \title{HTML dependency metadata} \usage{ htmlDependencies(x) @@ -53,4 +53,3 @@ tagList(div("Code here"), dep) attachDependencies(div("Code here"), dep) } - diff --git a/man/htmlDependency.Rd b/man/htmlDependency.Rd index 891a0be..bde3897 100644 --- a/man/htmlDependency.Rd +++ b/man/htmlDependency.Rd @@ -5,7 +5,8 @@ \title{Define an HTML dependency} \usage{ htmlDependency(name, version, src, meta = NULL, script = NULL, - stylesheet = NULL, head = NULL, attachment = NULL, all_files = TRUE) + stylesheet = NULL, head = NULL, attachment = NULL, package = NULL, + all_files = TRUE) } \arguments{ \item{name}{Library name} @@ -30,6 +31,10 @@ specified relative to the \code{src} parameter).} \item{attachment}{Attachment(s) to include within the document head. See Details.} +\item{package}{An R package name to indicate where to find the \code{src} +directory when \code{src} is a relative path (see +\code{\link{resolveDependencies}}).} + \item{all_files}{Whether all files under the \code{src} directory are dependency files. If \code{FALSE}, only the files specified in \code{script}, \code{stylesheet}, and \code{attachment} are treated as @@ -78,4 +83,3 @@ Each dependency can be located on the filesystem, at a relative or Use \code{\link{attachDependencies}} to associate a list of dependencies with the HTML it belongs with. } - diff --git a/man/htmlEscape.Rd b/man/htmlEscape.Rd index 1f99b75..c8c4bb1 100644 --- a/man/htmlEscape.Rd +++ b/man/htmlEscape.Rd @@ -18,4 +18,3 @@ Character vector with escaped text. Escape HTML entities contained in a character vector so that it can be safely included as text or an attribute value within an HTML document } - diff --git a/man/htmlPreserve.Rd b/man/htmlPreserve.Rd index 5f60569..bcb9435 100644 --- a/man/htmlPreserve.Rd +++ b/man/htmlPreserve.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/tags.R \name{htmlPreserve} -\alias{extractPreserveChunks} \alias{htmlPreserve} +\alias{extractPreserveChunks} \alias{restorePreserveChunks} \title{Preserve HTML regions} \usage{ @@ -63,4 +63,3 @@ output <- restorePreserveChunks(output, extracted$chunks) output } - diff --git a/man/htmlTemplate.Rd b/man/htmlTemplate.Rd index 165fa65..55cbef0 100644 --- a/man/htmlTemplate.Rd +++ b/man/htmlTemplate.Rd @@ -29,4 +29,3 @@ complete HTML document, then the returned object will also have class \seealso{ \code{\link{renderDocument}} } - diff --git a/man/html_print.Rd b/man/html_print.Rd index 67b8bac..853cd47 100644 --- a/man/html_print.Rd +++ b/man/html_print.Rd @@ -22,4 +22,3 @@ Invisibly returns the URL or path of the generated HTML page. Convenience method that provides an implementation of the \code{\link[base:print]{print}} method for HTML content. } - diff --git a/man/include.Rd b/man/include.Rd index 4a5d8ce..86dcf9a 100644 --- a/man/include.Rd +++ b/man/include.Rd @@ -2,11 +2,11 @@ % Please edit documentation in R/tags.R \name{include} \alias{include} -\alias{includeCSS} \alias{includeHTML} +\alias{includeText} \alias{includeMarkdown} +\alias{includeCSS} \alias{includeScript} -\alias{includeText} \title{Include Content From a File} \usage{ includeHTML(path) @@ -44,4 +44,3 @@ large literal R string. The \code{includeMarkdown} function requires the \code{markdown} package. } - diff --git a/man/knitr_methods.Rd b/man/knitr_methods.Rd index fc48f49..9f115df 100644 --- a/man/knitr_methods.Rd +++ b/man/knitr_methods.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/tags.R \name{knitr_methods} -\alias{knit_print.html} +\alias{knitr_methods} \alias{knit_print.shiny.tag} +\alias{knit_print.html} \alias{knit_print.shiny.tag.list} -\alias{knitr_methods} \title{Knitr S3 methods} \usage{ knit_print.shiny.tag(x, ...) @@ -22,4 +22,3 @@ knit_print.shiny.tag.list(x, ...) These S3 methods are necessary to allow HTML tags to print themselves in knitr/rmarkdown documents. } - diff --git a/man/makeDependencyRelative.Rd b/man/makeDependencyRelative.Rd index 9f9eb07..f568bbd 100644 --- a/man/makeDependencyRelative.Rd +++ b/man/makeDependencyRelative.Rd @@ -30,4 +30,3 @@ directories. \seealso{ \code{\link{copyDependencyToDir}} } - diff --git a/man/print.html.Rd b/man/print.html.Rd index d3b51fa..187f86f 100644 --- a/man/print.html.Rd +++ b/man/print.html.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/tags.R \name{print.shiny.tag} -\alias{print.html} \alias{print.shiny.tag} +\alias{print.html} \title{Print method for HTML/tags} \usage{ \method{print}{shiny.tag}(x, browse = is.browsable(x), ...) @@ -23,4 +23,3 @@ will be rendered at the console.} S3 method for printing HTML that prints markup or renders HTML in a web browser. } - diff --git a/man/renderDependencies.Rd b/man/renderDependencies.Rd index 7c23b38..1b0fc2d 100644 --- a/man/renderDependencies.Rd +++ b/man/renderDependencies.Rd @@ -27,4 +27,3 @@ An \code{\link{HTML}} object suitable for inclusion in the head of an Create the appropriate HTML markup for including dependencies in an HTML document. } - diff --git a/man/renderDocument.Rd b/man/renderDocument.Rd index ea59f41..0bf2372 100644 --- a/man/renderDocument.Rd +++ b/man/renderDocument.Rd @@ -29,4 +29,3 @@ inserts those. To do the insertion, this function finds the string \code{"<!-- HEAD_CONTENT -->"} in the document, and replaces it with the web dependencies. } - diff --git a/man/renderTags.Rd b/man/renderTags.Rd index 2213675..f5b63df 100644 --- a/man/renderTags.Rd +++ b/man/renderTags.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/tags.R \name{renderTags} -\alias{doRenderTags} \alias{renderTags} +\alias{doRenderTags} \title{Render tags into HTML} \usage{ renderTags(x, singletons = character(0), indent = 0) @@ -49,4 +49,3 @@ framework libraries, not directly by most users--see singleton, head, and dependency handling, and simply renders the given tag objects as HTML. } - diff --git a/man/resolveDependencies.Rd b/man/resolveDependencies.Rd index f08ce85..1c3bb4d 100644 --- a/man/resolveDependencies.Rd +++ b/man/resolveDependencies.Rd @@ -4,10 +4,14 @@ \alias{resolveDependencies} \title{Resolve a list of dependencies} \usage{ -resolveDependencies(dependencies) +resolveDependencies(dependencies, resolvePackageDir = TRUE) } \arguments{ \item{dependencies}{A list of \code{\link{htmlDependency}} objects.} + +\item{resolvePackageDir}{Whether to resolve the relative path to an absolute +path via \code{\link{system.file}} when the \code{package} attribute is +present in a dependency object.} } \value{ dependencies A list of \code{\link{htmlDependency}} objects with @@ -18,4 +22,3 @@ Given a list of dependencies, removes any redundant dependencies (based on name equality). If multiple versions of a dependency are found, the copy with the latest version number is used. } - diff --git a/man/save_html.Rd b/man/save_html.Rd index 736eeff..1dfeaf5 100644 --- a/man/save_html.Rd +++ b/man/save_html.Rd @@ -19,4 +19,3 @@ save_html(html, file, background = "white", libdir = "lib") Save the specified HTML object to a file, copying all of it's dependencies to the directory specified via \code{libdir}. } - diff --git a/man/singleton.Rd b/man/singleton.Rd index 9bcbcf6..bd1ac45 100644 --- a/man/singleton.Rd +++ b/man/singleton.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/tags.R \name{singleton} -\alias{is.singleton} \alias{singleton} +\alias{is.singleton} \title{Include content only once} \usage{ singleton(x, value = TRUE) @@ -20,4 +20,3 @@ be included in the generated document only once, yet may appear in the document-generating code more than once. Only the first appearance of the content (in document order) will be used. } - diff --git a/man/singleton_tools.Rd b/man/singleton_tools.Rd index 9ff54d2..2bfeb61 100644 --- a/man/singleton_tools.Rd +++ b/man/singleton_tools.Rd @@ -33,4 +33,3 @@ encountered should have the singleton attribute removed.} Functions for manipulating \code{\link{singleton}} objects in tag hierarchies. Intended for framework authors. } - diff --git a/man/subtractDependencies.Rd b/man/subtractDependencies.Rd index 2816d27..4a5645c 100644 --- a/man/subtractDependencies.Rd +++ b/man/subtractDependencies.Rd @@ -30,4 +30,3 @@ list; if the latter, a warning can be emitted if the version of the dependency being removed is later than the version of the dependency object that is causing the removal. } - diff --git a/man/suppressDependencies.Rd b/man/suppressDependencies.Rd index 675ba0f..cb71113 100644 --- a/man/suppressDependencies.Rd +++ b/man/suppressDependencies.Rd @@ -21,4 +21,3 @@ HTML template. \code{\link[htmltools]{htmlDependency}} } - diff --git a/man/tag.Rd b/man/tag.Rd index 8743c67..8e00698 100644 --- a/man/tag.Rd +++ b/man/tag.Rd @@ -2,13 +2,14 @@ % Please edit documentation in R/tags.R \name{tag} \alias{tag} +\alias{tagList} \alias{tagAppendAttributes} +\alias{tagHasAttribute} +\alias{tagGetAttribute} \alias{tagAppendChild} \alias{tagAppendChildren} -\alias{tagGetAttribute} -\alias{tagHasAttribute} -\alias{tagList} \alias{tagSetChildren} +\alias{tag} \title{HTML Tag Object} \usage{ tagList(...) @@ -71,4 +72,3 @@ x <- list(tags$h1("Title"), tags$p("Text here")) tagList(x) } - diff --git a/man/urlEncodePath.Rd b/man/urlEncodePath.Rd index a78bd28..b893276 100644 --- a/man/urlEncodePath.Rd +++ b/man/urlEncodePath.Rd @@ -14,4 +14,3 @@ Encode characters in a URL path. This is the same as \code{\link[utils]{URLencode}} with \code{reserved = TRUE} except that \code{/} is preserved. } - diff --git a/man/validateCssUnit.Rd b/man/validateCssUnit.Rd index 61052cb..a90f7c9 100644 --- a/man/validateCssUnit.Rd +++ b/man/validateCssUnit.Rd @@ -26,8 +26,8 @@ number plus a suffix of \code{"px"}. Single element character vectors must be \code{"auto"} or \code{"inherit"}, or a number. If the number has a suffix, it must be valid: \code{px}, \code{\%}, \code{em}, \code{pt}, \code{in}, \code{cm}, \code{mm}, \code{ex}, -or \code{pc}. If the number has no suffix, the suffix \code{"px"} is -appended. +\code{pc}, \code{vh}, \code{vw}, \code{vmin}, or \code{vmax}. +If the number has no suffix, the suffix \code{"px"} is appended. Any other value will cause an error to be thrown. } @@ -35,4 +35,3 @@ Any other value will cause an error to be thrown. validateCssUnit("10\%") validateCssUnit(400) #treated as '400px' } - diff --git a/man/withTags.Rd b/man/withTags.Rd index 58c3bf8..a8a7717 100644 --- a/man/withTags.Rd +++ b/man/withTags.Rd @@ -39,4 +39,3 @@ withTags( } - diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 792e3d1..29e6404 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -1,4 +1,4 @@ -// This file was generated by Rcpp::compileAttributes +// Generated by using Rcpp::compileAttributes() -> do not edit by hand // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 #include <Rcpp.h> @@ -9,10 +9,10 @@ using namespace Rcpp; std::vector<std::string> template_dfa(CharacterVector x); RcppExport SEXP htmltools_template_dfa(SEXP xSEXP) { BEGIN_RCPP - Rcpp::RObject __result; - Rcpp::RNGScope __rngScope; + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::traits::input_parameter< CharacterVector >::type x(xSEXP); - __result = Rcpp::wrap(template_dfa(x)); - return __result; + rcpp_result_gen = Rcpp::wrap(template_dfa(x)); + return rcpp_result_gen; END_RCPP } diff --git a/src/init.c b/src/init.c new file mode 100644 index 0000000..a1ca19b --- /dev/null +++ b/src/init.c @@ -0,0 +1,18 @@ +#include <R.h> +#include <Rinternals.h> +#include <stdlib.h> // for NULL +#include <R_ext/Rdynload.h> + +/* .Call calls */ +extern SEXP htmltools_template_dfa(SEXP); + +static const R_CallMethodDef CallEntries[] = { + {"htmltools_template_dfa", (DL_FUNC) &htmltools_template_dfa, 1}, + {NULL, NULL, 0} +}; + +void R_init_htmltools(DllInfo *dll) +{ + R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); + R_useDynamicSymbols(dll, FALSE); +} diff --git a/tests/testthat/template-basic.html b/tests/testthat/template-basic.html new file mode 100644 index 0000000..cf42346 --- /dev/null +++ b/tests/testthat/template-basic.html @@ -0,0 +1,8 @@ +<html> +<head> +{{ headContent() }} +</head> +<body> +{{ body }} +</body> +</html> diff --git a/tests/testthat/test-tags.r b/tests/testthat/test-tags.r index 250087d..80b6adc 100644 --- a/tests/testthat/test-tags.r +++ b/tests/testthat/test-tags.r @@ -168,12 +168,24 @@ test_that("Creating simple tags", { div(b = "value") ) + # length-0 attributes are dropped + expect_identical( + div(a = character(), b = "value"), + div(b = "value") + ) + # NULL children are dropped expect_identical( renderTags(div("foo", NULL, list(NULL, list(NULL, "bar"))))$html, renderTags(div("foo", "bar"))$html ) + # length-0 children are dropped + expect_identical( + renderTags(div("foo", character(), list(character(), list(list(), "bar"))))$html, + renderTags(div("foo", "bar"))$html + ) + # Numbers are coerced to strings expect_identical( renderTags(div(1234))$html, @@ -590,7 +602,7 @@ test_that("cssList tests", { expect_error(css(1, b=2)) # NULL and empty string are dropped - expect_identical(css(a="", b = NULL, "c!" = NULL), "") + expect_identical(css(a="", b = NULL, "c!" = NULL, d = character()), "") # We are dumb about duplicated properties. Probably don't do that. expect_identical(css(a=1, a=2), "a:1;a:2;") diff --git a/tests/testthat/test-template.R b/tests/testthat/test-template.R index 176c2df..7913bc9 100644 --- a/tests/testthat/test-template.R +++ b/tests/testthat/test-template.R @@ -46,6 +46,27 @@ test_that("UTF-8 characters in templates", { expect_identical(charToRaw(text), as.raw(c(0xc3, 0xbf))) }) +test_that("UTF-8 characters in template head but not body", { + # On Windows, a string with "中文" will automatically be marked as UTF-8. + ui <- tagList( + tags$head(tags$script("alert('中文')")), + "test" + ) + html <- htmlTemplate("template-basic.html", body = ui) + res <- renderDocument(html) + expect_identical(Encoding(res), "UTF-8") + expect_true(grepl("中文", res, fixed = TRUE)) + + # On Windows, a string with "á" will automatically be marked as latin1. + ui <- tagList( + tags$head(tags$script("alert('á')")), + "test" + ) + html <- htmlTemplate("template-basic.html", body = ui) + res <- renderDocument(html) + expect_identical(Encoding(res), "UTF-8") + expect_true(grepl("á", res, fixed = TRUE)) +}) test_that("Dependencies are added properly", { dep <- htmlDependency("d3", "3.5.10", c(href="shared"), script = "d3.js") -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-htmltools.git _______________________________________________ debian-med-commit mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit
