Skip to content

Commit

Permalink
remove the option width from opts_knit, and don't change options(wi…
Browse files Browse the repository at this point in the history
…dth) in knit() (i.e. respect user's width option)
  • Loading branch information
yihui committed Sep 18, 2019
1 parent b79403b commit 11ddfc6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: knitr
Type: Package
Title: A General-Purpose Package for Dynamic Report Generation in R
Version: 1.25
Version: 1.25.1
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Adam", "Vogt", role = "ctb"),
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# CHANGES IN knitr VERSION 1.26

## MINOR CHANGES

- `knit()` no longer adjusts the global R option `width`; previously it sets `options(width = 75)` by default.

# CHANGES IN knitr VERSION 1.25

## NEW FEATURES
Expand Down
4 changes: 2 additions & 2 deletions R/defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ set_alias = function(...) {
#' }
#' @include hooks-html.R
opts_knit = new_defaults(list(
progress = TRUE, verbose = FALSE, width = 75L, eval.after = 'fig.cap',
progress = TRUE, verbose = FALSE, eval.after = 'fig.cap',
base.dir = NULL, base.url = NULL, root.dir = NULL, child.path = '',
upload.fun = identity, global.device = FALSE, global.par = FALSE,
concordance = FALSE, documentation = 1L, self.contained = TRUE,
Expand All @@ -173,7 +173,7 @@ opts_knit = new_defaults(list(

# you may modify these options in options(knitr.package.foo)
opts_knit_names = c(
'progress', 'verbose', 'width', 'upload.fun', 'animation.fun', 'global.device',
'progress', 'verbose', 'upload.fun', 'animation.fun', 'global.device',
'eval.after', 'concordance', 'documentation', 'aliases', 'self.contained',
'unnamed.chunk.label'
)
Expand Down
5 changes: 2 additions & 3 deletions R/output.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ knit = function(
knit_log$restore()
on.exit(chunk_counter(reset = TRUE), add = TRUE) # restore counter
adjust_opts_knit()
# turn off fancy quotes, use smaller width
# turn off fancy quotes, use a null pdf device to record graphics
oopts = options(
useFancyQuotes = FALSE, width = opts_knit$get('width'),
knitr.in.progress = TRUE, device = pdf_null
useFancyQuotes = FALSE, device = pdf_null, knitr.in.progress = TRUE
)
on.exit(options(oopts), add = TRUE)
# restore chunk options after parent exits
Expand Down

0 comments on commit 11ddfc6

Please sign in to comment.