yihui/knitr — pull request #831 by kforner (2014-08-19 15:18:59+00:00)
Title: fixed knit_child when knitting chunks with blocks that produce multiple ...

fixed knit_child when knitting chunks with blocks that produce multiple plots.
cf https://github.com/yihui/knitr/issues/824

It was difficult writing a test because I could not manage to run your testit tests without running R CMD check, and you do not seem to use sample files in your tests (is there any reason not to use testthat ?)

To test it manually:
```
library(devtools)
load_all('knitr')
res <- knit('parent.Rnw', quiet = TRUE)
lines <- readLines(res)
nb1 <- sum(grepl('includegraphics', lines, ignore.case = TRUE))
cat('nb plots=', nb1, '\n')
```

with
parent.Rnw
```
\documentclass[letter, margin=1.90cm, 12pt]{scrartcl}
\begin{document}

<>=
library(ggplot2)
out <- knitr::knit_child('child.Rnw', options = list(fig.keep='all'))
@
\Sexpr{paste(out, collapse="\n")}
\end{document}
```
child.Rnw
```
\section{PLOTS}
<>=
{
print(ggplot(iris, aes(x = Species)) + geom_histogram(fill = 'green') + ggtitle(paste('PLOT CHILD 1')))
print(ggplot(iris, aes(x = Species)) + geom_histogram(fill = 'green') + ggtitle(paste('PLOT CHILD 2')))
}
@
```

The old knitr would output 1, the fixed one 2.