#1623·jupytext

py:percent behavior

Author: jbaronCreated Aug 7, 2026Updated Aug 7, 2026

Noticed that jupytext handles py:percent slightly different than f.e vscode.

python
# %% [markdown]
# some text
print("hello")

In the above example print("hello") is considered to the part of the markdown cell and becomes just plain text in the documentation when converted to a notebook.

In vscode however this creates implicitly a new code cell when executing this Python file (so even without including a new # %%). Seems any non-empty line that doesn't start with a # , creates a code cell.

Couldn't find a formal spec for py:percent. But the vscode approach makes more sense since including the code as plain unformatted text is seldom what you want.

BTW, minor finding since I can always insert a # %% and then jupytext and vscode behave the same.