On Monday, October 28, 2024 at 6:27:34 PM UTC-5 Thomas wrote:
Wait! The imported file in the @jupytext node is already in juyptext
format, not JSON.
...
Anyway, the nice jupytext people have already done that work for us.
Thanks! Very helpful.
What needs to be done for producing the different indentation levels is to:
I'll read about your approach after I play with your prototype script.
I need to wrap my head around the assumptions of your script.
Edward
P.S. Here is a prototype script I wrote before realizing I had best
understand your script first!
g.cls()
import io
import jupytext
from leo.plugins.importers.markdown import do_import
path = r'c:\test\ekr-small-test.ipynb'
if 0: # Read the .ipynb file into raw_contents and dump it.
with open(path, 'r') as f:
raw_contents = f.read()
g.printObj(raw_contents)
if 0: # Dump the notebook in semi-readable format.
fmt = 'py:percent'
notebook = jupytext.read(path, fmt=fmt)
jm = g.app.jupytextManager
jm.dump_notebook(notebook)
if 0: # Import the contents as markdown.
# Read the pseudo python text into contents.
fmt = 'py:percent'
notebook = jupytext.read(path, fmt=fmt)
with io.StringIO() as f:
jupytext.write(notebook, f, fmt=fmt)
contents = f.getvalue()
# g.printObj(contents)
h = 'markdown-test'
p = g.findNodeAnywhere(c, h)
assert p, h
p.b = ''
p.deleteAllChildren()
do_import(c, p, contents)
c.redraw(p)
EKR
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/leo-editor/df99687d-34c1-4821-b248-781864dc3f42n%40googlegroups.com.