Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use highr by default and depend on it #77

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Depends:
R (>= 3.0.1)
Imports:
utils,
grDevices
grDevices,
highr
Suggests:
methods,
highr,
Cairo,
testthat
Enhances: data.table, dplyr, htmlwidgets
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions R/options.r
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#' }
#'
#' }
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions R/repr_function.r
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------
Expand Down
2 changes: 1 addition & 1 deletion man/repr-options.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.