Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluto integration #125

Open
fonsp opened this issue May 7, 2024 · 11 comments
Open

Pluto integration #125

fonsp opened this issue May 7, 2024 · 11 comments

Comments

@fonsp
Copy link

fonsp commented May 7, 2024

Hi! It would be great if Pluto notebooks could work as an input format for Quarto! I talked briefly about this with @MichaelHatherly and with the Quarto devs at JupyterCon last year :) I believe that quite a nice integration is possible!

This issue could be used to collect ideas on what the integration would look like, and to find out whether there is interest in this feature.

@co1emi11er2
Copy link

Yes this would be an awesome integration! As someone who sees the potential use for this in my area of industry, let me know if I can help in any way.

@MichaelHatherly
Copy link
Collaborator

Hi! It would be great if Pluto notebooks could work as an input format for Quarto!

What do you have in mind with this integration? This backend just takes .qmds (or quarto's script format, https://quarto.org/docs/computations/render-scripts.html) and runs them. By integration are you meaning

quarto render path/to/pluto/notebook.jl

and have that "just work" for .jl files produced by Pluto?

@co1emi11er2
Copy link

I can take a shot at an idea. I don't know how Pluto, QuartoNotebookRunner (lets abreviate this to QNR), or Quarto work under the hood, so this could be completely wrong.

First question would be: If I had a pluto notebook that I kept linear in terms of cell order and stuck to the quarto script format, would this be rendered correctly already with QNR?

Idea

This is under the assumption that quarto passes the whole script to QNR and QNR does the parsing of the file. If quarto passes the cell chunks to QNR to then run, then this idea breaks down.

My idea would be:

1. Tell QNR that it is a pluto notebook.

It could be QNR determining that on its own by looking for the ### A Pluto.jl notebook ### or # ╔═╡ type symbols in the file. Or something in the yaml header block.

2. QNR would then let Pluto or PlutoDependencyExplorer to parse the file.

Hopefully we can keep the comments within the cell blocks to keep quarto commands so we can adjust outputs. I know macros parse comments out so it may have to be parsed back in afterwards depending on how pluto works.

By parsing the file I imagine having a list of code, output that is sorted not by the linear order needed to run the code, but by the order specified by how you see it rendered in the pluto document. I imagine that tooling is already there within pluto.

3. Parsed input/outputs passed to quarto to render

Now with this list quarto can then take that information to build the pdf/html/etc.

@MichaelHatherly
Copy link
Collaborator

This is under the assumption that quarto passes the whole script to QNR and QNR does the parsing of the file.

That is correct, quarto (the binary) passes the file contents as a whole to our backend, which then sends the cells to worker processes for evaluation.

The main question we need to address is still #125 (comment), what do you expect from the high-level user-interface for this? Just run quarto render directly on a Pluto notebook @co1emi11er2? Let's not worry about all the internal workings of everything just yet.

@co1emi11er2
Copy link

I guess the overall goal for me is to make it even more high level (no CLI). I want just an export or preview button inside pluto sort of like vscode extension where you can see the preview and saving the file will auto-render it again. But I would be fine with quarto render as the starting point for sure.

Most of the people I hope to convince to use pluto do not know the terminal, julia, quarto, or python. Our main tool for calculations is excel, so the more things I can pull away from a CLI, the better.

@MichaelHatherly
Copy link
Collaborator

Thanks. If this is just about getting nice Quarto renders of Pluto notebooks (which would be great) then the most straightforward way would be a feature directly in Pluto that uses quarto_jll.jl to shell out to quarto render and provides it as input a fully executed markdown/ipynb file that quarto already understands how to render.

That's pretty much what this package does internally anyway. We generate JSON output for executed .qmd in .ipynb format that quarto render already knew how to render.

@MichaelHatherly
Copy link
Collaborator

It would be great if Pluto notebooks could work as an input format for Quarto!

This one is a different request. Doing something like that requires first making quarto understand Pluto's notebook format. That is not actionable in this package. It'll need upstream changes.

@robot144
Copy link

For my work teaching, it would be great if topic explanations written as pluto files could be integrated into a website generated with quarto. The pluto files will then contain interactivity which will be rendered to html, so that the explanations can be read and figures seen. For interactivity, or even playing with the code, it would be great to have a link to the pluto file that can be pasted into a running pluto instance. Or even a link that opens the file in binder for example.

@younes-io
Copy link

younes-io commented Oct 13, 2024

is this abandoned? I think this would be really great! I've been waiting for this for months now and I hope it could become concrete some day..

Marimo (which is mainly inspired by Pluto) is working on something similar: https://docs.marimo.io/guides/exporting.html#embed-marimo-outputs-in-html-using-islands

Demo's here: https://docs.marimo.io/guides/island_example.html

@MichaelHatherly
Copy link
Collaborator

is this abandoned? I think this would be really great! I've been waiting for this for months now and I hope it could become concrete some day..

It isn't abandoned, just waiting on someone that wants this to take the time to do something about it. As in my previous comments, most of what's being requested here needs to be implemented upstream unless I'm misunderstanding what others have requested.

@jkrumbiegel
Copy link
Collaborator

jkrumbiegel commented Oct 14, 2024

Just adding a comment here that what was discussed further above, that quarto passes the input document as-is to QuartoNotebookRunner, is not quite true. There are shortcodes and other things that may modify the input markdown a bit before it reaches us. So quarto in general needs to be able to analyze the input, too, so it cannot just be something completely special that only QuartoNotebookRunner knows how to handle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants