yihui / knitr

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

`knit2html(fragment.only=TRUE)` does not work with `{markdown}` >= v1.6 #2257

Closed schloerke closed 1 year ago

schloerke commented 1 year ago

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.


{knitr} has some examples using fragment.only in knitr::knit2html(): https://github.com/search?q=repo%3Ayihui%2Fknitr+fragment.only&type=code. (And in https://github.com/rstudio/shinycoreci/blob/d1ca18f1930cb8fafd6821d57cd0fa465467b5fa/inst/apps/020-knit-html/server.R#L22).

I believe the breaking change of markdown::mark() was added in https://github.com/rstudio/markdown/commit/91ead1f93cfcc0e1f2163db25c4ef1d69c1e4700 which is called from {knitr} in https://github.com/yihui/knitr/blob/58e7879abda492fc4358dab2d249a30f581f0593/R/utils-conversion.R#L180 .

The reprex below does not work when {markdown} >= 1.6 is used.

Reprex:

shiny::runGitHub("yihui/knitr", subdir = "inst/shiny")
#> Downloading https://github.com/yihui/knitr/archive/HEAD.tar.gz
#> Loading required package: shiny
#>
#> Listening on http://127.0.0.1:7049
#> Warning: Error in mark: unused argument (fragment.only = TRUE)
#>   103: markdown::mark_html
#>   102: mark_html
#>   101: knit2html
#>    99: <reactive:output$nbOut> [/private/var/folders/gg/lzk06xmx6x3c0_9vqq1lcl9w0000gp/T/RtmpqNAgV6/shinyapp5f73253ed9d3/knitr-58e7879abda492fc4358dab2d249a30f581f0593/inst/shiny/server.R#13]
#>    83: output$nbOut
#>     3: runApp
#>     2: runUrl
#>     1: shiny::runGitHub
❯❯ xfun::session_info()
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.3.1

Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

Package version:
  base64enc_0.1.3        brio_1.1.3             bslib_0.4.2.9000       cachem_1.0.8           callr_3.7.3           
  cli_3.6.1              clisymbols_1.2.0       colorout_1.2-2         commonmark_1.9.0       compiler_4.2.2        
  crayon_1.5.2           desc_1.4.2             diffobj_0.3.5          digest_0.6.31          ellipsis_0.3.2        
  evaluate_0.20          fansi_1.0.4            fastmap_1.1.1          fontawesome_0.5.1      fs_1.6.2              
  git2r_0.31.0           glue_1.6.2             graphics_4.2.2         grDevices_4.2.2        highr_0.10            
  hms_1.1.2              htmltools_0.5.5.9000   httpuv_1.6.9           jquerylib_0.1.4        jsonlite_1.8.4        
  knitr_1.42.8           later_1.3.1            lifecycle_1.0.3        magrittr_2.0.3         markdown_1.6          
  memoise_2.0.1          memuse_4.2-3           methods_4.2.2          mime_0.12              pillar_1.8.1          
  pkgconfig_2.0.3        pkgload_1.3.2          praise_1.0.0           prettyunits_1.1.1      processx_3.8.0        
  progress_1.2.2         promises_1.2.0.1       prompt_1.0.1           ps_1.7.2               R6_2.5.1              
  rappdirs_0.3.3         Rcpp_1.0.10            rematch2_2.1.2         rlang_1.1.1            rprojroot_2.0.3       
  rstudioapi_0.14        sass_0.4.6             sessioninfo_1.2.2      shiny_1.7.4.9002       shinycoreci_0.0.0.9008
  sourcetools_0.1.7.1    stats_4.2.2            testthat_3.1.6         tibble_3.2.0           tools_4.2.2           
  utf8_1.2.3             utils_4.2.2            vctrs_0.5.2            waldo_0.4.0            withr_2.5.0           
  xfun_0.39              xtable_1.8-4           yaml_2.3.7

Please let me know how you'd like to adjust the shiny example. I'll follow your pattern in rstudio/shinycoreci and rstudio/shiny-examples.

Thank you!

yihui commented 1 year ago

Yes, we should use knit2html(..., template = FALSE) instead of fragment.only = TRUE now. I just adjusted the shiny example. Thanks a lot for the report!

Duplicate of #2252

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