yihui / knitr

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

Hard to parse inline parsing error #2173

Closed hadley closed 1 year ago

hadley commented 2 years ago

It's hard for me to understand this error (which I think is new in https://github.com/yihui/knitr/commit/3cbf47f31efebc28b59ac35c2ba07cbd3dd844ac)

knitr::knit(text = "`r 1 + `", quiet = TRUE)
#> Quitting from lines 1-1 (cilia-stag_reprex.spin.Rmd)
#> Error: Failed to parse the inline R code: 1 +  (Reason: <text>:2:0: unexpected end of input
#> 1: 1 + 
#>    ^)

Created on 2022-09-20 with reprex v2.0.2

I'd find it easier to understand if it was more like:

#> Error: Failed to parse the inline R code: `1 + `
#> Reason: <text>:2:0: unexpected end of input
#> 1: 1 + 
#>    ^

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 1 year ago

Thanks! The error message includes `r ` now, and the reason is written to the next line:

#> Error: Failed to parse the inline R code: `r 1 + `
#> Reason: <text>:2:0: unexpected end of input
#> 1: 1 + 
#>    ^
hadley commented 1 year ago

Much better, thanks!

github-actions[bot] commented 1 year ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.