Skip to content

Commit

Permalink
no need to add before/after code chunks for those chapters not includ…
Browse files Browse the repository at this point in the history
…ed in preview
  • Loading branch information
yihui committed Jul 19, 2016
1 parent 41b7a1a commit d086146
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ merge_chapters = function(files, to, before = NULL, after = NULL, orig = files)
preview = opts$get('preview'); input = opts$get('input_rmd')
content = unlist(mapply(files, orig, SIMPLIFY = FALSE, FUN = function(f, o) {
x = readUTF8(f)
if (preview && !(o %in% input)) x = create_placeholder(x)
x = insert_code_chunk(x, before, after)
x = if (preview && !(o %in% input)) create_placeholder(x) else {
insert_code_chunk(x, before, after)
}
c(x, '', paste0('<!--chapter:end:', o, '-->'), '')
}))
if (preview) content = c(create_placeholder(readUTF8(files[1]), FALSE), content)
Expand Down

0 comments on commit d086146

Please sign in to comment.