Skip to content

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

Closed

Description

@cderv

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 of “default”, “bootstrap”, “cerulean”, “cosmo”, “darkly”, “flatly”, “journal”, “lumen”, “paper”, “readable”, “sandstone”, “simplex”, “spacelab”, “united”, “yeti”
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/rlang_error>
Error in `match.arg()`:
! 'arg' should be one of “default”, “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.

Activity

  1. added
    bug
    on Jun 9, 2023
  2. github-actions commented on Dec 13, 2023

    @github-actions

    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.

  3. locked as resolved and limited conversation to collaborators on Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions