Skip to content

addition of cell id introduced with nbformat>=4.5 to text format #1263

@itcarroll

Description

@itcarroll

Discussion on #735, after it was closed, pointed to the need for an issue on inclusion of the cell id in jupytext text formats. I can't find one, and I think it's an enhancement worth considering.

Currently, a cell id is preserved in paired notebooks, but there are cases where the paired notebook is not present. Primary among these is when only text formats are held in a git repository. In this case, collaborators that generate notebooks locally from the text format end up with all cells having a different id. I'm interested to know, is there support for directly incorporating the cell id in the "light" format?

The obvious proposal would be to require a start-of-cell delimiter for every cell and include the id. The id is distinct from metadata because 1) it is first and 2) is not a key=value pair (the "=" character is not permitted in a cell id).

The examples would become:

# +b457cb9f-93c0_456a-a652-3f597535aa2d
# This is a multiline
# Markdown cell

# +a99ac56a-3859_4a15-9023-bab26654380f
# Another Markdown cell


# +4e9a328c-7d49_4e7e-9af4-a9f86ccddd14
# This is a code cell
class A():
    def one():
        return 1

    def two():
        return 2
# +3435c495-ba0c_4ca6-8a65-7b3658b66733
# A single code cell made of two paragraphs
a = 1


def f(x):
    return x+a
# +a8345b4b-8282_47fe-96c4-1d2c02bc92ca key="value"
# A code cell with metadata

# +a8345b4b-8282_47fe-96c4-1d2c02bc92ca [markdown] key="value"
# A Markdown cell with metadata

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions