Skip to content

Commit eaaee5a

Browse files
Wh1isperdavidbrochartpre-commit-ci[bot]
authored
Support cell.source is [list, of, string] (#112)
* Support cell.source is [list, of, string] * Using cell_source for cell["source"] Co-authored-by: David Brochart <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Using one notebook with two kind of cell * Using cell_source in rhs Co-authored-by: David Brochart <[email protected]> * Fix indentation Co-authored-by: David Brochart <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 5f52621 commit eaaee5a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

jupyter_ydoc/ydoc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ def create_ycell(self, value: Dict[str, Any]) -> Y.YMap:
320320
if "id" not in cell:
321321
cell["id"] = str(uuid4())
322322
cell_type = cell["cell_type"]
323-
cell["source"] = Y.YText(cell["source"])
323+
cell_source = cell["source"]
324+
cell_source = "".join(cell_source) if isinstance(cell_source, list) else cell_source
325+
cell["source"] = Y.YText(cell_source)
324326
cell["metadata"] = Y.YMap(cell.get("metadata", {}))
325327

326328
if cell_type in ("raw", "markdown"):

tests/files/nb0.ipynb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "code",
5+
"source": [
6+
"print('Hello, World!')"
7+
],
8+
"metadata": {},
9+
"outputs": [],
10+
"execution_count": null,
11+
"id": null
12+
},
313
{
414
"cell_type": "code",
515
"source": "print('Hello, World!')",

0 commit comments

Comments
 (0)