Skip to content

R files generating knitr templates are parsed as Rmd #743

@MichaelChirico

Description

@MichaelChirico

If I have a file that generates knitr templates, e.g.

writeLines('
CreateTemplate <- function(x) {
return(sprintf("
```{r code}
foo <- function(x) x+%d
foo(5)
```", x))
}', tmp <- tempfile())

parse(tmp) works just fine, however, lintr assumes this is an Rmd based on matching some chunk regex:

lintr::lint(tmp)
# /tmp/RtmpN8X7Dj/file3d0536f05e5d:4:1: error: Missing chunk end for chunk (maybe starting at line 4).
# ```{r code}
# ^

Should we try parsing the file as R code first, then checking Rmd chunks afterwards?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions