Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Autodetect if Rmd is rendered via @includeRmd #361

Closed
dfalbel opened this issue Oct 7, 2021 · 3 comments
Closed

Autodetect if Rmd is rendered via @includeRmd #361

dfalbel opened this issue Oct 7, 2021 · 3 comments
Labels
feature a feature request or enhancement

Comments

@dfalbel
Copy link

dfalbel commented Oct 7, 2021

I wonder if cli could autodetect if the Rmd is running through an @includeRmd tag and thus being included in an . Rd file and in this case set cli.unicode=FALSE.

Otherwise, the Rmd can end-up rendering unicode characters in the .Rd and generate issues when building the PDF manual:

LaTeX errors when creating PDF version.
This typically indicates Rd problems.
LaTeX errors found:
! Package inputenc Error: Unicode char ─ (U+2500)
(inputenc)                not set up for use with LaTeX.

For example:

https://github.com/mlverse/luz/blob/f8a34dcc815651456ece210dcdcd60b4e97ebc8d/man/evaluate.Rd#L63

@dfalbel dfalbel changed the title Autodetect if Rmd is rendered to @includeRmd Autodetect if Rmd is rendered via @includeRmd Oct 7, 2021
@gaborcsardi
Copy link
Member

Yeah, this is annoying. There is currently no official way to detect roxygen2, so we would need to address this there first.

This is also related: r-lib/roxygen2#1240

Ideally, we would have Unicode in the HTML help and in pkgdown, and would only turn it off in the PDF manual.

For now, a workaround is to turn it off before the @includeRmd:

#' Test
#'
#' `r options(cli.unicode = FALSE)`
#'
#' @includeRmd test.Rmd
#' @name test
NULL

This of course turns it off for the whole session, but if you run document() is a subprocess or from the shell, then it is not too bad.

@gaborcsardi gaborcsardi added the feature a feature request or enhancement label Oct 20, 2021
@gaborcsardi gaborcsardi added this to the 3.2.0 milestone Jan 20, 2022
@gaborcsardi
Copy link
Member

We actually still need support from roxygen2 for this.

@gaborcsardi gaborcsardi removed this from the 3.2.0 milestone Feb 9, 2022
@hadley
Copy link
Member

hadley commented May 24, 2022

Now part of r-lib/roxygen2#1349

@hadley hadley closed this as completed May 24, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants