nbsync 0.3.2__tar.gz → 0.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nbsync-0.3.2 → nbsync-0.3.4}/PKG-INFO +1 -1
- {nbsync-0.3.2 → nbsync-0.3.4}/pyproject.toml +1 -1
- {nbsync-0.3.2 → nbsync-0.3.4}/src/nbsync/cell.py +4 -1
- {nbsync-0.3.2 → nbsync-0.3.4}/src/nbsync/sync.py +2 -2
- {nbsync-0.3.2 → nbsync-0.3.4}/tests/test_cell.py +11 -1
- {nbsync-0.3.2 → nbsync-0.3.4}/.devcontainer/devcontainer.json +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/.devcontainer/postCreate.sh +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/.devcontainer/starship.toml +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/.gitattributes +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/.github/workflows/ci.yaml +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/.github/workflows/docs.yaml +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/.github/workflows/publish.yaml +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/.gitignore +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/LICENSE +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/README.md +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/docs/index.md +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/mkdocs.yaml +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/src/nbsync/__init__.py +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/src/nbsync/logger.py +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/src/nbsync/markdown.py +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/src/nbsync/notebook.py +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/src/nbsync/py.typed +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/tests/__init__.py +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/tests/conftest.py +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/tests/test_logger.py +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/tests/test_markdown.py +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/tests/test_notebook.py +0 -0
- {nbsync-0.3.2 → nbsync-0.3.4}/tests/test_sync.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nbsync
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.4
|
4
4
|
Summary: A core library to synchronize Jupyter notebooks and Markdown documents, enabling seamless integration and dynamic content execution
|
5
5
|
Project-URL: Documentation, https://daizutabi.github.io/nbsync/
|
6
6
|
Project-URL: Source, https://github.com/daizutabi/nbsync
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "nbsync"
|
7
|
-
version = "0.3.
|
7
|
+
version = "0.3.4"
|
8
8
|
description = "A core library to synchronize Jupyter notebooks and Markdown documents, enabling seamless integration and dynamic content execution"
|
9
9
|
readme = "README.md"
|
10
10
|
license = { file = "LICENSE" }
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
import html
|
3
4
|
import textwrap
|
4
5
|
import uuid
|
5
6
|
from dataclasses import dataclass
|
@@ -26,7 +27,7 @@ class Cell:
|
|
26
27
|
content: bytes | str
|
27
28
|
"""The content of the image."""
|
28
29
|
|
29
|
-
def convert(self) -> str:
|
30
|
+
def convert(self, *, escape: bool = False) -> str:
|
30
31
|
kind = self.image.attributes.pop("source", "")
|
31
32
|
tabs = self.image.attributes.pop("tabs", "")
|
32
33
|
identifier = self.image.attributes.pop("identifier", "")
|
@@ -51,6 +52,8 @@ class Cell:
|
|
51
52
|
)
|
52
53
|
result, self.image.url = self.content, ""
|
53
54
|
result = result.rstrip()
|
55
|
+
if escape and self.mime == "text/plain":
|
56
|
+
result = html.escape(result)
|
54
57
|
|
55
58
|
else:
|
56
59
|
source = get_source(
|
@@ -47,9 +47,9 @@ class Synchronizer:
|
|
47
47
|
continue
|
48
48
|
|
49
49
|
path = ".md" if url == ".md" else self.store.find_path(url)
|
50
|
-
logger.info(f"Executing notebook: {path}
|
50
|
+
logger.info(f"Executing notebook: {path}")
|
51
51
|
if elapsed := notebook.execute():
|
52
|
-
logger.info(f"{Path(path).name!r} executed in {elapsed} seconds")
|
52
|
+
logger.info(f"{Path(path).name!r} executed in {elapsed:.2f} seconds")
|
53
53
|
|
54
54
|
def convert(self, text: str) -> Iterator[str | Cell]:
|
55
55
|
elems = list(self.parse(text))
|
@@ -38,7 +38,7 @@ def convert(sync: Synchronizer):
|
|
38
38
|
def convert(text: str) -> str:
|
39
39
|
cell = next(sync.convert(text))
|
40
40
|
assert isinstance(cell, Cell)
|
41
|
-
return cell.convert()
|
41
|
+
return cell.convert(escape=True)
|
42
42
|
|
43
43
|
return convert
|
44
44
|
|
@@ -106,3 +106,13 @@ def test_unknown(convert):
|
|
106
106
|
def test_code_block_exec(convert):
|
107
107
|
x = convert('```python exec="1" source="1"\nprint(1+1)\n```')
|
108
108
|
assert x == "```python\nprint(1+1)\n```\n\n2"
|
109
|
+
|
110
|
+
|
111
|
+
def test_code_block_exec_escape_print(convert):
|
112
|
+
x = convert('```python exec="1" source="1"\nprint("<1>")\n```')
|
113
|
+
assert x == '```python\nprint("<1>")\n```\n\n<1>'
|
114
|
+
|
115
|
+
|
116
|
+
def test_code_block_exec_escape_stream(convert):
|
117
|
+
x = convert('```python exec="1" source="1"\n"<1>"\n```')
|
118
|
+
assert x == '```python\n"<1>"\n```\n\n'<1>''
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|