Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Resource detection is broken for custom format using an overwrite of theme argument #2493

Closed
cderv opened this issue Jun 9, 2023 · 1 comment · Fixed by #2494
Closed
Labels
bug an unexpected problem or unintended behavior

Comments

@cderv
Copy link
Collaborator

cderv commented Jun 9, 2023

From r-lib/pkgdown#2319 cc @gadenbuie

---
output: 
  cleanrmd::html_document_clean: 
    theme: no-class
---

# test

And you'll have an issue

> rmarkdown::find_external_resources("test.Rmd")
Error in `match.arg()`:
! 'arg' should be one ofdefault”, “bootstrap”, “cerulean”, “cosmo”, “darkly”, “flatly”, “journal”, “lumen”, “paper”, “readable”, “sandstone”, “simplex”, “spacelab”, “united”, “yetiRun `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/rlang_error>
Error in `match.arg()`:
! 'arg' should be one ofdefault”, “bootstrap”, “cerulean”, “cosmo”, “darkly”, “flatly”, “journal”, “lumen”, “paper”, “readable”, “sandstone”, “simplex”, “spacelab”, “united”, “yeti---
Backtrace:1. └─rmarkdown::find_external_resources("test.Rmd")
 2.   └─rmarkdown:::discover_rmd_resources(input_file, discover_single_resource)
 3.     ├─rmarkdown:::is_bs_theme(resolve_theme(output_format[["theme"]]))
 4.     │ └─bslib::is_bs_theme(theme)
 5.     └─rmarkdown:::resolve_theme(output_format[["theme"]])
 6.       └─base::match.arg(theme, themes())

This is because

  • find_external_resources() parsed the YAML front matter to do some resource detection
  • in detecting external resources needs to consider css argument #2486 we added a check on theme for bslib resource handling, and we used resolve_theme()
  • resolve_theme() was made for handling bslib compatible theme argument and not custom ones.

We should probably use a tryCatch() in discover_rmd_resources() because if resolve_theme() errors, this means this is not a bslib theme for sure.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant