yihui / knitr

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

New behavior of the `knit2html` function - `fragment.only` parameter is not respected anymore #2252

Closed federicomarini closed 1 year ago

federicomarini commented 1 year ago

Hi,

This issue is related to https://github.com/federicomarini/ideal_serveredition/issues/11

In brief: I have in my shiny app the functionality to render "in the app" a preview of the report.

https://github.com/federicomarini/ideal/blob/a4595a58227d4b2ff8153744285d8385451f5384/R/ideal.R#L4719

This uses the knitr::knit2html function, which had a parameter fragment.only, set to TRUE so that I could simply "embed" the generated html without scrambling up the css of the app.

Now somehow the knit2html does not care about the parameter anymore and it throws the error reported by @tamuanand. If I remove that, I obtain the report preview but in a way that messes up the look of the app itself.

Something like this:

image

whereas it used to look like this:

image

Is there a way to keep that functionality? Or alternatively, an even better way to include the "preview on the fly" of the Rmd report?

Thanks in advance!

Federico


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.

federicomarini commented 1 year ago

If there are more elegant ways of doing this, I am more than happy to learn how it is supposed to be done.

I am not afraid to say my solution was a bit clunky -- yet it worked 😬 Well, until recently at least

yihui commented 1 year ago

Is there a way to keep that functionality? Or alternatively, an even better way to include the "preview on the fly" of the Rmd report?

Yes, please use knit2html(..., template = FALSE) instead of fragment.only = TRUE. Sorry about the trouble!

The change was from the markdown package: https://github.com/rstudio/markdown/releases/tag/v1.3

federicomarini commented 1 year ago

Fantastic, thanks for the clarification - blazing fast AND positive reply, love it.

I did try to track it down into markdown but was not successful in doing that. Testing it right away!

federicomarini commented 1 year ago

... aaaaaand it works like a charm, as expected. Thanks @yihui , I know at least a long time user of ideal who will cheer with me for the quick solution (cc @tamuanand)

image
yihui commented 1 year ago

Great! Thanks for testing! I also appreciate your patience and understanding! Please do not hesitate to ask when you run into any trouble next time.

tamuanand commented 1 year ago

Hi @federicomarini and @yihui

thanks a lot

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.