Skip to content

Commit 846a7db

Browse files
committed
fix #2025: the -o argument of asymptote takes the basename of the output file path instead of the actual path now, so if we pass foo.png to -o, we will get foo.png.png
to fix this problem, we check if foo.png exists; if not, check foo.png.png
1 parent ea278f6 commit 846a7db

File tree

7 files changed

+15
-24
lines changed

7 files changed

+15
-24
lines changed

.github/CONTRIBUTING.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,6 @@ To make sure you did not break anything, you need to run tests, which are
1616
done through the [**testit**](http://cran.rstudio.com/package=testit)
1717
package. If you added any features, add your own tests in `tests/testit/`.
1818

19-
## Travis CI
20-
21-
If you are lazy or do not understand what I said above, just push commits to
22-
your repo, submit a PR, and wait for a few minutes.
23-
[Travis CI](http://yihui.name/en/2013/04/travis-ci-general-purpose/) will run
24-
the tests automatically. If your pull request passes the tests, you see
25-
green check marks, otherwise you see red crosses, and you will probably get
26-
email notifications as well.
27-
28-
- [An example PR that passed the
29-
check](https://github.com/yihui/knitr/pull/852/commits)
30-
- [An example PR that failed](https://github.com/yihui/knitr/pull/832/commits)
31-
32-
When your PR does not pass the check, you need to click on the red cross to see
33-
details. There are two sets of tests: `R CMD check` on the package source, as
34-
well as the test on examples. The former is basically the unit tests, and the
35-
latter is to make sure your changes does not break my existing examples in the
36-
[knitr-examples](https://github.com/yihui/knitr-examples).
37-
3819
## roxygen2 documentation
3920

4021
If your changes involve the roxygen2 documentation, please run `Rd2roxygen::rab('.')` to generate the Rd files.

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: knitr
22
Type: Package
33
Title: A General-Purpose Package for Dynamic Report Generation in R
4-
Version: 1.51.1
4+
Version: 1.51.2
55
Authors@R: c(
66
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666", URL = "https://yihui.org")),
77
person("Abhraneel", "Sarma", role = "ctb"),

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ import(grDevices)
152152
import(graphics)
153153
import(stats)
154154
import(utils)
155+
importFrom(xfun,file_exists)
155156
importFrom(xfun,file_ext)
156157
importFrom(xfun,file_string)
157158
importFrom(xfun,html_escape)

NEWS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGES IN knitr VERSION 1.52
22

3+
## BUG FIXES
4+
5+
- Due to a change in Asymptote, the output file may not be recognized or included correctly (thanks, @DeliciousRoastPotato @shangeconnew, #2025).
36

47
# CHANGES IN knitr VERSION 1.51
58

@@ -9,7 +12,7 @@
912
- `knit()` produces 'knitr processing' and 'knitr output' spans when starting and finishing an operation
1013
- `knit()` produces 'knit' spans for each chunk, recording attributes such as the label and knit engine
1114

12-
- Added support for hooks that get executed before and after knitting. To register a hook before knitting starts, use `knitr::knit_hooks$set(before.knit = function() {})`. Similarly, the hook `after.knit` can be registered and will be executed after knitting is finished.
15+
- Added support for hooks that get executed before and after knitting (thanks, @cderv #2223, @arnaudgallou #2419). To register a hook before knitting starts, use `knitr::knit_hooks$set(before.knit = function() {})`. Similarly, the hook `after.knit` can be registered and will be executed after knitting is finished.
1316

1417
## BUG FIXES
1518

R/engine.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,13 @@ eng_plot = function(options) {
403403
output = function(options, code, output, file) {
404404
extra = if (options$eval) {
405405
# move the generated plot (with a temp filename) to fig.path
406-
f1 = with_ext(file, ext)
406+
if (!file_exists(f1 <- with_ext(file, ext))) {
407+
# asymptote may geneate file.ext.ext (see #2025)
408+
if (cmd == 'asy') f1 = paste0(f1, '.', ext)
409+
}
410+
if (!file_exists(f1)) stop(
411+
'The command did not generate the expected plot file: ', f1
412+
)
407413
f2 = paste(fig_path(), ext, sep = '.')
408414
xfun::dir_create(dirname(f2))
409415
unlink(f2)

R/package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#' FAQ's: \url{https://yihui.org/knitr/faq/}
2727
#' @importFrom xfun file_ext html_escape is_windows loadable parse_only
2828
#' sans_ext try_silent with_ext read_utf8 write_utf8 file_string
29-
#' is_R_CMD_check is_abs_path
29+
#' is_R_CMD_check is_abs_path file_exists
3030
'_PACKAGE'
3131

3232
.knitEnv = new.env()

R/utils-conversion.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ rnw2pdf = function(
115115
# On Windows, when tweaking the content, users may forget to close the PDF
116116
# file (thus can't be written). Since knitting may take quite some time, it's
117117
# better to check the write permission of the output file in advance.
118-
if (xfun::file_exists(output) && !file.remove(output)) stop(
118+
if (file_exists(output) && !file.remove(output)) stop(
119119
"The file '", output, "' cannot be removed (may be locked by a PDF reader)."
120120
)
121121
old = opts_chunk$set(error = error)

0 commit comments

Comments
 (0)