-
Notifications
You must be signed in to change notification settings - Fork 91
Description
Trying to wrap my head how best to capture outputs between looking here and the quarto-live repo. A small snippet in example/ would help tremendously. Also it seems like the best route is to capture outputs from within R?
From quarto-live we use R and evaluate to eval the code wrapped in webR.captureR
https://github.com/r-wasm/quarto-live/blob/bfd6811e6dc804a7b8bc8653ff5d20dee67bb103/live-runtime/src/evaluate-webr.ts#L210
We then loop through our result object after evaluating our R code and handle each case, one worth noting is using replayPlot to capture plot outputs
https://github.com/r-wasm/quarto-live/blob/bfd6811e6dc804a7b8bc8653ff5d20dee67bb103/live-runtime/src/evaluate-webr.ts#L439
And have a handful of helper functions to append html output via asHtml
https://github.com/r-wasm/quarto-live/blob/bfd6811e6dc804a7b8bc8653ff5d20dee67bb103/live-runtime/src/evaluate-webr.ts#L248
Then for widgets knitr is required and I must be using knit_asis to capture widgets using staticRender()?
https://github.com/r-wasm/quarto-live/blob/bfd6811e6dc804a7b8bc8653ff5d20dee67bb103/live-runtime/src/evaluate-webr.ts#L571
https://github.com/r-wasm/quarto-live/blob/bfd6811e6dc804a7b8bc8653ff5d20dee67bb103/live-runtime/src/evaluate-webr.ts#L496
From webR examples appears I can handle this all natively
https://github.com/r-wasm/webr/blob/04cdbae6795fcaa20f01c2bf48a35d51b23643b5/src/examples/plot/plot.js#L16:L25
So I guess my follow would be is there a way to handle widgets similarly from webR without knitr? Also this is all in the context of say a repl app for example I want to eval R code and capture what it returns.