Skip to content

Commit

Permalink
version 1.26
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui authored and cran-robot committed Nov 12, 2019
1 parent a713891 commit b12cbb8
Show file tree
Hide file tree
Showing 48 changed files with 273 additions and 221 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: knitr
Type: Package
Title: A General-Purpose Package for Dynamic Report Generation in R
Version: 1.25
Version: 1.26
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person("Adam", "Vogt", role = "ctb"),
Expand Down Expand Up @@ -109,7 +109,7 @@ Suggests: formatR, testit, digest, rgl (>= 0.95.1201), codetools,
rmarkdown, htmlwidgets (>= 0.7), webshot, tikzDevice (>= 0.10),
tinytex, reticulate (>= 1.4), JuliaCall (>= 0.11.1), magick,
png, jpeg, gifski, xml2 (>= 1.2.0), httr, DBI (>= 0.4-1),
showtext, tibble, sass, styler
showtext, tibble, sass, styler (>= 1.2.0)
License: GPL
URL: https://yihui.name/knitr/
BugReports: https://github.com/yihui/knitr/issues
Expand All @@ -130,7 +130,7 @@ Collate: 'block.R' 'cache.R' 'utils.R' 'citation.R' 'hooks-html.R'
'utils-vignettes.R' 'zzz.R'
RoxygenNote: 6.1.1
NeedsCompilation: no
Packaged: 2019-09-17 13:24:32 UTC; yihui
Packaged: 2019-11-12 20:05:16 UTC; yihui
Author: Yihui Xie [aut, cre] (<https://orcid.org/0000-0003-0645-5666>),
Adam Vogt [ctb],
Alastair Andrew [ctb],
Expand Down Expand Up @@ -229,4 +229,4 @@ Author: Yihui Xie [aut, cre] (<https://orcid.org/0000-0003-0645-5666>),
Wush Wu [ctb],
Zachary Foster [ctb]
Repository: CRAN
Date/Publication: 2019-09-18 09:10:07 UTC
Date/Publication: 2019-11-12 21:00:02 UTC
94 changes: 47 additions & 47 deletions MD5
@@ -1,10 +1,10 @@
2cfb53c978738d6961835fe0a24360f3 *DESCRIPTION
92271eddf4e1e1ad77e06dfb6b7af664 *DESCRIPTION
a916831d30a070fdfc0ee680362a5e40 *NAMESPACE
33c703de02d6653651ac717fb150f49f *R/block.R
914d3f6b63f32a4ec06c8db64a9f611f *R/cache.R
9124992f2de8e645542919074ae8145e *R/citation.R
960615d4f13899f85aee4b07244df39f *R/citation.R
d3066cdaec8d60368dfa30093222ac88 *R/concordance.R
151fe5dc6f4f8cca67ba3ddb37c7dbd1 *R/defaults.R
705154341e67eb27680994ec685ab4b6 *R/defaults.R
063bbc5581a624aca0127cf614abc995 *R/engine.R
7bb8588a54afe6add2ed5d7742ee31c6 *R/header.R
e02a4e40986a42a8d4f3e08d6a7c22b7 *R/highlight.R
Expand All @@ -17,7 +17,7 @@ e54524651326164b24c42cc10923cb5e *R/hooks-md.R
be17cd3493a42bd2ca826c8f5ce82d73 *R/hooks-rst.R
06ac4a6bd4827959b1719892028bf4df *R/hooks-textile.R
48529fb31a21a6cf27b9cf89924d0dee *R/hooks.R
608bdd4b738ea7e6df8a6d596cec9128 *R/output.R
e47e3d37914b7695ead59e63e2d1b6db *R/output.R
1c6bec5eaed27eb45c44ea876cdec45f *R/package.R
36909798b502a1152bade8fc7f7a55e5 *R/pandoc.R
62a8271ab2bb4cb847b002d2735c5761 *R/params.R
Expand All @@ -35,7 +35,7 @@ b48c95e8eef8c8ad8a09a9d25119c670 *R/utils-rd2html.R
510cf9590cc804e006adf18552fde34a *R/utils-sweave.R
b698f55f469c38b3b21b4ed8191b38ac *R/utils-upload.R
4f4027f41fa98f2d70c54689273c44c7 *R/utils-vignettes.R
4c2060631b50e9fb0992d4858b0a6f49 *R/utils.R
279a74c69733ef5958d19e8526d968ee *R/utils.R
64580757ed828267f6976d73231f1f8f *R/zzz.R
e7e516bacd3923e52e48b8fda38d13dc *README.md
05a0d19a5ff6e0062f0978cb9cf7bac0 *build/vignette.rds
Expand All @@ -45,32 +45,32 @@ a95e58617a42ea5ea95fa99a10f1c120 *demo/notebook.R
068c2f0744f0181a83aeadd88d80ed2a *inst/CITATION
a70f6f982a3c3cc343b5db3f0bb90949 *inst/NEWS.Rd
4874a71c96d939a22aa11a3f6ee0c0df *inst/bin/knit
2e944bf7603da99fd4539f4fcdc394a0 *inst/doc/datatables.R
0a2620c902485a75cdad53208b5049c2 *inst/doc/datatables.R
4ab33a0b2c409210d1f8d2feff177b16 *inst/doc/datatables.Rmd
b7813b1fe75cac6649448fab76bf1bae *inst/doc/datatables.html
294a1bced1cf56fc690cfe68db997784 *inst/doc/docco-classic.R
f65d5ee8789ca5d827dfabdbfec7b881 *inst/doc/docco-classic.R
b47c340c4060c759ed158eeb0c258560 *inst/doc/docco-classic.Rmd
895ad93dfa4a9650ef4d47d10c33a197 *inst/doc/docco-classic.html
65c936899dfbbb5ea725beb9e11f6463 *inst/doc/docco-linear.R
47ce82368efd05f9c4d485d57affd5b4 *inst/doc/docco-classic.html
695167079b70ad2b94a46b258de380ad *inst/doc/docco-linear.R
77224ea1f36284bfe5b3aa7c2576a0f1 *inst/doc/docco-linear.Rmd
28e51a4d051d5c0682c14da0cc511f42 *inst/doc/docco-linear.html
d060cc6329c3b03347a61d5240cbb527 *inst/doc/knit_expand.R
57428b83d861130b495f5447bb3741ce *inst/doc/docco-linear.html
3e4b708e32004e6634e71a946d2b7d72 *inst/doc/knit_expand.R
45dec121925f328760fee414d1890168 *inst/doc/knit_expand.Rmd
cbb41dc16148f50c441a090ddf12f3d8 *inst/doc/knit_expand.html
7b4a69a47428141d7521f2e23f10ca21 *inst/doc/knit_print.R
a99a61b104d7172ce8efde7dd2e20e26 *inst/doc/knit_expand.html
ca1821ef3b3bcd502d10b3082f44d07e *inst/doc/knit_print.R
0e6b7d6e4e4903b5b227cf7535591809 *inst/doc/knit_print.Rmd
6f0c3dc1da1f6cd0ccfe56093db10b31 *inst/doc/knit_print.html
7c333d10e4255222789dda55dad958d8 *inst/doc/knitr-html.R
1ad7410d69c1c00a7c45e1746ea51a28 *inst/doc/knit_print.html
769d05c90e0867719cdee64025753b53 *inst/doc/knitr-html.R
824b923dd4a500fb460a2366aabfb19c *inst/doc/knitr-html.Rhtml
a94c617655817bb3cd2cebf28df042eb *inst/doc/knitr-html.html
97b83b9e94f5690f0dcce82bda0eef48 *inst/doc/knitr-intro.R
9e7029910e5758c05cd4a036151b630f *inst/doc/knitr-html.html
23404d775025e833ea59a5e08270fc0e *inst/doc/knitr-intro.R
c9c93ff46b0506f7facefc8de8edf09b *inst/doc/knitr-intro.Rmd
7bed83644e1416ea809050aa34fe18c4 *inst/doc/knitr-intro.html
aa3f1c19ae5b4ba70df72922f67996dc *inst/doc/knitr-markdown.R
a56f9db1bfc1aee9b749f8c1ad281b9b *inst/doc/knitr-intro.html
3c00ba068a4599f959ba80e7beb0c758 *inst/doc/knitr-markdown.R
3d047ff09d3b18b13466241cda178c57 *inst/doc/knitr-markdown.Rmd
f5ca7a757c0e59342cc77971857799a3 *inst/doc/knitr-markdown.html
55c12289eeb7594bcceee5b77ffb34b4 *inst/doc/knitr-markdown.html
fe4f84807839f4ec0b3514718daec3fa *inst/doc/knitr-refcard.Rmd
ece1db083d07a16e18908982e94b6fb9 *inst/doc/knitr-refcard.pdf
1da3e362c1c02d3118542f5f8daaa62c *inst/doc/knitr-refcard.pdf
f16d37ed927336b920c67ce2e958ffc5 *inst/examples/README.md
80d81165446ea535b4368b5f6375d7a1 *inst/examples/Sweavel.sty
5cc86725bad53543ab7cc881a2783269 *inst/examples/child/knitr-child-a.Rnw
Expand Down Expand Up @@ -218,84 +218,84 @@ c654ad3c4586084b795513343f0c8761 *inst/themes/xoria256.css
8bddde8d60970f665f04814529446c97 *inst/themes/zellner.css
7e4d9ef2703aa32dead65a39c2568fba *inst/themes/zenburn.css
c2abe08ea4638d3c157c8df34a621e47 *inst/themes/zmrok.css
2d5913483b36974cc60544418e963151 *man/Sweave2knitr.Rd
d39e5244f8740e9beb416d2275d23068 *man/Sweave2knitr.Rd
14bf04f27ca22d3a954deface50df448 *man/all_labels.Rd
c70ef32aed9098ab4174db8d3dc7b79d *man/all_patterns.Rd
9859878a0c29836090a732c000331e18 *man/asis_output.Rd
4f3628f0248537b9ce6a3e727977af76 *man/cache_engines.Rd
ae24c845fd9b2da0116d75ade8c720bd *man/cache_engines.Rd
a531bb4f5bffd67d01c7778139c459ec *man/chunk_hook.Rd
cbfff2380163f4c2a6bbc0922e53e7b9 *man/clean_cache.Rd
d7f43cbbfa899a761417e52eb40874f3 *man/combine_words.Rd
8cd89220aa97a0383deb2b3385c75ae7 *man/combine_words.Rd
3dee5c437d1d13266ec49f3673fdf704 *man/current_input.Rd
4089e143f53d3843ded53eece7d40b73 *man/dep_auto.Rd
15516b8f520f77e7a7c42c0c518ea36f *man/dep_prev.Rd
73d44ea427ddebf742bc8ac73ff014be *man/engine_output.Rd
fc81570acbdda941dd826106425ea169 *man/fig_chunk.Rd
2ebab2eb2ad1e57c9c038c7c75f3049e *man/fig_chunk.Rd
179291efb7710a81573c18a6b940a4a2 *man/fig_path.Rd
c82f1d2262daf76e9860d87eb7362d9e *man/hook_animation.Rd
22f3d921c032294cb90cd78961ebdb94 *man/hook_document.Rd
cb308199c822d4a9ece7cd91f4890db5 *man/hook_plot.Rd
4fd96407b5a75afba7aa72296e1af155 *man/image_uri.Rd
d019b31ef0072e36aa16bbe53f847d98 *man/imgur_upload.Rd
d31b552d1b1c76c22d7f63b59fe914ee *man/include_graphics.Rd
76e29828a0273e301eac9cf605c3df40 *man/include_graphics.Rd
0608d288357ff740bbfd0e7be24d41ba *man/include_url.Rd
339b19fe49695c2640a3876542a13142 *man/inline_expr.Rd
d692c18f4666c96592bf24bc01817632 *man/kable.Rd
16c473bfa3e7ad377fddeca4c406fe68 *man/knit.Rd
4d3482809a4facaa7d649e4ec2ce8312 *man/knit2html.Rd
aac6a1b8e4988d6e632cb1cd31311bc7 *man/knit2pandoc.Rd
cb1d4eac5836d987f9a57736c043fd89 *man/knit2pdf.Rd
2df156330096786414181bb25ed2fc3b *man/knit2wp.Rd
0831730831390d2f8636a72d54fbdcc7 *man/kable.Rd
2c243c45a05c55a3e2eb7bd4a5efe7ad *man/knit.Rd
2f0dbcdb096cd380a23b413844906e03 *man/knit2html.Rd
20e8cacd31483a78dcdf531e93ffdc61 *man/knit2pandoc.Rd
c67ba376bf3b79731749e6403b5e9184 *man/knit2pdf.Rd
1a94b57c721eea83bbc0356d91647320 *man/knit2wp.Rd
a6d8bb0d14cc903dea44a1368e4213ea *man/knit_child.Rd
0fc312f4ab4ad512927b6ab3de5233f9 *man/knit_code.Rd
6b55b643f0387d438a28a9c2d954dfbd *man/knit_engines.Rd
11e9ed773e71b24c8293365da99b8f0c *man/knit_code.Rd
54f80cda15b1641be0c1f8398e88593b *man/knit_engines.Rd
9c461debed03e8f272772fb0d830b993 *man/knit_exit.Rd
3826ce847f95b5428a47db6c7afcb2e5 *man/knit_expand.Rd
b5df5547ccc6d3f935bb8f151990ae89 *man/knit_filter.Rd
4728d146be77e9f68d28b8b668b988d8 *man/knit_global.Rd
211e8b8f5d9c584e04591a8e9c8b8d5b *man/knit_hooks.Rd
915e1c8afe702369f7462b3e044aca20 *man/knit_hooks.Rd
b2d78a6ff6ce8a7e7f9eb936617113af *man/knit_meta.Rd
3faa957f12dff93a25aec26ed67092e2 *man/knit_params.Rd
f7bce4fc3089f38ff25c7bb1fdc64103 *man/knit_params_yaml.Rd
75b9d3bef5989572feae37b800f8ebf2 *man/knit_patterns.Rd
e33cb6c16dff794493472b4e08c296ed *man/knit_patterns.Rd
d7ba3d10fb9c473dab6ea707ee9aa22f *man/knit_print.Rd
99f46046459d8b2a7dafa95e807212d8 *man/knit_rd.Rd
08152afd6ff33447d2b62f612e510dda *man/knit_theme.Rd
ab6fc290e2abcd38db22c0952c13aeec *man/knit_watch.Rd
88eedf87ad7dd45ea43c8874fad40ec9 *man/knitr-package.Rd
9691ac6f3e2557c035510c1d9b95da0b *man/load_cache.Rd
0bb6a3b5fb89ed2d82175df8a5542fd8 *man/opts_chunk.Rd
de23f365059434fcdd4aeb591d3386c2 *man/opts_hooks.Rd
71effb0ea9c15156fa2becb3981c60db *man/opts_knit.Rd
2af2b65d4abe1d2bf540ba2e17f00375 *man/opts_template.Rd
3306bf8e7e7efc7f2feee5a116baf031 *man/output_hooks.Rd
95c6d58b9a8c7b83d5a87d37b373b27a *man/load_cache.Rd
fa4b0f36fd548537b6dbee2d84a34bfa *man/opts_chunk.Rd
8fafce6b8e5b9f03a26fc6a2ebb92eba *man/opts_hooks.Rd
547134b3d216564d3a6ebbd0e48f45fe *man/opts_knit.Rd
4c15615f81d431b877f6f58138f86477 *man/opts_template.Rd
23344833b05e9e16a944c2487679cfc6 *man/output_hooks.Rd
3f2f30f826b20af7469068479be40fe9 *man/output_type.Rd
4d3b988bccdba42c3e4a6ad98e114fd7 *man/pandoc.Rd
1fcc7272717b8080bad4391e05eeb041 *man/pat_fun.Rd
a5428ea44f54e284f6fcdf80e94d1beb *man/plot_crop.Rd
ecdeff784f0a76d326d97a5b54ed978d *man/rand_seed.Rd
b43ff2da7af3008a4700920732f7b40b *man/raw_block.Rd
95b9e03619feb2645252eb606f306975 *man/raw_output.Rd
1f9d460942bf78ef4cf470957be4c8e0 *man/read_chunk.Rd
1004c40a9bdb25b68e90ffb42ed7b4dc *man/read_chunk.Rd
daef4bc697911d95d764a21244d746fe *man/read_rforge.Rd
a210c81cd4930dae4b6709e37594ec28 *man/rocco.Rd
4c425df2766facb4d55fe47f3e46322a *man/rst2pdf.Rd
3695a685eb7c349e0706982088ee9145 *man/set_alias.Rd
18c2e647c5a8746c7d5a2dbe0131254d *man/set_header.Rd
bb9e7e0e33839acc5e7ccb2ac972e801 *man/set_parent.Rd
a313a0c9c22113e061194ea4bddee96d *man/spin.Rd
71d2894496476c20436e5591360e6323 *man/spin.Rd
a302e6837904fefe1e6daa53c38df637 *man/spin_child.Rd
0f28f574d5fd97a741114e09cb19a698 *man/stitch.Rd
328906a9070f92628772e46147e7faa6 *man/stitch.Rd
0b967b4dd4e395ad764a24cd75b02204 *man/vignette_engines.Rd
6e89223cbccc5ee17cdc93070b25157e *man/wrap_rmd.Rd
f69fd33f31f3571f492c3ee834cfbf68 *man/write_bib.Rd
225a652d28dedca120de766c27169453 *man/write_bib.Rd
c9999baf2feaa9582fff2870c8a3260d *tests/run-all.R
35da2267d10aa1b44bbec536cf869169 *tests/testit/acid.style
29b3efe2fa7fd7537cd0b03c0e0c41e7 *tests/testit/knit-envir.Rmd
409a303e08ceca7233025326046382a3 *tests/testit/knit-tikzDevice.Rnw
35389910ee6b641a0e0b81e6f009159e *tests/testit/test-cache.R
621fafe6a1a958b26529fc59594bcff9 *tests/testit/test-citation.R
ba9e0aebd2d9410a5178456e7d2c68d1 *tests/testit/test-closure.R
8434ccf049db2d30d2795e1a605db098 *tests/testit/test-closure.R
f2dc0de6ec9d0c4159c4d2673301d4da *tests/testit/test-envir.R
644350f692d3d8f1b53f426d81758aee *tests/testit/test-hooks-md.R
746feb029c17f799b23b1ec8b01d1825 *tests/testit/test-output.R
Expand Down
69 changes: 47 additions & 22 deletions R/citation.R
Expand Up @@ -2,33 +2,29 @@
#'
#' This function uses \code{\link[utils]{citation}} and
#' \code{\link[utils]{toBibtex}} to create bib entries for R packages and write
#' them in a file. Only the auto-generated citations are included for a package.
#' This function can facilitate the auto-generation of bibliography databases
#' for R packages, and it is easy to regenerate all the citations after updating
#' R packages.
#' them in a file. It can facilitate the auto-generation of bibliography
#' databases for R packages, and it is easy to regenerate all the citations
#' after updating R packages.
#'
#' The citation is forced to be generated from the \file{DESCRIPTION} file of
#' the package (\code{citation(auto = TRUE)}). The keyword \samp{R-pkgname} is
#' used for the bib item, where \samp{pkgname} is the name of the package. All
#' references specified in the \file{CITATION} file of the package are ignored.
#' The main purpose of this function is to automate the generation of the
#' package citation information because it often changes (e.g. author, year,
#' package version, ...). By comparison, paper/book citations don't change too
#' often, so it is not a lot of work even if you just cut and paste such
#' bibliography entries from \code{toBibtex(citation())}.
#' For a package, the keyword \samp{R-pkgname} is used for its bib item, where
#' \samp{pkgname} is the name of the package. Citation entries specified in the
#' \file{CITATION} file of the package are also included. The main purpose of
#' this function is to automate the generation of the package citation
#' information because it often changes (e.g. author, year, package version,
#' ...).
#'
#' @param x Package names. Packages which are not installed are ignored.
#' @param file The (\file{.bib}) file to write. By default, or if \code{NULL},
#' output is written to the R console.
#' @param tweak Whether to fix some known problems in the citations, especially
#' non-standard format of author names.
#' @param width Width of lines in bibliography entries. If \code{NULL},
#' lines will not be wrapped.
#' @param width Width of lines in bibliography entries. If \code{NULL}, lines
#' will not be wrapped.
#' @param prefix Prefix string for keys in BibTeX entries; by default, it is
#' \samp{R-} unless \code{\link{option}('knitr.bib.prefix')} has been set to
#' another string.
#' @return A list containing the citations. Citations are also written to the \code{file} as a
#' side effect.
#' @return A list containing the citations. Citations are also written to the
#' \code{file} as a side effect.
#' @note Some packages on CRAN do not have standard bib entries, which was once
#' reported by Michael Friendly at
#' \url{https://stat.ethz.ch/pipermail/r-devel/2010-November/058977.html}. I
Expand Down Expand Up @@ -69,6 +65,7 @@ write_bib = function(
x = x[!idx]
}
x = setdiff(x, .base.pkgs) # remove base packages
x = sort(x)
bib = sapply(x, function(pkg) {
cite = citation(pkg, auto = if (pkg == 'base') NULL else TRUE)
if (tweak) {
Expand All @@ -88,14 +85,42 @@ write_bib = function(
}
bib = lapply(bib, function(b) {
b['author'] = sub('Duncan Temple Lang', 'Duncan {Temple Lang}', b['author'])
b['title'] = sub("'RStudio'", 'RStudio', b['title'])
# remove the ugly single quotes required by CRAN policy
b['title'] = gsub(
"'(RStudio|Htmlwidgets|iframes|TeX Live|LaTeX)'", '\\1', b['title']
)
if (!('year' %in% names(b))) b['year'] = .this.year
idx = which(names(b) == '')
if (!is.null(width)) b[-idx] = stringr::str_wrap(b[-idx], width, 2, 4)
structure(c(b[idx[1L]], b[-idx], b[idx[2L]]), class = 'Bibtex')
b
})
}
bib = bib[sort(x)]
# also read citation entries from the CITATION file if provided
bib2 = lapply(x, function(pkg) {
if (pkg == 'base') return()
if (system.file('CITATION', package = pkg) == '') return()
cites = citation(pkg, auto = FALSE)
cites = Filter(x = cites, function(cite) {
# exclude entries identical to citation(pkg, auto = TRUE)
!isTRUE(grepl('R package version', cite$note))
})
s = make_unique(unlist(lapply(cites, function(cite) {
if (is.null(cite$year)) format(Sys.Date(), '%Y') else cite$year
})))
mapply(cites, s, FUN = function(cite, suffix) {
# the entry is likely to be the same as citation(pkg, auto = TRUE)
if (isTRUE(grepl('R package version', cite$note))) return()
entry = toBibtex(cite)
entry[1] = sub('\\{,$', sprintf('{%s%s,', pkg, suffix), entry[1])
entry
}, SIMPLIFY = FALSE)
})
# TODO: remove this hack once https://github.com/mitchelloharawild/vitae/pull/91 is merged
if (is_R_CMD_check() && all(c('package:testthat', 'package:vitae') %in% search())) bib2 = NULL
bib = c(bib, unlist(bib2, recursive = FALSE))
bib = lapply(bib, function(b) {
idx = which(names(b) == '')
if (!is.null(width)) b[-idx] = stringr::str_wrap(b[-idx], width, 2, 4)
structure(c(b[idx[1L]], b[-idx], b[idx[2L]]), class = 'Bibtex')
})
if (!is.null(file) && length(x)) write_utf8(unlist(bib), file)
invisible(bib)
}
Expand Down
12 changes: 9 additions & 3 deletions R/defaults.R
Expand Up @@ -23,6 +23,9 @@ new_defaults = function(value = list()) {
if (length(dots)) defaults <<- merge(dots)
invisible(NULL)
}
delete = function(keys) {
for (k in keys) defaults[[k]] <<- NULL
}
merge = function(values) merge_list(defaults, values)
restore = function(target = value) defaults <<- target
append = function(...) {
Expand All @@ -32,7 +35,10 @@ new_defaults = function(value = list()) {
invisible(NULL)
}

list(get = get, set = set, append = append, merge = merge, restore = restore)
list(
get = get, set = set, delete = delete,
append = append, merge = merge, restore = restore
)
}

#' Default and current chunk options
Expand Down Expand Up @@ -158,7 +164,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 +179,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
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
12 changes: 12 additions & 0 deletions R/utils.R
Expand Up @@ -968,3 +968,15 @@ digest3 = function(x) {

# collapse by \n
one_string = function(x, ...) paste(x, ..., collapse = '\n')

# c(1, 1, 1, 2, 3, 3) -> c(1a, 1b, 1c, 2a, 3a, 3b)
make_unique = function(x) {
if (length(x) == 0) return(x)
x2 = make.unique(x)
if (all(i <- x2 == x)) return(x)
x2[i] = paste0(x2[i], '.0')
i = as.numeric(sub('.*[.]([0-9]+)$', '\\1', x2)) + 1
s = letters[i]
s = ifelse(is.na(s), i, s)
paste0(x, s)
}

0 comments on commit b12cbb8

Please sign in to comment.