fonsp/PlutoUtils.jl

Feature request: converting a pluto notebook to markdown

GiggleLiu opened this issue · 8 comments

It will be a nice feature to have with which one can display a notebook in the documentation page with Documenter CI.

I tried to convert the Pluto notebook to a Jupyter notebook first with the online tool
https://observablehq.com/@olivier_plas/pluto-jl-jupyter-conversion

And then convert the notebook to markdown,
However the converted markdown file does not show the texts correctly. It displays raw julia sources codes like md"..."

fonsp commented

Should it contain code? Plots?

Yes, with code and outputs.

fonsp commented

That's tough

Yeah, the conversion between from html to md can be tough. This might be not neccesary considering many markdown readers can read html directly.

Will it be easier to transform it to html directly? So that it can still be deployed through the CI.

fonsp commented

Yeah it would! This is possible using the new UI in 0.11.8, but like you said, we also want to do it automatically, without opening the browser.

fonsp commented

Some inspiration:

https://github.com/esowc/Elefridge.jl

Makes me think that the github renderer should be the target

Since Documenter.jl can run code examples and capture and display the output, it would perhaps be enough to export a notebook to markdown that contains Documenter.jl @example code blocks. Then Documenter would run the code during docs build and capture the same output as was displayed in the notebook.

fonsp commented

I made a prototype for this here: https://github.com/fonsp/Promises.jl/blob/main/tools/generate_readme2.jl , result is https://github.com/fonsp/Promises.jl/blob/main/README.md which is generated from https://github.com/fonsp/Promises.jl/blob/main/src/notebook.jl .

This was fun&cute for github READMEs (where you have to provide Markdown), but for other SSR purposes, like generating websites/PDFs, I think that outputting HTML directly is much more useful. (Markdown is a poor intermediate format (if the end goal is HTML), because its minimalism makes it a "feature bottleneck".) Take a look at https://github.com/rikhuijzer/PlutoStaticHTML.jl for outputting HTML!