Skip to content

Commit

Permalink
Use named extract for code content (#2263)
Browse files Browse the repository at this point in the history
This is to avoid partial matching with option like `code_folding = FALSE`

Found in **distill** while it was warning for non empty chunk content while using
````markdown
```{r, child="mychild.Rmd"}
```
````
  • Loading branch information
cderv authored Jun 20, 2023
1 parent 8403ca5 commit 0b6bee2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/block.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ call_block = function(block) {

if (opts_knit$get('progress')) print(block)

params$code = parse_chunk(params$code) # parse sub-chunk references
params[['code']] = parse_chunk(params[['code']]) # parse sub-chunk references

ohooks = opts_hooks$get()
for (opt in names(ohooks)) {
Expand Down
2 changes: 1 addition & 1 deletion R/parser.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ parse_block = function(code, header, params.src, markdown_mode = out_format('mar
code = parts$code

label = params$label; .knitEnv$labels = c(.knitEnv$labels, label)
if (length(code) || length(params$file) || length(params$code)) {
if (length(code) || length(params[['file']]) || length(params[['code']])) {
if (label %in% names(knit_code$get())) {
if (identical(getOption('knitr.duplicate.label'), 'allow')) {
params$label = label = unnamed_chunk(label)
Expand Down

0 comments on commit 0b6bee2

Please sign in to comment.