quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.95k stars 326 forks source link

quarto in the browser #263

Open thomasballinger opened 2 years ago

thomasballinger commented 2 years ago

It'd be neat to run Quarto in the browser, I'm wondering if this is a design goal or perhaps if it's explicitly not. I just found some notes I wrote up a few months ago about various quarto-cli deps:

Deno

It's a goal of Deno to be browser-compatible.

esbuild is probably the way to go here? And factoring stuff out?

Pandoc

There's an Asterius-built pandoc executable available at https://asterius.netlify.app/demo/pandoc/pandoc.html but I haven't found the code that builds it.

There's an old GHCJS-compiled pandoc too.

It's not clear that either of these keep the lua functionality intact? There's been lots of back and forth trying to get the C bits out of pandoc, but currently there are C dependencies. The lua filters seem to be integral to Quarto. There are definitely Emscripten builds of Lua out there, but the integration might be tricky.

ESBuild

Is this maybe a runtime dependency? there's a wasm version available at esbuild-wasm on npm, see https://esbuild.github.io/getting-started/#wasm

SASS

There's a version of SASS compiled to JavaScript on npm.

R

I heard from Pyodide folks that discussions of compiling R to the browser petered out because there was so much Fortran involved. It seems like R isn't required to run to run Quarto at all, but I want to check because when commands like quarto serve error on my if I don't have Shiny R library installed, suggesting there's some R in there somewhere. edit: I misunderstood what quarto serve does, it's explicitly for Shiny apps.

jjallaire commented 2 years ago

Yes, we would definitely like to run Quarto in the browser! You are correct that R is not required for Quarto so that's not a gating factor.

I think Pandoc is going to be the long pole here. You are correct that we make extensive use of Lua filters. Even though getting C dependencies out has been a consideration I don't think this is an overriding concern (as the pandoc.List Lua object was re-written in C for performance just this past release).

thomasballinger commented 2 years ago

Great to hear! Yeah I'm worried getting a Pandoc build with lua support will require getting deep into emscripten and one of the Haskell to WebAssembly toolchains to do the linking. A project I'm not going to tackle now, but I'll keep an eye on that world.

thomasballinger commented 2 years ago

Working with Tweag might be a way to do this, Asterious has a demo compiling pandoc but no source available (and I assume without lua filters working).

thomasballinger commented 2 years ago

As stated above this isn't a blocker, but sounds like there are efforts to get R in the browser, it's not stuck like I said above: https://github.com/georgestagg/webR & see https://chrz.de/2020/04/21/fortran-in-the-browser for info about how to get FORTRAN in (h/t @mdboom)

thomasballinger commented 2 years ago

Cheng Shao and Tweag, the consultancy they're affiliated with, are working to add WebAssembly support to ghc: https://asterius.netlify.app/milestones-2022-01.html

But they say

hslua support is another story, since I'm not familiar with lua internals, so I'm not sure if the c toolchain we use is sufficient to support it.

Sounds like it makes sense to wait for the out-of-the-box pandoc support that a WebAssembly-capable ghc promises, but figuring out the lua story may be extra work.