On Tue, Oct 29, 2024 at 12:31 AM Thomas Passin <tbp100...@gmail.com> wrote:

> I need some guidance on edge cases before I can get the script to indent
> beyond one level.
>
>
Ah, there are so many edge cases. My suggestion is to only extract nodes at
the markdown heading level without smaller subnodes. That is,

``` jupytext
# %% [markdown]
# # header 1

# %%
print("python1")

# %% [markdown]
# ## header 1.1

# %%
print("python1.1")

# %% [markdown]
# ### header 1.1.1

# %% [markdown]
# ##### header 1.1.1.1.5

# %%
print("python1.1.1.1.5")
```

Only generate nodes corresponding to the markdown Headings level, that is,
only generate
```
# header 1
## header 1.1
### header 1.1.1
##### header 1.1.1.1.5
```

These 4 nodes (do not need to be indented to become child nodes). This
should make the code simpler and there is no need to consider edge cases.
(If all the original cells are turned into nodes, there may be too many
nodes; if there is no markdown heading, then do nothing)

The reason is that in jupyter lab, we can already see the indentation of
its markdown heading level directly, and we don’t need to copy its display
form to Leo. More likely to use it is that we will manually reorganize the
content in the form of Leo.

In addition to the above command, I think it is enough to add a Leo form
with only four nodes, flattening it back to the original @jupytext node
without any child nodes. This is very simple, iterate the contents of all
the child nodes of the current node, append to the end of the current node,
and then delete these four nodes.

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/leo-editor/CA%2BUQrQyLdPS1OhD%2B-AW2WF3C0n2Xt%2BCJXTkp2vaow3q2t%2B_yBw%40mail.gmail.com.

Reply via email to