Logseq like Jupyter Notebook et similia

Logseq is dope. Once you get used to it, you want its functionalities everywhere.

If you are a user of both Logseq and Jupyter Notebook et similia you know what I mean when I say that it would be great to have Logseq functionalities in interpreted/interactive notebooks.

I would like so have pieces of code in blocks in Logseq interpreted and rendered like in Jupyter Notebook, R Studio, Posit.co, Quarto.org ecc.

Maybe a block like this in Logseq:

```{python}
r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(
 subplot_kw = {'projection': 'polar'} 
)
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])
ax.grid(True)
plt.show()
```

could be rendered like this (example taken from quarto.org):

i.e. a piece of interactive HTML or just an image.

If you have any idea about this and how it could be implemented maybe with a Logseq plugin write it below.

What’s tricky in particular is interpreting languages like Python, R, Julia ecc using binaries that are available on our systems. But I would be happy even with a companion external tool that maybe manipulate the .md files and a Logseq plugin does the rendering.

Also it would be cool if some common languages like Python could access the page properties:: or even more data about the graph. Imagine running data analysis tools on your own knowledge graph from the same app (Logseq) you use to manage it.


CC @GaiusScotius

2 Likes

Absolutely on the same page here, excuse the pun!

What I would add, from R markdown running in R Studio, is the ability for code blocks in Clojure — the “native language” of Logseq — to be run in-process so that they have access to an API to navigate, query and amend the whole graph and can import data from external sources. This, I admit, carries the potential of inadvertently breaking the graph, but it is more flexible than having to construct a query and somehow export the results to an external process, as would be needed if the script was in another language. That said, I’d take the latter if that was an easier first step, with the caveat that {{query …}} needs to be able to do a graph walk.

2 Likes