nbsync 0.3.8__tar.gz → 0.3.9__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nbsync
3
- Version: 0.3.8
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
5
  Keywords: jupyter,notebook,documentation,markdown,python,visualization,dynamic-execution,real-time-sync
6
6
  Author: daizutabi
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "nbsync"
7
- version = "0.3.8"
7
+ version = "0.3.9"
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" }
@@ -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,16 +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 result := cell.image.attributes.get("result", ""):
93
- if not is_truelike(result):
94
- lang = result
95
- return f"```{lang}\n{text}\n```"
96
-
97
- if cell.mime == "text/plain":
98
- return f"```text\n{text}\n```"
92
+ if result:
93
+ result = "text" if is_truelike(result) else result
94
+ return f"```{result}\n{text}\n```"
99
95
 
100
96
  if escape and cell.mime == "text/plain":
101
97
  return html.escape(text)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes