-
-
Notifications
You must be signed in to change notification settings - Fork 878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
knitr options hook with eval does not work as expected with child documents #2247
Comments
Looking at the code in Lines 58 to 67 in 1239f36
If the chunk option Only after are the option hooks are retrived and added to Lines 71 to 81 in 1239f36
So in the example, It seems like an obvious fix would be moving the option hook code above the child code, but that might have other consequences...? |
Yes, the fix seems obvious. Let's see if #2251 can pass the checks, and also if any reverse dependencies will be broken. Thanks! |
Some reverse dependencies were broken, but I think they are irrelevant to this change, so I just merged the PR. |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
Summary of the problem: option hooks that control the
eval
argument don't seem to prevent theeval
of child documents, only the chunks within them.I am compiling (via the RStudio "knit" button) the following Rmd document, which contains an option hook. The params$s parameter controls whether a chunk is evaluated and included, via the option hook. When the
solutions
hook is included, the chunk should be completely ignored.However, this does not seem to occur with chunks specifying child Rmd documents. Straight-up
eval=FALSE
works, but the options hook does not. Instead, the code chunks within the child document are affected by the options hook.The child document (
child.Rmd
) is this:The options hook seems to work for code chunks (ie,
# 0
). I would expect the same results (ie, the child document is not evaluated at all) for chunks under#2
,#3
, and#4
, however, the chunk#3
shows that the markdown is rendered, but the chunks are not.The hook seems to be controlling the chunks within the child document, instead of the chunk itself. Also, in my testing, inline code (via `r `) is run, which is a problem when e.g. variables are defined in unevaluated chunks but then printed in (unexpectedly evaluated) inline code in the child chunk.
By filing an issue to this repo, I promise that
xfun::session_info('knitr')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: