diff --git a/NEWS.md b/NEWS.md index 2753da8eb5..eaed4998c0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,8 @@ - fixed #862: the YAML metadata in child R Markdown documents was not correctly removed (thanks, @krlmlr) +- fixed #874: for the engines `dot` and `tikz`, the figure directory will be created recursively (thanks, @WilDoane) + # CHANGES IN knitr VERSION 1.7 ## NEW FEATURES diff --git a/R/engine.R b/R/engine.R index 76fa333fd1..9cbc952a6f 100644 --- a/R/engine.R +++ b/R/engine.R @@ -154,7 +154,7 @@ eng_tikz = function(options) { unlink(texf) fig = fig_path('', options) - dir.create(dirname(fig), showWarnings = FALSE) + dir.create(dirname(fig), recursive = TRUE, showWarnings = FALSE) file.rename(outf, str_c(fig, '.pdf')) # convert to the desired output-format, calling `convert` ext = tolower(options$fig.ext %n% dev2ext(options$dev)) @@ -191,7 +191,7 @@ eng_dot = function(options) { shQuote(str_c(fig <- fig_path(), '.', ext))) # generate output - dir.create(dirname(fig), showWarnings = FALSE) + dir.create(dirname(fig), recursive = TRUE, showWarnings = FALSE) outf = paste(fig, ext, sep = '.') unlink(outf) extra = if (options$eval) {