r-lib / lintr

Static Code Analysis for R
https://lintr.r-lib.org
Other
1.16k stars 184 forks source link

Non-R code blocks are parsed as R in Rmd/qmd files #1896

Open eitsupi opened 1 year ago

eitsupi commented 1 year ago

While trying to set up lintr in the rextendr package, I noticed that lintr parses the Rust code in the {extendr} code blocks as R code and raise errors. https://github.com/extendr/rextendr/blob/870a03a67b50168c4df8d84d8fcdebdb9f5c33a7/vignettes/rmarkdown.Rmd

This seems to be the same for Quarto markdown files, and the {ojs} code block is also parsed as an R code block.

---
title: test
---

```{ojs}
data = FileAttachment("seattle-weather.csv")
  .csv({typed: true})
eitsupi commented 1 year ago

Perhaps set to exclude only Engines registered in knitr?

In the case of qmd, there may be code blocks inserted that are clearly unrelated to knitr. Just off the top of my head, {ojs}, {mermaid}, and {dot} are processed by Quarto and are not passed to knitr.