nbsync 0.3.4__py3-none-any.whl → 0.3.6__py3-none-any.whl
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/cell.py +19 -8
- nbsync/markdown.py +2 -2
- {nbsync-0.3.4.dist-info → nbsync-0.3.6.dist-info}/METADATA +2 -2
- {nbsync-0.3.4.dist-info → nbsync-0.3.6.dist-info}/RECORD +6 -6
- {nbsync-0.3.4.dist-info → nbsync-0.3.6.dist-info}/WHEEL +0 -0
- {nbsync-0.3.4.dist-info → nbsync-0.3.6.dist-info}/licenses/LICENSE +0 -0
nbsync/cell.py
CHANGED
@@ -50,10 +50,8 @@ class Cell:
|
|
50
50
|
include_attrs=True,
|
51
51
|
include_identifier=bool(identifier),
|
52
52
|
)
|
53
|
-
|
54
|
-
result =
|
55
|
-
if escape and self.mime == "text/plain":
|
56
|
-
result = html.escape(result)
|
53
|
+
self.image.url = ""
|
54
|
+
result = get_text_markdown(self, escape=escape)
|
57
55
|
|
58
56
|
else:
|
59
57
|
source = get_source(
|
@@ -61,7 +59,7 @@ class Cell:
|
|
61
59
|
include_attrs=False,
|
62
60
|
include_identifier=bool(identifier),
|
63
61
|
)
|
64
|
-
result =
|
62
|
+
result = get_image_markdown(self)
|
65
63
|
|
66
64
|
if markdown := get_markdown(kind, source, result, tabs):
|
67
65
|
return textwrap.indent(markdown, self.image.indent)
|
@@ -77,7 +75,8 @@ def get_source(
|
|
77
75
|
) -> str:
|
78
76
|
attrs = [cell.language]
|
79
77
|
if include_attrs:
|
80
|
-
|
78
|
+
parts = cell.image.iter_parts(exclude_attributes=["result"])
|
79
|
+
attrs.extend(parts)
|
81
80
|
attr = " ".join(attrs)
|
82
81
|
|
83
82
|
source = cell.image.source
|
@@ -87,7 +86,19 @@ def get_source(
|
|
87
86
|
return f"```{attr}\n{source}\n```"
|
88
87
|
|
89
88
|
|
90
|
-
def
|
89
|
+
def get_text_markdown(cell: Cell, *, escape: bool = False) -> str:
|
90
|
+
text = str(cell.content.rstrip())
|
91
|
+
|
92
|
+
if lang := cell.image.attributes.get("result", ""):
|
93
|
+
return f"```{lang}\n{text}\n```"
|
94
|
+
|
95
|
+
if escape and cell.mime == "text/plain":
|
96
|
+
return html.escape(text)
|
97
|
+
|
98
|
+
return text
|
99
|
+
|
100
|
+
|
101
|
+
def get_image_markdown(cell: Cell) -> str:
|
91
102
|
msg = f"{cell.image.url}#{cell.image.identifier} [{cell.mime}]"
|
92
103
|
logger.debug(f"Converting image: {msg}")
|
93
104
|
|
@@ -115,7 +126,7 @@ def get_markdown(kind: str, source: str, result: str, tabs: str) -> str:
|
|
115
126
|
return f"{result}\n\n{source}"
|
116
127
|
|
117
128
|
if kind == "material-block":
|
118
|
-
result = f'<div class="result" markdown="1"
|
129
|
+
result = f'<div class="result" markdown="1">\n{result}\n</div>'
|
119
130
|
return f"{source}\n\n{result}"
|
120
131
|
|
121
132
|
if kind == "tabbed-left":
|
nbsync/markdown.py
CHANGED
@@ -15,7 +15,7 @@ Element: TypeAlias = str | CodeBlock | Image
|
|
15
15
|
def convert_code_block(code_block: CodeBlock) -> Iterator[Element]:
|
16
16
|
for elem in _convert_code_block_tabbed(code_block):
|
17
17
|
if isinstance(elem, CodeBlock):
|
18
|
-
yield
|
18
|
+
yield _convert_code_block_attrs(elem)
|
19
19
|
else:
|
20
20
|
yield elem
|
21
21
|
|
@@ -35,7 +35,7 @@ def _convert_code_block_tabbed(code_block: CodeBlock) -> Iterator[Element]:
|
|
35
35
|
yield from nbstore.markdown.parse(text)
|
36
36
|
|
37
37
|
|
38
|
-
def
|
38
|
+
def _convert_code_block_attrs(code_block: CodeBlock) -> CodeBlock | Image:
|
39
39
|
exec_ = code_block.attributes.get("exec", None)
|
40
40
|
if exec_ != "1" or not code_block.classes:
|
41
41
|
return code_block
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nbsync
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.6
|
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
|
@@ -39,7 +39,7 @@ Classifier: Topic :: Documentation
|
|
39
39
|
Classifier: Topic :: Software Development :: Documentation
|
40
40
|
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
41
41
|
Requires-Python: >=3.10
|
42
|
-
Requires-Dist: nbstore>=0.
|
42
|
+
Requires-Dist: nbstore>=0.5.2
|
43
43
|
Description-Content-Type: text/markdown
|
44
44
|
|
45
45
|
# nbsync
|
@@ -1,11 +1,11 @@
|
|
1
1
|
nbsync/__init__.py,sha256=3NuWx9D0LcBnXjEKrC-uypNDOz8rLWXI7mIjdN9xSeE,126
|
2
|
-
nbsync/cell.py,sha256=
|
2
|
+
nbsync/cell.py,sha256=9e-Qo0VC-X_HN81IUJzXlK-8EB6EX4uOYNnPqipvCW4,4196
|
3
3
|
nbsync/logger.py,sha256=snNRqi9xESj4B-Z9GQffCBlgqeVujvuXuBveWAebIWM,736
|
4
|
-
nbsync/markdown.py,sha256=
|
4
|
+
nbsync/markdown.py,sha256=6jDaDtCEkDLsukInF0EnauJ2pUki6nVswjyu3Zg2AUE,3832
|
5
5
|
nbsync/notebook.py,sha256=4F3V1KDHfJnIR5ZSb1xWdN9JGiC6mWUVimXXK1BFsbc,1450
|
6
6
|
nbsync/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
nbsync/sync.py,sha256=vISzn8D_Dae-jdJABRnvvD02aL35bYIWx52OinAORVo,3990
|
8
|
-
nbsync-0.3.
|
9
|
-
nbsync-0.3.
|
10
|
-
nbsync-0.3.
|
11
|
-
nbsync-0.3.
|
8
|
+
nbsync-0.3.6.dist-info/METADATA,sha256=5QDV8YWYNWpb3miXM_nU6jI5qFrV3ktYWIJBS6Dlt_k,6551
|
9
|
+
nbsync-0.3.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
nbsync-0.3.6.dist-info/licenses/LICENSE,sha256=wy1pqn52upuo_qYwY-epWmspwE-3UWJso0xodciGXYc,1062
|
11
|
+
nbsync-0.3.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|