VR3 Proposed Enhancement - Execute non-Python Code

48 views
Skip to first unread message

tbp1...@gmail.com

unread,
Feb 19, 2021, 12:10:08 AM2/19/21
to leo-editor
I've been prototyping new functionality for Viewrendered3 that would allow for non-python code to be executed.  It's working, but it also has some limitations.  I'd like suggestions as to whether this functionality will be worthwhile or whether it would be too limited.  To execute code blocks, an external program is needed.  For example, to execute julia code, julia.exe must be installed; for javascript, one option is graal.  The program must be able to run using a command line like

julia.exe test1.jl

Here is what the new functionality can do:
  1. Execute code blocks in a node or tree, even if they are not Python code;
  2. Display the resulting stdout and stderr, just as is currently done for Python code;
  3. The paths to external code execution programs are defined in an ini file located in Leo's .leo directory.
Here are the current limitations:
  1.  At present, only available for ReStructured Text.  Should be possible for MD and ASCIIDoc in the future;
  2. All code blocks in the node or tree must be for the same code language (e.g., julia);
  3. There is no way to pass arguments to the executing program.  For example, you cannot give a classpath to java.exe.
These are essentially the same limitations as for running Python code in VR3.

The ini file must be in a vr3 subdirectory of the .leo directory.  VR3 reads this file on startup to discover what languages are known and the paths to their executables.  Currently, julia and javascript can be set up.

The ini file must have a section like the following:

[executables]
javascript = D:\usr\graalvm-ce-java11-20.0.0\languages\js\bin\js.exe
julia = C:\Users\tom\AppData\Local\Programs\Julia 1.5.3\bin\julia.exe


If any of the possible languages is not specified in the ini file, no error is raised; VR3 will simply not try to execute the code for that language (and will write a message to Leo's log pane).

One quirk is that some languages may not have a Leo colorizer file.  Julia is one of these.  However, the colorizer used by VR3 may still be able to colorize it (true for Julia).  In the body frame, Leo tries to colorize the code anyway as best it can, which can be a little strange, but in the VR3 rendering pane, the colorizing will be OK.

So please give me your thoughts about this experimental functionality.  It's not available for anyone else to play with yet, but I could arrange that if anyone wants.


tbp1...@gmail.com

unread,
Feb 19, 2021, 11:53:08 AM2/19/21
to leo-editor
I just found a JEdit colorizer code for Julia, and converted it using Leo's Jedit2Py script button.  It worked perfectly, so now we can have Leo colorizing Julia files.

Edward K. Ream

unread,
Feb 22, 2021, 10:43:30 AM2/22/21
to leo-editor
On Thu, Feb 18, 2021 at 11:10 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
I've been prototyping new functionality for Viewrendered3 that would allow for non-python code to be executed.  It's working, but it also has some limitations.  I'd like suggestions as to whether this functionality will be worthwhile or whether it would be too limited. 

Thanks for looking into this. In general, I think this kind of project is a worthwhile addition to Leo.

Edward

Edward K. Ream

unread,
Feb 22, 2021, 10:44:22 AM2/22/21
to leo-editor
On Fri, Feb 19, 2021 at 10:53 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
I just found a JEdit colorizer code for Julia, and converted it using Leo's Jedit2Py script button.  It worked perfectly, so now we can have Leo colorizing Julia files.

Thanks for this. Please create a PR for it.

Edward

tbp1...@gmail.com

unread,
Feb 22, 2021, 10:19:16 PM2/22/21
to leo-editor
Reply all
Reply to author
Forward
0 new messages