yihui / knitr

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

htmlwidgets in quarto cause rendering error #2286

Closed Bisaloo closed 8 months ago

Bisaloo commented 10 months ago

Reproducible example

This is a test file test.qmd:

---
title: "Untitled"
format: html
---

```{r}
library(visNetwork)
nodes <- data.frame(id = 1:6, title = paste("node", 1:6), 
                    shape = c("dot", "square"),
                    size = 10:15, color = c("blue", "red"))
edges <- data.frame(from = 1:5, to = c(5, 4, 6, 3, 3))
visNetwork(nodes, edges) %>%
  visOptions(highlightNearest = TRUE, nodesIdSelection = TRUE)

Error:

processing file: reprex.qmd 1/3
2/3 [unnamed-chunk-1]

Quitting from lines 7-14 [unnamed-chunk-1] (reprex.qmd) Error in add_html_caption(): ! unused argument (xfun::grep_sub("^[^<]<[^>]+aria-labelledby[ ]=[ ]\"([^\"]+)\".$", "\1", x)) Backtrace:

  1. global .main()
  2. execute(...)
  3. rmarkdown::render(...)
  4. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
  5. knitr:::process_file(text, output) ...
    1. sew(res, options)
    2. knitr:::sew.list(x, options, ...)
    3. base::lapply(x, sew, options, ...)
    4. FUN(X[[i]], ...)
    5. knitr:::sew.knit_asis(x, options, ...) Execution halted

It seems that the error comes from the add_html_caption() call here:

https://github.com/yihui/knitr/blob/43dd3aed149a670129ae4d0501d96e9ce5c815e9/R/output.R#L509-L512

but I can't figure out why this fails. 3 arguments are provided and add_html_caption() has 3 arguments.

Session info ``` R version 4.3.1 (2023-06-16) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.3 LTS, RStudio 2023.9.0.290 Locale: LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 LC_PAPER=en_GB.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C time zone: Europe/Paris tzcode source: system (glibc) Package version: base64enc_0.1.3 bslib_0.5.0 cachem_1.0.8 cli_3.6.1 compiler_4.3.1 cpp11_0.4.4 ctv_0.9-5 curl_5.0.1 digest_0.6.33 dplyr_1.1.2 ellipsis_0.3.2 evaluate_0.21 fansi_1.0.4 fastmap_1.1.1 fontawesome_0.5.1 fs_1.6.2 generics_0.1.3 glue_1.6.2 graphics_4.3.1 grDevices_4.3.1 highr_0.10 htmltools_0.5.5 jquerylib_0.1.4 jsonlite_1.8.7 knitr_1.43 lifecycle_1.0.3 magrittr_2.0.3 memoise_2.0.1 methods_4.3.1 mime_0.12 parsedate_1.3.1 pillar_1.9.0 pkgconfig_2.0.3 pkgsearch_3.1.2 prettyunits_1.1.1 purrr_1.0.1.9000 R6_2.5.1 rappdirs_0.3.3 rlang_1.1.1 rmarkdown_2.23 rstudioapi_0.15.0 sass_0.4.7 sessioninfo_1.2.2 stats_4.3.1 stringi_1.7.12 stringr_1.5.0 tibble_3.2.1 tidyr_1.3.0 tidyselect_1.2.0 tinytex_0.45 tools_4.3.1 utf8_1.2.3 utils_4.3.1 vctrs_0.6.3 withr_2.5.0 xfun_0.39 yaml_2.3.7 ```

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 10 months ago

This has already been fixed in the dev version of knitr. Please do read and follow the issue guide at the bottom of your issue. In particular:

  • also tried the development version: remotes::install_github('yihui/knitr').

Thanks!

yihui commented 10 months ago

Duplicate of #2261

github-actions[bot] commented 2 months 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.