From 0b6bee28f590cc4a4337ab45dd26a58e63e9b426 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 21 Jun 2023 01:36:20 +0200 Subject: [PATCH] Use named extract for code content (#2263) 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"} ``` ```` --- R/block.R | 2 +- R/parser.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/block.R b/R/block.R index 8ec882dc22..5f84875357 100644 --- a/R/block.R +++ b/R/block.R @@ -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)) { diff --git a/R/parser.R b/R/parser.R index fb7f42a3f1..4c8a074226 100644 --- a/R/parser.R +++ b/R/parser.R @@ -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)