quarto-dev / quarto-r

R interface to quarto-cli
https://quarto-dev.github.io/quarto-r/
145 stars 24 forks source link

Integrating Quarto in shiny apps #213

Open davidrsch opened 2 months ago

davidrsch commented 2 months ago

From https://github.com/rstudio/shiny/issues/4123#issue-2510461372. I think that adding a function includeQuarto like includeMarkdown is a good idea to make easier to integrate quarto docs inside shinyapps

cderv commented 1 month ago

cc @gadenbuie as you pointed towards here 😉

We are talking about htmltools::includeMarkdown() which uses markdown package to convert some markdown file to HTML fragement right ?

I do think including a .qmd in a shiny app will require a fragment HTML, right ? Quarto does not have (yet) a rmarkdown::html_fragment() format and format: html would produce a full feature HTML that I don't think can be included in a shiny app.

How both you are seeing this in a shiny app context ?

gadenbuie commented 1 month ago

Quarto does not have (yet) a rmarkdown::html_fragment() format and format: html would produce a full feature HTML that I don't think can be included in a shiny app.

Maybe quarto could render the document and include it in an iframe? Although if Quarto had html fragments, that would also be helpful.

Anyway, I can broadly see the utility of this feature request but I also don't have a good sense of the scope of the feature or how people want to "integrate quarto docs inside shiny apps". My redirection came mostly from knowing that the quarto R package would be a better home for such a feature than shiny.

cderv commented 1 month ago

Maybe quarto could render the document and include it in an iframe?

This is definitely feasiblAe. Not sure what would be the benefice of making it inside quarto R package. But that is true on both side.

Although if Quarto had html fragments, that would also be helpful.

This is more complex because to make it correctly we would probably need a quarto format for this. Though I can make one specifically in this package by using format: html with custom template.

Problem of fragment is about the feature that would be used for the quarto document. To make them work, we need the head part. We could argue some of them could be available in shiny app already, but this implies both versions should really be in sync. Hope I am clear about my current thinking... 🤔

My redirection came mostly from knowing that the quarto R package would be a better home for such a feature than shiny.

At the end, I guess in the fragment case, I see why it would make sense for it to be in the package. This would be a quarto-r specific current format (like vignette engine). But for rendering a .qmd and including into shiny app through an iframe, I don't see what makes this package a better place. Though probably there is no better place... (just thinking about testing and problem resolution etc...)

Anyhow, thanks for the feature request @davidrsch. Having more information of context and usage for such feature will help us make it happen. Thanks

davidrsch commented 1 month ago

I have the idea of this feature while working on an app where I explain certain concepts about machine learning. For the explanation of these concepts I am using quarto docs. Right now I am integrating this into the app by rendering the quarto docs and embedding it's output inside an iframe. The idea of this feature it's to avoid rendering the quarto docs before building or updating the app.

If I change the content of the quarto documents but I do not update the rendered version of them the content displayed won't be updated. So it would be nice to have a way to automatically include the output of quarto render into shiny apps. Right now I am using it with html outputs but I can see this being used also for revealjs presentations and other formats.

cderv commented 1 month ago

@davidrsch in your case I understand inserting into shinyapps as an iframe is ok, and the pain point is the process for rendering.

If I change the content of the quarto documents but I do not update the rendered version of them the content displayed won't be updated.

I think the .qmd will still need to be rendered at some point. I am not sure how that would work with shiny. Do you want to edit you .qmd and then when running the shiny app, it re-rerender the doc ?

I am trying to get a sense of the use case and how that would work to know which function to add in this package.

davidrsch commented 1 month ago

This is the idea yes:

Do you want to edit you .qmd and then when running the shiny app, it re-rerender the doc ?

But now I see how there may be some downsides to this like the quarto documents rendering may slow down the app initiation

cderv commented 1 month ago

the quarto documents rendering may slow down the app initiation

Yes it will I think.