diff --git a/DESCRIPTION b/DESCRIPTION index 5ad6b47..2191420 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,10 +17,10 @@ Depends: R (>= 3.0.1) Imports: utils, - grDevices + grDevices, + highr Suggests: methods, - highr, Cairo, testthat Enhances: data.table, dplyr, htmlwidgets diff --git a/NAMESPACE b/NAMESPACE index b661f4a..e303f1d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -76,6 +76,7 @@ importFrom(grDevices,pdf) importFrom(grDevices,png) importFrom(grDevices,replayPlot) importFrom(grDevices,svg) +importFrom(highr,hilight) importFrom(tools,Rd2HTML) importFrom(tools,Rd2latex) importFrom(tools,Rd2txt) diff --git a/R/options.r b/R/options.r index 605bb90..fe5f062 100644 --- a/R/options.r +++ b/R/options.r @@ -38,7 +38,7 @@ #' \code{end} mainly exists for when you want a vertical line there (default: 'r|', 'l', and '') #' } #' \item{\code{repr.function.highlight}}{ -#' Use the \code{highr} package to insert highlighting instructions into the code? Needs that package to be installed. (default: FALSE) +#' Use the \code{highr} package to insert highlighting instructions into the code? (default: TRUE) #' } #' #' } @@ -64,7 +64,7 @@ class_defaults <- list( repr.matrix.max.rows = 60, repr.matrix.max.cols = 20, repr.matrix.latex.colspec = list(row_head = 'r|', col = 'l', end = ''), - repr.function.highlight = FALSE) + repr.function.highlight = TRUE) #' @name repr-options #' @export diff --git a/R/repr_function.r b/R/repr_function.r index fdbac3c..dda5dd6 100644 --- a/R/repr_function.r +++ b/R/repr_function.r @@ -10,12 +10,11 @@ #' @include utils.r NULL +#' @importFrom highr hilight repr_function_generic <- function(f, fmt, escape, high_wrap, norm_wrap, highlight) { code <- deparse(f) if (highlight) { - if (!requireNamespace('highr')) - stop(sprintf('Tried to create a %s representation of a function with highlighting, but the `highlight` package is not installed!', fmt)) - code <- highr::hilight(code, fmt) + code <- hilight(code, fmt) wrap <- high_wrap } else { code <- escape(code) diff --git a/README.md b/README.md index 73fb7d1..737efae 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,10 @@ Exports Imports ------- -Per default, `repr` will not use any packages not part of the R distribution. - -Only if you want to use `repr_html.function` and `repr_latex.function`, and specify the parameter `highlight` or option `repr.function.highlight` to be `TRUE`, then be sure to have [highr][] installed. +`repr` uses [highr][] to highlight functions, and can optionally improve plot output quality via [Cairo][]. [highr]: https://github.com/yihui/highr +[Cairo]: https://rforge.net/Cairo/ Formats ------- diff --git a/man/repr-options.Rd b/man/repr-options.Rd index a6e907e..6cb7fc8 100644 --- a/man/repr-options.Rd +++ b/man/repr-options.Rd @@ -50,7 +50,7 @@ Setting all options set to \code{NULL} are reset to defaults when reloading the \code{end} mainly exists for when you want a vertical line there (default: 'r|', 'l', and '') } \item{\code{repr.function.highlight}}{ - Use the \code{highr} package to insert highlighting instructions into the code? Needs that package to be installed. (default: FALSE) + Use the \code{highr} package to insert highlighting instructions into the code? (default: TRUE) } }