Skip to content

Commit

Permalink
version 1.15.1
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui authored and cran-robot committed Nov 22, 2016
1 parent 211607c commit be08fa0
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 69 deletions.
12 changes: 7 additions & 5 deletions DESCRIPTION
@@ -1,8 +1,8 @@
Package: knitr
Type: Package
Title: A General-Purpose Package for Dynamic Report Generation in R
Version: 1.15
Date: 2016-11-09
Version: 1.15.1
Date: 2016-11-22
Authors@R: c(
person("Yihui", "Xie", email = "xie@yihui.name", role = c("aut", "cre")),
person("Adam", "Vogt", role = "ctb"),
Expand Down Expand Up @@ -45,6 +45,7 @@ Authors@R: c(
person("Joseph", "Larmarange", role = "ctb"),
person("Julien", "Barnier", role = "ctb"),
person("Kaiyin", "Zhong", role = "ctb"),
person("Kamil", "Slowikowski", role = "ctb"),
person(c("Kevin", "K."), "Smith", role = "ctb"),
person("Kirill", "Mueller", role = "ctb"),
person("Kohske", "Takahashi", role = "ctb"),
Expand Down Expand Up @@ -79,7 +80,7 @@ Description: Provides a general-purpose tool for dynamic report generation in R
using Literate Programming techniques.
Depends: R (>= 3.1.0)
Imports: evaluate (>= 0.10), digest, highr, markdown, stringr (>= 0.6),
yaml (>= 2.1.5), methods, tools
yaml, methods, tools
Suggests: formatR, testit, rgl (>= 0.95.1201), codetools, rmarkdown,
htmlwidgets (>= 0.7), webshot, tikzDevice (>= 0.10), png, jpeg,
XML, RCurl, DBI (>= 0.4-1), tibble
Expand All @@ -102,7 +103,7 @@ Collate: 'block.R' 'cache.R' 'utils.R' 'citation.R' 'hooks-html.R'
'utils-vignettes.R' 'zzz.R'
RoxygenNote: 5.0.1
NeedsCompilation: no
Packaged: 2016-11-08 23:46:37 UTC; yihui
Packaged: 2016-11-22 05:33:02 UTC; yihui
Author: Yihui Xie [aut, cre],
Adam Vogt [ctb],
Alastair Andrew [ctb],
Expand Down Expand Up @@ -146,6 +147,7 @@ Author: Yihui Xie [aut, cre],
Joseph Larmarange [ctb],
Julien Barnier [ctb],
Kaiyin Zhong [ctb],
Kamil Slowikowski [ctb],
Kevin K. Smith [ctb],
Kirill Mueller [ctb],
Kohske Takahashi [ctb],
Expand Down Expand Up @@ -175,4 +177,4 @@ Author: Yihui Xie [aut, cre],
Wush Wu [ctb],
Zachary Foster [ctb]
Repository: CRAN
Date/Publication: 2016-11-09 18:28:52
Date/Publication: 2016-11-22 09:36:46
30 changes: 15 additions & 15 deletions MD5
@@ -1,16 +1,16 @@
6c01175105eb2c5db4b4efc56826b710 *DESCRIPTION
54b1c3f9e6b195d59baf287211d779af *NAMESPACE
2a6b600badb2dc10730df2a1efec9f18 *R/block.R
b0acd6b4402bebffe304e38ea3eb80e9 *DESCRIPTION
37621070683a68a4bc227566e0a03721 *NAMESPACE
2020a5be55f21396e99866ad276388cb *R/block.R
397799b33f6c92366eb231e7064b368b *R/cache.R
6da551afb249af398702fec5ff4e537c *R/citation.R
f4de17ed656fa9124cce2e7429e27d6a *R/citation.R
d3066cdaec8d60368dfa30093222ac88 *R/concordance.R
dcd2c08d9ce1917ce089d8578cb40457 *R/defaults.R
1b2ae89a5a503c719b93d7fc00866471 *R/engine.R
77b340611c485589d7441d395852defe *R/engine.R
44370920d24fd560ceeb3f5985c83215 *R/header.R
e36c54d9b272ea1245ab8e0bcba9c8a1 *R/highlight.R
ef19e925acc44824076bc6eb2dfc50aa *R/hooks-asciidoc.R
ad8783b17b5906fc6c07f09f4d296f7b *R/hooks-chunk.R
22921f2a49542ae19e31e742f9a7392b *R/hooks-extra.R
be602dec68f60269d7d9bb0c06c2d3a7 *R/hooks-extra.R
e4ada63ee08edeb85d8989d51407edad *R/hooks-html.R
209d5b0c6fcf3e44d6bff450f3d3662f *R/hooks-latex.R
692badbd7b542004c8d6f23618bc7d3a *R/hooks-md.R
Expand All @@ -20,7 +20,7 @@ e4ada63ee08edeb85d8989d51407edad *R/hooks-html.R
e257dc01156580249316cb45eed9018e *R/output.R
21ce69e8540725f8206050bc4e71ea3c *R/package.R
dbfc00595b8621af0cb83c20274ed99f *R/pandoc.R
4f2a820f12d00290dc4977bc0539ba9c *R/params.R
bfffd7d37228dba6fc19745f53a7a608 *R/params.R
1eea1417232ec06100f9c58fefc10622 *R/parser.R
40a3f7837f7cceecd189b0fb2a396152 *R/pattern.R
d4246a8aa0b1e2ebdea43123149a1f3a *R/plot.R
Expand All @@ -37,8 +37,8 @@ cef5bab6cd92a77e0dbe91d5f8235098 *R/utils-base64.R
18927d3734faccb549ae7a93c038f664 *R/utils-vignettes.R
70a9b341689125a0de4c2c0edb887329 *R/utils.R
64580757ed828267f6976d73231f1f8f *R/zzz.R
d651706f6a72d80af95501d5d3ca6c68 *README.md
c7a70576b151bb14f645d053c262bed1 *build/knitr.pdf
d341508952d70b263d2c079e2b9e4424 *README.md
5df8c6a245231c66b4543f6c82d34bb0 *build/knitr.pdf
c5617fe42ca44b01644e6da5e63774cd *build/vignette.rds
5320cec79c972798fe0eb5579eb51927 *demo/00Index
a0d48f6ce89f9e1d39ee7248ff8c5511 *demo/gwidgets.R
Expand All @@ -57,21 +57,21 @@ b47c340c4060c759ed158eeb0c258560 *inst/doc/docco-classic.Rmd
0a3c5c8a96824d354a8573aa1e5a7e75 *inst/doc/docco-linear.html
d060cc6329c3b03347a61d5240cbb527 *inst/doc/knit_expand.R
45dec121925f328760fee414d1890168 *inst/doc/knit_expand.Rmd
d52aedfffc7ae585ada632f5bcc35cee *inst/doc/knit_expand.html
d16dc4b606ff71296097a82cd2b58455 *inst/doc/knit_expand.html
4eea99d3bf4431c606eacdf79713ded6 *inst/doc/knit_print.R
c90ac685808dfe85c05d21191dfe36a8 *inst/doc/knit_print.Rmd
a170fcfc48598cf0e163e1647ab8eb86 *inst/doc/knit_print.html
e6f43dfed1f856b04612e1b31a292ec9 *inst/doc/knit_print.html
7c333d10e4255222789dda55dad958d8 *inst/doc/knitr-html.R
824b923dd4a500fb460a2366aabfb19c *inst/doc/knitr-html.Rhtml
8a8a2edbfa2ae3c06f8a335fd22d1c2e *inst/doc/knitr-html.html
97b83b9e94f5690f0dcce82bda0eef48 *inst/doc/knitr-intro.R
fa0189ffab9ee6f23ebf599740a16ddb *inst/doc/knitr-intro.Rmd
3ef6e0359ea52a0f7700ae75749eef79 *inst/doc/knitr-intro.html
a004b0626171a81e690ebce02eebe371 *inst/doc/knitr-intro.html
aa3f1c19ae5b4ba70df72922f67996dc *inst/doc/knitr-markdown.R
3d047ff09d3b18b13466241cda178c57 *inst/doc/knitr-markdown.Rmd
4be2b0349f6a8c65564bc26b4d695eae *inst/doc/knitr-markdown.html
d61323ff5fbf6706eb21c9aec6bfa29c *inst/doc/knitr-markdown.html
b41a48fcc33fd13fcb30ff44bb644b03 *inst/doc/knitr-refcard.Rmd
86131bc39933175e6c519c8da9f8d11e *inst/doc/knitr-refcard.pdf
7e989013fd52f274aa3160ed0cd0c62f *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 @@ -224,7 +224,7 @@ c2abe08ea4638d3c157c8df34a621e47 *inst/themes/zmrok.css
85e96631ee501c9741b3b3c6872f88b8 *man/all_labels.Rd
0d0e0d50e323fe0b63fdddd90bd904dc *man/all_patterns.Rd
c66a982c680ce38bcad35e31d5ff5b8e *man/asis_output.Rd
8ba9a74eb42f834127d9a8a7012a4d32 *man/chunk_hook.Rd
27fd66bb85a5a21262f49cbae16a8bae *man/chunk_hook.Rd
f61d44236133b9dae05c6754e3e97e17 *man/clean_cache.Rd
e867bbdfee1ee5f5396acf32b43f6f34 *man/combine_words.Rd
0dc6684ce1d6e71acd2a3d93402b8f37 *man/current_input.Rd
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -44,6 +44,7 @@ export(hook_plot_md)
export(hook_plot_rst)
export(hook_plot_tex)
export(hook_plot_textile)
export(hook_pngquant)
export(hook_purl)
export(hook_r2swf)
export(hook_scianimator)
Expand Down
2 changes: 1 addition & 1 deletion R/block.R
Expand Up @@ -476,6 +476,6 @@ label_code = function(code, label) {
'----', code)
}

as.source <- function(code) {
as.source = function(code) {
list(structure(list(src = code), class = 'source'))
}
1 change: 1 addition & 0 deletions R/citation.R
Expand Up @@ -86,6 +86,7 @@ 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'])
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)
Expand Down
8 changes: 4 additions & 4 deletions R/engine.R
Expand Up @@ -106,8 +106,8 @@ eng_interpreted = function(options) {
)
} else paste(switch(
engine, bash = '-c', coffee = '-e', groovy = '-e', lein = 'exec -e',
mysql = '-e', node = '-e', perl = '-e', psql = '-c', python = '-c',
ruby = '-e', scala = '-e', sh = '-c', zsh = '-c', NULL
mysql = '-e', node = '-e', octave = '--eval', perl = '-e', psql = '-c',
python = '-c', ruby = '-e', scala = '-e', sh = '-c', zsh = '-c', NULL
), shQuote(paste(options$code, collapse = '\n')))

# FIXME: for these engines, the correct order is options + code + file
Expand Down Expand Up @@ -543,8 +543,8 @@ eng_sql = function(options) {
local({
for (i in c(
'awk', 'bash', 'coffee', 'gawk', 'groovy', 'haskell', 'lein', 'mysql',
'node', 'perl', 'psql', 'python', 'Rscript', 'ruby', 'sas', 'scala', 'sed',
'sh', 'stata', 'zsh'
'node', 'octave', 'perl', 'psql', 'python', 'Rscript', 'ruby', 'sas',
'scala', 'sed', 'sh', 'stata', 'zsh'
)) knit_engines$set(setNames(list(eng_interpreted), i))
})

Expand Down
33 changes: 29 additions & 4 deletions R/hooks-extra.R
Expand Up @@ -21,6 +21,11 @@
#' provide additional parameters to the program \command{optipng}, e.g.
#' \code{optipng = '-o7'}.
#'
#' The function \code{hook_pngquant()} calls the program \command{pngquant} to
#' optimize PNG images. Note the chunk option \code{pngquant} can be used to
#' provide additional parameters to the program \command{pngquant}, e.g.
#' \code{pngquant = '--speed=1 --quality=0-50'}.
#'
#' When the plots are not recordable via \code{\link[grDevices]{recordPlot}} and
#' we save the plots to files manually via other functions (e.g. \pkg{rgl}
#' plots), we can use the chunk hook \code{hook_plot_custom} to help write code
Expand Down Expand Up @@ -62,26 +67,46 @@ hook_pdfcrop = function(before, options, envir) {
#' @export
#' @rdname chunk_hook
hook_optipng = function(before, options, envir) {
hook_png(before, options, envir, 'optipng')
}

hook_png = function(
before, options, envir, cmd = c('optipng', 'pngquant'), post_process = identity
) {
if (before) return()
ext = tolower(options$fig.ext)
if (ext != 'png') {
warning('this hook only works with PNG at the moment'); return()
}
if (!nzchar(Sys.which('optipng'))) {
warning('cannot find optipng; please install and put it in PATH'); return()
cmd = match.arg(cmd)
if (!nzchar(Sys.which(cmd))) {
warning('cannot find ', cmd, '; please install and put it in PATH'); return()
}
paths = all_figs(options, ext)

in_base_dir(
lapply(paths, function(x) {
message('optimizing ', x)
x = shQuote(x)
cmd = paste('optipng', if (is.character(options$optipng)) options$optipng, x)
cmd = paste(cmd, if (is.character(options[[cmd]])) options[[cmd]], shQuote(x))
(if (is_windows()) shell else system)(cmd)
post_process(x)
})
)
return()
}

#' @export
#' @rdname chunk_hook
hook_pngquant = function(before, options, envir) {
if (is.null(options[['pngquant']])) options$pngquant = '--skip-if-larger'
options[['pngquant']] = paste(options[['pngquant']], '--ext -fs8.png')
hook_png(before, options, envir, 'pngquant', function(x) {
# pngquant creates an output file with '-fs8.png' as the extension.
x2 = sub("\\.png$", "-fs8.png", x)
if (file.exists(x2)) file.rename(x2, x)
})
}

#' @export
#' @rdname chunk_hook
hook_plot_custom = function(before, options, envir){
Expand Down
22 changes: 3 additions & 19 deletions R/params.R
Expand Up @@ -79,8 +79,7 @@ knit_params = function(text, evaluate = TRUE) {
yaml = yaml_front_matter(text)
if (is.null(yaml)) return(list())

yaml = enc2utf8(yaml)
knit_params_yaml(yaml, evaluate = evaluate)
knit_params_yaml(enc2utf8(yaml), evaluate = evaluate)
}

#' Extract knit parameters from YAML text
Expand All @@ -106,7 +105,7 @@ knit_params_yaml = function(yaml, evaluate = TRUE) {

# if we found paramters then resolve and return them
if (is.list(parsed_yaml) && !is.null(parsed_yaml$params)) {
resolve_params(mark_utf8(parsed_yaml$params), evaluate = evaluate)
resolve_params(parsed_yaml$params, evaluate = evaluate)
} else {
list()
}
Expand All @@ -119,19 +118,6 @@ flatten_params = function(params) {
res
}

# copied from rmarkdown:::mark_utf8
mark_utf8 = function(x) {
if (is.character(x)) {
Encoding(x) = 'UTF-8'
return(x)
}
if (!is.list(x)) return(x)
attrs = attributes(x)
res = lapply(x, mark_utf8)
attributes(res) = attrs
res
}

# Extract the yaml front matter (if any) from the passed lines. The front
# matter is returned as a single-element character vector (with newlines
# delimited by \n) suitable for passing to yaml::load. This code is based on
Expand Down Expand Up @@ -161,14 +147,12 @@ yaml_front_matter = function(lines) {

front_matter = front_matter_lines
front_matter = front_matter[2:(length(front_matter) - 1)]
# FIXME: this is only for apex on CRAN (https://github.com/thibautjombart/apex/pull/15)
if (length(grep('^params:', front_matter)) == 0) return()
if (length(grep('^params:', front_matter)) == 0) return() # no params in YAML
front_matter = paste(front_matter, collapse = "\n")

# ensure that the front-matter doesn't terminate with ':', so it won't cause a
# crash when passed to yaml::load
if (!grepl(":\\s*$", front_matter)) front_matter

}


Expand Down
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://travis-ci.org/yihui/knitr.svg)](https://travis-ci.org/yihui/knitr)
[![Coverage Status](https://coveralls.io/repos/yihui/knitr/badge.svg?branch=master&service=github)](https://coveralls.io/github/yihui/knitr?branch=master)
[![Downloads from the RStudio CRAN mirror](http://cranlogs.r-pkg.org/badges/knitr)](https://cran.r-project.org/package=knitr)
[![Downloads from the RStudio CRAN mirror](http://cranlogs.r-pkg.org/badges/knitr)](https://cran.rstudio.org/package=knitr)

The R package **knitr** is a general-purpose literate programming engine,
with lightweight API's designed to give users full control of the output
Expand All @@ -15,7 +15,7 @@ frequently asked questions (including where to ask questions).
## Installation

You can install the stable version on
[CRAN](https://cran.r-project.org/package=knitr):
[CRAN](https://cran.rstudio.org/package=knitr):

```r
install.packages('knitr', dependencies = TRUE)
Expand All @@ -39,8 +39,8 @@ devtools::install_github('yihui/knitr', build_vignettes = TRUE)
## Motivation

While Sweave and related add-on packages like
[**cacheSweave**](https://cran.r-project.org/package=cacheSweave) and
[**pgfSweave**](https://cran.r-project.org/package=pgfSweave) are fairly good
[**cacheSweave**](https://cran.rstudio.org/package=cacheSweave) and
[**pgfSweave**](https://cran.rstudio.org/package=pgfSweave) are fairly good
engines for literate programming in R, but I often feel my hands are tied,
for example:

Expand All @@ -60,15 +60,15 @@ for example:
- I wished there was a way to round the numbers in `\Sexpr{}` other than
writing expressions like `\Sexpr{round(x, 3)}` for *each single* `\Sexpr{}`
- I wished I did not have to `print()` plots from
[**ggplot2**](https://cran.r-project.org/package=ggplot2) and a simple
[**ggplot2**](https://cran.rstudio.org/package=ggplot2) and a simple
`qplot(x, y)` would just give me a plot in Sweave
- I wished users would never need instructions on `Sweave.sty` or run into
troubles due to the fact that LaTeX cannot find `Sweave.sty`
- I wished **cacheSweave** could print the results of a code chunk even if
it was cached
- I wished [**brew**](https://cran.r-project.org/package=brew) could support
- I wished [**brew**](https://cran.rstudio.org/package=brew) could support
graphics
- I wished [**R2HTML**](https://cran.r-project.org/package=R2HTML) could
- I wished [**R2HTML**](https://cran.rstudio.org/package=R2HTML) could
support R code syntax highlighting
- ...

Expand Down
Binary file modified build/knitr.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions inst/doc/knit_expand.html
Expand Up @@ -220,7 +220,7 @@ <h1>Demos of <code>knit_expand()</code></h1>
<pre><code class="r">knit_expand(text = &quot;The value of a is {{a}}, so a + 1 is {{a+1}}.&quot;, a = rnorm(1))
</code></pre>

<pre><code>## [1] &quot;The value of a is -0.420789961861209, so a + 1 is 0.579210038138791.&quot;
<pre><code>## [1] &quot;The value of a is 0.703623490875254, so a + 1 is 1.70362349087525.&quot;
</code></pre>

<pre><code class="r">knit_expand(text = &quot;The area of a circle with radius {{r}} is {{pi*r^2}}&quot;, r = 5)
Expand Down Expand Up @@ -260,7 +260,7 @@ <h1>Demos of <code>knit_expand()</code></h1>
<pre><code class="r">knit_expand(text = &quot;you cannot see the value of x {{x=rnorm(1)}}but it is indeed created: x = {{x}}&quot;)
</code></pre>

<pre><code>## [1] &quot;you cannot see the value of x but it is indeed created: x = -1.52347367655193&quot;
<pre><code>## [1] &quot;you cannot see the value of x but it is indeed created: x = 1.53456091566555&quot;
</code></pre>

<pre><code class="r">res = knit_expand(text = c(&quot; x | x^2&quot;, &quot;{{x=1:5;paste(sprintf(\&quot;%2d | %3d\&quot;, x, x^2), collapse = \&quot;\n\&quot;)}}&quot;))
Expand Down
13 changes: 7 additions & 6 deletions inst/doc/knit_print.html
Expand Up @@ -12,7 +12,7 @@

<meta name="author" content="Yihui Xie" />

<meta name="date" content="2016-11-08" />
<meta name="date" content="2016-11-21" />

<title>Custom Print Methods</title>

Expand Down Expand Up @@ -70,7 +70,7 @@

<h1 class="title toc-ignore">Custom Print Methods</h1>
<h4 class="author"><em>Yihui Xie</em></h4>
<h4 class="date"><em>2016-11-08</em></h4>
<h4 class="date"><em>2016-11-21</em></h4>


<div id="TOC">
Expand Down Expand Up @@ -110,10 +110,11 @@ <h2>Customize Printing</h2>
## }
## &lt;environment: namespace:knitr&gt;</code></pre>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">methods</span>(knit_print)</code></pre></div>
<pre><code>## [1] knit_print.data.frame* knit_print.default*
## [3] knit_print.html* knit_print.knit_asis*
## [5] knit_print.knitr_kable* knit_print.shiny.tag*
## [7] knit_print.shiny.tag.list*
<pre><code>## [1] knit_print.data.frame* knit_print.default*
## [3] knit_print.grouped_df* knit_print.html*
## [5] knit_print.knit_asis* knit_print.knitr_kable*
## [7] knit_print.rowwise_df* knit_print.shiny.tag*
## [9] knit_print.shiny.tag.list* knit_print.tbl_sql*
## see '?methods' for accessing help and source code</code></pre>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">getS3method</span>(<span class="st">&quot;knit_print&quot;</span>, <span class="st">&quot;default&quot;</span>) <span class="co"># the default method</span></code></pre></div>
<pre><code>## function (x, ..., inline = FALSE)
Expand Down

0 comments on commit be08fa0

Please sign in to comment.