cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.15k stars 81 forks source link

Support `cell` Scope Type in Plaintext Notebooks #1980

Open C-Loftus opened 1 year ago

C-Loftus commented 1 year ago

Plaintext Notebooks along the lines of https://github.com/mwouts/jupytext are a good choice for voice coding instead of the specialized editors like the VSCode Jupyter Extension. It is easier to move cells around and manipulate text given the fact that they are all part of the same file (whereas in the extension each cell is its own pseudo file)

Currently the cell scope type does not support these sorts of plaintext notebooks where each cell is created with the characters # %% We would also need to support # %% [markdown] to declare a markdown block. According to the behavior of the vscode implementation, a cell is defined as having exactly one leading # then at least two % symbols on the same line, directly after, not including whitespace. There can be any number of spaces between these declaraction characters and any character after the last %

Examples of valid cells (each of these will create a new cell and cause the visual studio code extension to label it as such)

    # %%

    # %% test

    # %%%%% test2

    # %%%

    #           %%%%%

    # %% [markdown]

Example of Invalid Cells

    ##%%

    #### %%

    # test # %%

    ### %%% test

An example of using it can be found below image More documentation can be found here: https://code.visualstudio.com/docs/python/jupyter-support-py

C-Loftus commented 1 year ago

just wanted to note as well that the discussion on quarto here https://github.com/cursorless-dev/cursorless/issues/880 might be of relevance. it appears that certain plaintext notebooks use the markdown code cells syntax as well instead so what is considered a cell might have to be parsed slightly differently depending on the type of plaintext notebook.