On 6/14/19 1:10 PM, Jason Sun wrote:
With the help of the reticulate package and knitr package, we are able to now embed python and R
code in lyx in a reproducible manner. But the problem is that we have to compile the file every time
we need to see the execution result of the python/R code. In jupyter notebook, this is not
necessary and we can run the code chunks independently.
So the question is whether its possible to implement a similar functionality in future lyx versions?
Briefly, the feature could be abstracted in the following manner:
1. Create a procedure to copy the code in the ERT/code chunks, open a new subprocess, in which runs
the python/R REPL and paste the code into a subprocess.
2. Run the code.
3. Return the result in the a panel/window.
4. Closed the subprocess.
Is something like this possible?
This is a late reply, but I only recently checked this newsgroup
again and came across your posting.
Back in 2012 I put out a project called Lyx Notebook, the purpose of
which is to turn Lyx into a code-evaluating notebook similar to
Mathematica notebooks. The GitHub page is:
https://github.com/abarker/lyxNotebook
Jupyter notebooks weren't really a thing back then. This program runs
separate interpreters for all the languages it supports, evaluates
code cells/insets in the appropriate interpreter, and then writes the
output into an output cell/inset. The main Python process communicates
with Lyx via Lyx server pipes. There is a PDF doc file that shows
some screenshots, etc., located at
https://github.com/abarker/lyxNotebook/blob/master/doc/lyxNotebookDocs.pdf
The program worked fairly well, though it remains beta-level software.
It mostly still works. I stopped working on it for a while for a
couple of reasons. First, the reception I got when I announced it was
essentially crickets. More importantly, I lacked the proper LFUN to
extract text from a cell and update/edit it. The mechanism I used was
a slow kludge where a magic-cookie string is inserted into the inset,
the buffer is written to a file, and the program searches the file for
that string to get the text. Finally, the cookie string is deleted.
I was interested to read in a later, related thread that Lyx 2.4.0 will
likely have a mechanism to edit/extract text from general insets. That
could make the program work much better. Just recently I cleaned up the
code some (I hadn't been using Python very long when I wrote the first
version) and converted to a proper setup.py/pip install with entry point
scripts.
--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel