diff --git a/NAMESPACE b/NAMESPACE index ef18480..8b39488 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,6 +16,7 @@ export(hl_grep) export(hl_opts) export(is_emphatic) export(knit_print.emphatic) +export(show_html) export(write_xlsx) importFrom(grDevices,col2rgb) importFrom(grDevices,convertColor) diff --git a/R/core-html.R b/R/core-html.R index da31d3b..158b560 100644 --- a/R/core-html.R +++ b/R/core-html.R @@ -157,6 +157,7 @@ as_html <- function(x, ..., style = NULL, complete = FALSE, browsable = FALSE) { #' @param viewer function which activates viewer #' @return None #' @export +#' @examples #' # Will try and spawn a viewer for content #' hl_grep(mode, "switch") |> #' as_html() |> diff --git a/R/zzz.R b/R/zzz.R index bcaf8d5..61c3d9a 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -67,13 +67,13 @@ get_env_dbl <- function(nm, unset) { #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .onLoad <- function(libname, pkgname) { - options(HL_NA = Sys.getenv ("HL_NA" , unset = 'NA')) - options(HL_TEXT_MODE = Sys.getenv ("HL_TEXT_MODE" , unset = 'contrast')) - options(HL_TEXT_CONTRAST = get_env_dbl("HL_TEXT_CONTRAST", unset = 1)) - options(HL_GREP_COL = Sys.getenv("HL_GREP_COL" , unset = "#0F19F0")) - options(HL_SUB_COL = Sys.getenv("HL_SUB_COL" , unset = "dodgerblue")) - options(HL_INS_COL = Sys.getenv("HL_INS_COL" , unset = "darkgreen")) - options(HL_DEL_COL = Sys.getenv("HL_DEL_COL" , unset = "firebrick")) + options(HL_NA = Sys.getenv ("HL_NA" , unset = 'NA')) + options(HL_TEXT_MODE = Sys.getenv ("HL_TEXT_MODE" , unset = 'contrast')) + options(HL_TEXT_CONTRAST = get_env_dbl("HL_TEXT_CONTRAST", unset = 1)) + options(HL_GREP_COL = Sys.getenv("HL_GREP_COL" , unset = "yellow")) + options(HL_SUB_COL = Sys.getenv("HL_SUB_COL" , unset = "darkslategray1")) + options(HL_INS_COL = Sys.getenv("HL_INS_COL" , unset = "palegreen1")) + options(HL_DEL_COL = Sys.getenv("HL_DEL_COL" , unset = "rosybrown1")) # Is this the Rstudio 256 colour console? rstudio_256 <- Sys.getenv("RSTUDIO_CONSOLE_COLOR", 0) == 256 diff --git a/README.Rmd b/README.Rmd index 98168a8..a07c9ce 100644 --- a/README.Rmd +++ b/README.Rmd @@ -328,7 +328,7 @@ writeLines(svg, "data-raw/figures/example-svg-anim.svg") | | `"remove"` remove all text without a user-defined colour | | `HL_TEXT_CONTRAST` | When `text_mode = "contrast"` this numeric value (in range [0, 1]) adjusts the visibility of the text. Default: 1 (high contrast) | | `HL_GREP_COL` |The fill colour to use with `hl_grep()` if no colour is specified. Default: "#0F19F0"| -| `HL_SUB_COL`, `HL_INS_COL`, `HL_DEL_COL` | the default colours to use with `hl_diff()` for substitution, insertion and deletion (respectively). Defaults: `dodgerblue` (substitute), `darkgreen` (insert) and `firebrick` (delete) | +| `HL_SUB_COL`, `HL_INS_COL`, `HL_DEL_COL` | the default colours to use with `hl_diff()` for substitution, insertion and deletion (respectively). | ## Vignettes diff --git a/README.md b/README.md index 8219e90..b72c1ae 100644 --- a/README.md +++ b/README.md @@ -190,17 +190,17 @@ svg <- as_svg_anim(objs, width = 600, height = 300, duration = 2, `.Rprofile` - `options(HL_NA = FALSE)` at any time -| Option | Description | -|:-----------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `HL_NA` | String to use for NA values. Default “NA” | -| `HL_FULL_COLOUR` | Should full colour ANSI codes be used when outputting to the console? Default: FALSE on Rstudio, but TRUE on all other R consoles | -| `HL_TEXT_MODE` | How to handle text if no text colour has been explicitly specified by the user | -| | `"contrast"` (default) automatically select a colour which contrasts with the background | -| | `"asis"` do not change the colour from the console’s default | -| | `"remove"` remove all text without a user-defined colour | -| `HL_TEXT_CONTRAST` | When `text_mode = "contrast"` this numeric value (in range \[0, 1\]) adjusts the visibility of the text. Default: 1 (high contrast) | -| `HL_GREP_COL` | The fill colour to use with `hl_grep()` if no colour is specified. Default: “\#0F19F0” | -| `HL_SUB_COL`, `HL_INS_COL`, `HL_DEL_COL` | the default colours to use with `hl_diff()` for substitution, insertion and deletion (respectively). Defaults: `dodgerblue` (substitute), `darkgreen` (insert) and `firebrick` (delete) | +| Option | Description | +|:-----------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------| +| `HL_NA` | String to use for NA values. Default “NA” | +| `HL_FULL_COLOUR` | Should full colour ANSI codes be used when outputting to the console? Default: FALSE on Rstudio, but TRUE on all other R consoles | +| `HL_TEXT_MODE` | How to handle text if no text colour has been explicitly specified by the user | +| | `"contrast"` (default) automatically select a colour which contrasts with the background | +| | `"asis"` do not change the colour from the console’s default | +| | `"remove"` remove all text without a user-defined colour | +| `HL_TEXT_CONTRAST` | When `text_mode = "contrast"` this numeric value (in range \[0, 1\]) adjusts the visibility of the text. Default: 1 (high contrast) | +| `HL_GREP_COL` | The fill colour to use with `hl_grep()` if no colour is specified. Default: “\#0F19F0” | +| `HL_SUB_COL`, `HL_INS_COL`, `HL_DEL_COL` | the default colours to use with `hl_diff()` for substitution, insertion and deletion (respectively). | ## Vignettes diff --git a/data-raw/figures/example-hlgrep-1.svg b/data-raw/figures/example-hlgrep-1.svg index d00e754..47bbd52 100644 --- a/data-raw/figures/example-hlgrep-1.svg +++ b/data-raw/figures/example-hlgrep-1.svg @@ -6,7 +6,7 @@ Encyclopedia Britannica in storage at the Lindbergh Palace Hotel under the names Ari and Uzi Tenenbaum. No-one spoke at the funeral, and Father Petersen's leg had not yet mended, but it was agreed among them that Royal -would have found the event to be most satisfactory. +would have found the event to be most satisfactory. [Chas, now wearing a black Adidas tracksuit, nods to his sons] diff --git a/data-raw/figures/example-hlgrep-2.svg b/data-raw/figures/example-hlgrep-2.svg index 5c279c3..3d092a5 100644 --- a/data-raw/figures/example-hlgrep-2.svg +++ b/data-raw/figures/example-hlgrep-2.svg @@ -7,13 +7,13 @@ if (is.expression(x)) return("expression") if (is.call(x)) - return(switch(deparse(x[[1L]])[1L], `(` = "(", "call")) + return(switch(deparse(x[[1L]])[1L], `(` = "(", "call")) if (is.name(x)) "name" - else switch(tx <- typeof(x), double = , integer = "numeric", + else switch(tx <- typeof(x), double = , integer = "numeric", closure = , builtin = , special = "function", tx) } -<bytecode: 0x12cc16ee8> +<bytecode: 0x112fb3a70> <environment: namespace:base> diff --git a/data-raw/figures/example-strdiff-3.svg b/data-raw/figures/example-strdiff-3.svg index 2c2b391..1099335 100644 --- a/data-raw/figures/example-strdiff-3.svg +++ b/data-raw/figures/example-strdiff-3.svg @@ -2,7 +2,7 @@
-
[1] "    Paris in the the spring?"
[1] "Not Paris in the spring!"
+
[1] "    Paris in the the spring?"
[1] "Not Paris in the spring!"
diff --git a/data-raw/figures/example-strdiff-4.svg b/data-raw/figures/example-strdiff-4.svg index 81d2d76..2a221d4 100644 --- a/data-raw/figures/example-strdiff-4.svg +++ b/data-raw/figures/example-strdiff-4.svg @@ -2,13 +2,13 @@
-
function (x               , ...) 
-UseMethod("me  an")
-<bytecode: 0x12b551f28 >
-<environment: namespace:b a se>

function (x, na.rm = FALSE, ...) -UseMethod("median") -<bytecode: 0x12b43e 2d0> -<environment: namespace:stats >
+
function (x               , ...) 
+UseMethod("me  an")
+<bytecode: 0x106191448 >
+<environment: namespace:b a se>

function (x, na.rm = FALSE, ...) +UseMethod("median") +<bytecode: 0x1221f 47f0> +<environment: namespace:stats >
diff --git a/data-raw/figures/example-svg-anim.svg b/data-raw/figures/example-svg-anim.svg index 98bde68..9b81b13 100644 --- a/data-raw/figures/example-svg-anim.svg +++ b/data-raw/figures/example-svg-anim.svg @@ -2,7 +2,7 @@
-
[1] " hello"
[1] "there "
+
[1] " hello"
[1] "there "
-
[1] "good b ye"
[1] "good boy "
+
[1] "good b ye"
[1] "good boy "
+ as_html() |> + show_html() +}