nbsync 0.3.7__py3-none-any.whl → 0.3.9__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 CHANGED
@@ -31,8 +31,9 @@ class Cell:
31
31
  kind = self.image.attributes.pop("source", "")
32
32
  tabs = self.image.attributes.pop("tabs", "")
33
33
  identifier = self.image.attributes.pop("identifier", "")
34
+ result = self.image.attributes.pop("result", "")
34
35
 
35
- if "/" not in self.mime or not self.content or kind == "source-only":
36
+ if "/" not in self.mime or not self.content or kind == "only":
36
37
  if self.image.source:
37
38
  source = get_source(
38
39
  self,
@@ -42,7 +43,7 @@ class Cell:
42
43
  kind = "only"
43
44
  else:
44
45
  source = ""
45
- result, self.image.url = "", ""
46
+ result = self.image.url = ""
46
47
 
47
48
  elif self.mime.startswith("text/") and isinstance(self.content, str):
48
49
  source = get_source(
@@ -51,7 +52,7 @@ class Cell:
51
52
  include_identifier=bool(identifier),
52
53
  )
53
54
  self.image.url = ""
54
- result = get_text_markdown(self, escape=escape)
55
+ result = get_text_markdown(self, result, escape=escape)
55
56
 
56
57
  else:
57
58
  source = get_source(
@@ -75,8 +76,7 @@ def get_source(
75
76
  ) -> str:
76
77
  attrs = [cell.language]
77
78
  if include_attrs:
78
- parts = cell.image.iter_parts(exclude_attributes=["result"])
79
- attrs.extend(parts)
79
+ attrs.extend(cell.image.iter_parts())
80
80
  attr = " ".join(attrs)
81
81
 
82
82
  source = cell.image.source
@@ -86,11 +86,12 @@ def get_source(
86
86
  return f"```{attr}\n{source}\n```"
87
87
 
88
88
 
89
- def get_text_markdown(cell: Cell, *, escape: bool = False) -> str:
89
+ def get_text_markdown(cell: Cell, result: str, *, escape: bool = False) -> str:
90
90
  text = str(cell.content.rstrip())
91
91
 
92
- if lang := cell.image.attributes.get("result", ""):
93
- return f"```{lang}\n{text}\n```"
92
+ if result:
93
+ result = "text" if is_truelike(result) else result
94
+ return f"```{result}\n{text}\n```"
94
95
 
95
96
  if escape and cell.mime == "text/plain":
96
97
  return html.escape(text)
@@ -1,45 +1,46 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.3
2
2
  Name: nbsync
3
- Version: 0.3.7
3
+ Version: 0.3.9
4
4
  Summary: A core library to synchronize Jupyter notebooks and Markdown documents, enabling seamless integration and dynamic content execution
5
- Project-URL: Documentation, https://daizutabi.github.io/nbsync/
6
- Project-URL: Source, https://github.com/daizutabi/nbsync
7
- Project-URL: Issues, https://github.com/daizutabi/nbsync/issues
5
+ Keywords: jupyter,notebook,documentation,markdown,python,visualization,dynamic-execution,real-time-sync
6
+ Author: daizutabi
8
7
  Author-email: daizutabi <daizutabi@gmail.com>
9
8
  License: MIT License
10
-
11
- Copyright (c) 2025 Daizu
12
-
13
- Permission is hereby granted, free of charge, to any person obtaining a copy
14
- of this software and associated documentation files (the "Software"), to deal
15
- in the Software without restriction, including without limitation the rights
16
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- copies of the Software, and to permit persons to whom the Software is
18
- furnished to do so, subject to the following conditions:
19
-
20
- The above copyright notice and this permission notice shall be included in all
21
- copies or substantial portions of the Software.
22
-
23
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- SOFTWARE.
30
- License-File: LICENSE
31
- Keywords: documentation,dynamic-execution,jupyter,markdown,notebook,python,real-time-sync,visualization
9
+
10
+ Copyright (c) 2025 Daizu
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
32
29
  Classifier: Development Status :: 4 - Beta
33
30
  Classifier: Programming Language :: Python
34
31
  Classifier: Programming Language :: Python :: 3.10
35
32
  Classifier: Programming Language :: Python :: 3.11
36
33
  Classifier: Programming Language :: Python :: 3.12
37
34
  Classifier: Programming Language :: Python :: 3.13
35
+ Classifier: Programming Language :: Python :: 3.14
38
36
  Classifier: Topic :: Documentation
39
37
  Classifier: Topic :: Software Development :: Documentation
40
38
  Classifier: Topic :: Text Processing :: Markup :: Markdown
41
- Requires-Python: >=3.10
42
39
  Requires-Dist: nbstore>=0.5.2
40
+ Requires-Python: >=3.10
41
+ Project-URL: Documentation, https://daizutabi.github.io/nbsync/
42
+ Project-URL: Issues, https://github.com/daizutabi/nbsync/issues
43
+ Project-URL: Source, https://github.com/daizutabi/nbsync
43
44
  Description-Content-Type: text/markdown
44
45
 
45
46
  # nbsync
@@ -144,6 +145,22 @@ Use standard Markdown image syntax with the figure identifier:
144
145
  ![Chart description](my-notebook.ipynb){#my-figure}
145
146
  ```
146
147
 
148
+ ### Control how results render
149
+
150
+ You can control how executed outputs render using attributes:
151
+
152
+ - `source`: where to place the source relative to the result.
153
+ Supported values include `on`/`1` (above), `below`, `only`,
154
+ `material-block`, `tabbed-left`, `tabbed-right`. See tests for details.
155
+ - `result`: wrap the execution result in a fenced code block using the
156
+ given language (similar to mkdocs-exec). For example:
157
+
158
+ ````markdown
159
+ ```python exec="1" result="text"
160
+ print(2)
161
+ ```
162
+ ````
163
+
147
164
  ## The Power of Separation
148
165
 
149
166
  Creating documentation and developing visualizations involve different
@@ -0,0 +1,10 @@
1
+ nbsync/__init__.py,sha256=dcdb96c7d0f42dc0675e310aac2faeca93433b3f2b2d65c8ee622374df7149e1,126
2
+ nbsync/cell.py,sha256=329fc181d8dd9ded8e6d86cf24e3f3fc3abd7ea6396e765c1ddc040dc7876d7e,4233
3
+ nbsync/logger.py,sha256=b27351aa2f711128f807e67d1907df081960a9e56e8efb97b81bde58079b2163,736
4
+ nbsync/markdown.py,sha256=ea30da0ed0849032ecba42271741276ae276a54922ea756cc23caedd98360141,3832
5
+ nbsync/notebook.py,sha256=e05dd5d4a0c77c99c84796526f5c5674df491a20ba9965158a65d72b5045b1b7,1450
6
+ nbsync/py.typed,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
7
+ nbsync/sync.py,sha256=bc84b39fc0ff0da7be8dd2400519efbc3d3668bdf96d8216c79d8e8a700e455a,3990
8
+ nbsync-0.3.9.dist-info/WHEEL,sha256=2b400f346628f0064eb5bbf656b39df8dfcb092437ab08244409d295749b81a3,78
9
+ nbsync-0.3.9.dist-info/METADATA,sha256=d5966bfd9c5578e334b129b7dee4c8b0bd54d08d7a50d92a44ea0eb84837b6f7,7104
10
+ nbsync-0.3.9.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.8.9
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -1,11 +0,0 @@
1
- nbsync/__init__.py,sha256=3NuWx9D0LcBnXjEKrC-uypNDOz8rLWXI7mIjdN9xSeE,126
2
- nbsync/cell.py,sha256=9e-Qo0VC-X_HN81IUJzXlK-8EB6EX4uOYNnPqipvCW4,4196
3
- nbsync/logger.py,sha256=snNRqi9xESj4B-Z9GQffCBlgqeVujvuXuBveWAebIWM,736
4
- nbsync/markdown.py,sha256=6jDaDtCEkDLsukInF0EnauJ2pUki6nVswjyu3Zg2AUE,3832
5
- nbsync/notebook.py,sha256=4F3V1KDHfJnIR5ZSb1xWdN9JGiC6mWUVimXXK1BFsbc,1450
6
- nbsync/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- nbsync/sync.py,sha256=vISzn8D_Dae-jdJABRnvvD02aL35bYIWx52OinAORVo,3990
8
- nbsync-0.3.7.dist-info/METADATA,sha256=idJhAA4B2OqMCV0H589B6KDYhZGXLdRRzW-z-zc84PI,6551
9
- nbsync-0.3.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- nbsync-0.3.7.dist-info/licenses/LICENSE,sha256=wy1pqn52upuo_qYwY-epWmspwE-3UWJso0xodciGXYc,1062
11
- nbsync-0.3.7.dist-info/RECORD,,
@@ -1,4 +0,0 @@
1
- Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
3
- Root-Is-Purelib: true
4
- Tag: py3-none-any
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Daizu
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.