Plugin prototype to run python code blocks using `pyodide`

Hi everyone,

I’m starting with logseq and I spent some time this weekend playing with plugins and code to better understand the tool and how I can adapt it to my needs.

I’ve read about running python code inside logseq modifying custom.js but I tried to create a plugin to allow this functionality in a simpler way for everyone. Maybe this already exists but I couldn’t find it.

The prototype can be downloaded from here. In the link you will find instructions to install the plugin.

Here is a dummy example

The code is a little mess as I’m more experienced with Python than with js and it is my first time with node, electron and most of this stuff (not with vanilla js in the browser) and I do not understand many things yet.

At this stage it is pretty simple what it does. In the code there are some comments to download other stuff like numpy, matplotlib or pandas. Now, it captures the stdout and the result is shown in a message. This is not practical nor very useful. There is no support for images/matplotlib, stderr, etc.

Actually I would prefer to use other tools for code and logseq for my notes and running code there is not the best idea, IMHO, Unix philosophy, but I thought it would be cool for others to use this prototype to do some other cool stuff or to use python/pyodide to create other logseq plugins.