Skip to content

Linting code chunks in Rmd not working consistently with knitr #797

@renkun-ken

Description

@renkun-ken

Consider the following Rmd (saved to e.g. lintr-test.Rmd):

```{r}
x<-1
```

```{R}
x<-2
```

```{therom, name='test'}
x<-3
```

Linting the file has the following output:

> lintr::lint("lintr-test.Rmd")                                                                                                                             
/home/renkun/Workspaces/testR/lintr-test.Rmd:2:2: style: Put spaces around all infix operators.
x<-1
~^~~
/home/renkun/Workspaces/testR/lintr-test.Rmd:10:2: style: Put spaces around all infix operators.
x<-3
~^~~

To my understanding, it should lint the first two R chunks and ignores the third one.

However, the current chunk extraction does not seem to work consistently with knitr in that knitr treats r and R as the same. The theorem is brought up at REditorSupport/languageserver#421 where bookdown seems to provide some markdown extensions where additional engines are implemented (as introduced at https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html).

I think the expected behavior should be linting the R or r chunks and ignores all other chunks.

Metadata

Metadata

Assignees

Labels

featurea feature request or enhancementrmd

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions