Skip to content

Commit

Permalink
need local chunk options in hook_purl() to check if user has set erro…
Browse files Browse the repository at this point in the history
…r=TRUE for that chunk

also close #2338
  • Loading branch information
yihui committed Nov 1, 2024
1 parent 6e644b8 commit a60203c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

- Unbalanced chunk delimiters (fences) in R Markdown documents are strictly prohibited now.

- For code chunks with `error = TRUE`, `purl()` and `hook_purl()` will wrap the code in `try({...})` (thanks, @jeroen, #2368).
- For code chunks with `error = TRUE`, `purl()` and `hook_purl()` will wrap the code in `try({...})` (thanks, @bastistician #2338, @jeroen #2368).

## MINOR CHANGES

Expand Down
5 changes: 4 additions & 1 deletion R/hooks-extra.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ hook_purl = function(before, options, ...) {
.knitEnv$tangle.params = NULL
}

code = tangle_mask(options$code, options$eval, options$error)
# `options` contains merged chunk options, but we need to check if
# `error=TRUE` in local chunk options, so retrieve options from knit_code
error = attr(knit_code$get(options$label), 'chunk_opts')[['error']]
code = tangle_mask(options$code, options$eval, error)
if (is.character(output)) {
code = c(
if (file.exists(output)) read_utf8(output),
Expand Down

0 comments on commit a60203c

Please sign in to comment.