From 94c536e146b448a8c791f9b09b014e2f50f7d0b7 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Fri, 4 Mar 2022 10:31:36 +0100 Subject: [PATCH] respect non-R chunks --- R/purl.R | 2 +- tests/testthat/in/parsable-R-success.Rmd | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/R/purl.R b/R/purl.R index 30a3063bf..dfab0a46a 100644 --- a/R/purl.R +++ b/R/purl.R @@ -18,7 +18,7 @@ robust_purl <- function(path) { if (tolower(ext) == "rmd") { lines[!should_not_override] <- gsub( - "^```\\{.*\\}.*", "```{r purl = TRUE}", lines[!should_not_override] + "^```\\{ *[Rr] *.*\\}.*", "```{r purl = TRUE}", lines[!should_not_override] ) } else if (tolower(ext) == "rnw") { lines[!should_not_override] <- gsub( diff --git a/tests/testthat/in/parsable-R-success.Rmd b/tests/testthat/in/parsable-R-success.Rmd index 47ce464bb..71b227b53 100644 --- a/tests/testthat/in/parsable-R-success.Rmd +++ b/tests/testthat/in/parsable-R-success.Rmd @@ -15,3 +15,20 @@ parsable + code ```{r, purl=FALSE} fas / fk 12 - ``` + + +```{nonR chunk} +this is +``` + +```{f , x= 2} +this is +``` + +```{f, x= 2} +this is +``` + +```{ f, x= 2} +this is +```