yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.36k stars 873 forks source link

Use named extract for code content #2263

Closed cderv closed 1 year ago

cderv commented 1 year ago

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

```{r, child="mychild.Rmd"}

Try this without this PR to get the warning

````markdown
---
title: "reprex"
---

```{r}
knitr::opts_chunk$set(code_folding = FALSE)

Warning message: In call_block(block) : The chunk 'unnamed-chunk-2' has the 'child' option, and this code chunk must be empty. Its code will be ignored.



This PR makes sure that `params[['code']]` does not do partial matching with `params$code`

it creates an issue with distill because `code_fold = FALSE` is an option used in the distill format,.