Skip to content

Commit

Permalink
add unparsable example, make it work for named r chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert committed May 2, 2021
1 parent 86872bf commit deebffc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Expand Up @@ -45,8 +45,8 @@ repos:
exclude: >
(?x)^(
bench/.*|
tests/testthat/.*-in\.R|
tests/testthat/.*-out\.R
tests/testthat/.*-in\.R(md)?|
tests/testthat/.*-out\.R(md)?
)$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
Expand Down
2 changes: 1 addition & 1 deletion R/transform-code.R
Expand Up @@ -116,7 +116,7 @@ identify_raw_chunks <- function(lines, filetype, engine_pattern = get_engine_pat
#' addition not styled with styler when formatting the document.
#' @keywords internal
finalize_raw_chunks <- function(start, end, filetype, lines) {
header <- gsub(get_knitr_pattern(filetype)$chunk.begin, "\\1", lines[start])
header <- gsub(get_knitr_pattern(filetype)$chunk.begin, "\\2", lines[start])
parsed <- get_parse_data(paste0("c(", header, ")"))$text
do_not_tidy <- any(parsed == "tidy") &&
parsed[which(parsed == "tidy") + 1] == "=" &&
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/rmd/no-tidy-in.Rmd
Expand Up @@ -9,10 +9,10 @@ test + f(1)
```


```{r, tidy=FALSE}
1 +1 #co
```{r, tidy = FALSE}
1, , ___
```

```{r}
test + f(1 )
test + f(1)
```
4 changes: 2 additions & 2 deletions tests/testthat/rmd/no-tidy-out.Rmd
Expand Up @@ -9,8 +9,8 @@ test + f(1)
```


```{r, tidy=FALSE}
1 +1 #co
```{r, tidy = FALSE}
1, , ___
```

```{r}
Expand Down

0 comments on commit deebffc

Please sign in to comment.