From 4f2fe8135704f6da20dd1fb69ab78a4d2e206247 Mon Sep 17 00:00:00 2001 From: Xie Zejian Date: Mon, 3 Jul 2023 02:38:28 +0800 Subject: [PATCH] feat: support jupytext py:percent flavor cell magic (#84) --- lua/jupynium/cells.lua | 2 +- src/jupynium/buffer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/jupynium/cells.lua b/lua/jupynium/cells.lua index 77f6282..c6d21be 100644 --- a/lua/jupynium/cells.lua +++ b/lua/jupynium/cells.lua @@ -16,7 +16,7 @@ function M.line_type(line) return "cell separator: markdown (string)" elseif utils.string_begins_with(line, "# %% [md]") or utils.string_begins_with(line, "# %% [markdown]") then return "cell separator: markdown (jupytext)" - elseif utils.string_begins_with(line, "# %%") then + elseif vim.fn.trim(line) == "# %%" then return "cell separator: code" elseif utils.string_begins_with(line, '%%"""') or utils.string_begins_with(line, "%%'''") then return "cell separator: code (string)" diff --git a/src/jupynium/buffer.py b/src/jupynium/buffer.py index 1d0d998..07347da 100644 --- a/src/jupynium/buffer.py +++ b/src/jupynium/buffer.py @@ -91,7 +91,7 @@ def full_analyse_buf(self, header_cell_type="header"): num_rows_this_cell = 1 cell_types.append("markdown (jupytext)") elif ( - line.startswith("# %%") + line.strip() == "# %%" or line.startswith('%%"""') or line.startswith("%%'''") ):