Closed rempsyc closed 1 year ago
I think this is a change that is expected as it fixed an issue.
As explained in NEWS for 1.41:
Added an argument exact to pandoc_to() and pandoc_from() to decide whether to use/return the exact Pandoc output/input format name. If not (default), Pandoc extensions will be removed from the format name, e.g., latex-smart will be treated as latex.
Change was made at https://github.com/yihui/knitr/commit/96f3ff76407fb3c29663a95887ef6b131e3725fb
Before this knitr was not correctly considering some formats with extensions like html-native_spans
or gfm+tex_math_dollars
, as respectively html
or gfm
. The change fixes it. This means is_html_output()
has been fixed also, returning TRUE
when gfm+tex_math_dollars-yaml_metadata_block
was the format used (as showned in the error message)
The side effect of the issue was that flextable in github_document()
was not seeing this as a HTML output so doing some saving to image, and after the knitr change, it was considered as a HTML output and then some HTML dependencies were introduced in a GFM output which is not expected usually (hence the issue).
This is fixed in flextable now (https://github.com/davidgohel/flextable/commit/6e53256e04afbecae3e72415630b6991084eb2aa) where gfm
is excluded of format considered as being HTML.
Thanks for the report in here ! It will be useful to others that will also bump into this necessary change.
I would like to add that this also breaks flextable
for reprexes:
reprex::reprex(flextable::flextable(mtcars), std_out_err = TRUE)
This reprex appears to crash R. See standard output and standard error for more details.
Error : Functions that produce HTML output found in document targeting gfm-yaml_metadata_block output.
Please change the output type of this document to HTML.
If your aiming to have some HTML widgets shown in non-HTML format as a screenshot,
please install webshot or webshot2 R package for knitr to do the screenshot.
Alternatively, you can allow HTML output in non-HTML formats
by adding this option to the YAML front-matter of
your rmarkdown file:
always_allow_html: true
Note however that the HTML output will not be visible in non-HTML formats.
Not sure if that message is still valid:
If your aiming to have some HTML widgets shown in non-HTML format as a screenshot, please install webshot or webshot2 R package for knitr to do the screenshot.
packageVersion("webshot")
#> [1] '0.5.4'
packageVersion("webshot2")
#> [1] '0.1.0'
Created on 2023-08-04 with reprex v2.0.2
Even adding venue = "html"
creates the same error:
reprex::reprex(flextable::flextable(mtcars), venue = "html")
#> ℹ Non-interactive session, setting `html_preview = FALSE`.
#> ℹ Rendering reprex...
#> Error in `reprex_render()`:
#> ! This reprex appears to crash R. Call `reprex()` again with
#> `std_out_err = TRUE` to get more info.
#> Backtrace:
#> ▆
#> 1. └─reprex::reprex(flextable::flextable(mtcars), venue = "html")
#> 2. └─reprex:::reprex_impl(...)
#> 3. └─reprex:::reprex_render_impl(...)
#> 4. └─cli::cli_abort(...)
#> 5. └─rlang::abort(...)
Created on 2023-08-04 with reprex v2.0.2
Edit: The development (but not CRAN) version of flextable
fixes this issue.
packageVersion("flextable")
#> [1] '0.9.3.2'
Created on 2023-08-04 with reprex v2.0.2
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.
By filing an issue to this repo, I promise that
xfun::session_info('knitr')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr')
:update.packages(ask = FALSE, checkBuilt = TRUE)
andremotes::install_github('yihui/knitr', upgrade = TRUE)
, and updated RStudio and RI understand that my issue may be closed if I don't fulfill my promises.
knitr version 1.41
and above now breaks the natural htmlflextable
towebshot
image integration for GitHub/md documents. Reprex:knitr 1.40
(works)knitr 1.43.1
(errors)