yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.38k stars 873 forks source link

why knitr accepts ```r instead of {r} ? #2354

Closed ChristianWia closed 2 months ago

ChristianWia commented 2 months ago

I ve checked that ```r is not R compliant but knitr accepts to generate html files in Rstudio when this chunk is used. My issue https://github.com/Rdatatable/data.table/issues/6225 is rejected but tool mdpo is lost when it encounters this form. So is there a special meaning for ```r and why is knitr so generous ? Thanks.


By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

yihui commented 2 months ago

```r is standard Markdown syntax, and knitr doesn't do anything about it. knitr only processes ```{r} and `r `.

As @MichaelChirico told you in the issue, ```r is a simpler way to write code that is not to be evaluated, i.e., it's a shorthand for ```{r, eval=FALSE}.

MichaelChirico commented 2 months ago

It sounds like the issue is with mdpo, not knitr or data.table.

MichaelChirico commented 2 months ago

I see more than 100,000 usages of ```r on GitHub:

https://github.com/search?q=%2F%5Cn%5B%60%5D%5B%60%5D%5B%60%5Dr%5Cb%2F&type=code

ChristianWia commented 2 months ago

thanks for the url it helps , that means tools mdpo should adapt and recognize this syntax also. i will refer your answer.