Refactor tutorial knitr hooks and set them in the tutorial format #599
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tutorial_knitr_options()now prepares a list of knitr options with the knitr options and hooks that are used during the tutorial pre-render. This list is in the same format as the knitr options expected byrmarkdown::output_format()so we can set the knitr options directly in thetutorialoutput format.This ensures that the hooks are set for each
rmarkdown::render()call. Previously, by only relying on.onAttach(), these hooks might be reset at the end of the firstrender()and wouldn't be re-installed for subsequent renders, resulting in the behavior seen in #598. I haven't removed the.onAttach()mechanism because it is still useful for catching learnr component usage outside of thelearnr::tutorial()format.Fixes #598