diff --git a/DESCRIPTION b/DESCRIPTION index 8d2ddce8a8..13396eee8e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: knitr Type: Package Title: A General-Purpose Package for Dynamic Report Generation in R -Version: 1.43.2 +Version: 1.43.3 Authors@R: c( person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")), person("Abhraneel", "Sarma", role = "ctb"), @@ -152,6 +152,7 @@ Suggests: tinytex, webshot, rstudioapi, + svglite, xml2 (>= 1.2.0) License: GPL URL: https://yihui.org/knitr/ diff --git a/NEWS.md b/NEWS.md index 9d4e476499..f834c22692 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ - Fixed a bug in `spin(format = 'Rnw')` reported by @Tarious14 at https://github.com/yihui/yihui.org/discussions/769#discussioncomment-6587927 +- When the chunk option `dev = 'svglite'`, the `svglite` device should be used to record plots (thanks, @Darxor, #2272). + # CHANGES IN knitr VERSION 1.43 ## NEW FEATURES diff --git a/R/block.R b/R/block.R index 5f84875357..db473aa023 100644 --- a/R/block.R +++ b/R/block.R @@ -403,6 +403,10 @@ chunk_device = function(options, record = TRUE, tmp = tempfile()) { do.call(grDevices::svg, c(list( filename = tmp, width = width, height = height ), get_dargs(dev.args, 'svg'))) + } else if (identical(dev, 'svglite')) { + do.call(svglite::svglite, c(list( + filename = tmp, width = width, height = height + ), get_dargs(dev.args, 'svglite'))) } else if (identical(getOption('device'), pdf_null)) { if (!is.null(dev.args)) { dev.args = get_dargs(dev.args, 'pdf')