[Rd] tools::parseLatex() crashes on "\\verb{}"

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Fri Jul 21 16:18:51 CEST 2023


В Fri, 21 Jul 2023 15:14:09 +0200
Antoine Fabri <antoine.fabri using gmail.com> пишет:

> On a closer look it seems like roxygen2 introduces those, when using
> markdown backtick quoting, if the quoted content is not syntactic. For
> instance:
> 
> #' `c(c(1)`
> #' `c(c(1))`
> 
> Will convert the first line to `\verb{c(c(1)}` and the second to
> `\code{c(c(1))}`.

roxygen2 tries to do the right thing here. As defined in "Parsing Rd
files" [*], \code{} blocks are supposed to contain syntactically valid
R code. When something that is not valid R is given in a Markdown code
block, roxygen2 should not output \code{}, so it outputs \verb{}.

Also, unlike in LaTeX as understood by tools::parseLatex(), \verb{}
blocks use the {} braces in R documentation, and are understood
correctly by tools::parse_Rd(). Perhaps you also need tools::parse_Rd()?

-- 
Best regards,
Ivan

[*] https://developer.r-project.org/parseRd.pdf



More information about the R-devel mailing list