nbsync 0.3.4__py3-none-any.whl → 0.3.5__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
@@ -50,10 +50,8 @@ class Cell:
50
50
  include_attrs=True,
51
51
  include_identifier=bool(identifier),
52
52
  )
53
- result, self.image.url = self.content, ""
54
- result = result.rstrip()
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 = get_result(self)
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)
@@ -87,7 +85,19 @@ def get_source(
87
85
  return f"```{attr}\n{source}\n```"
88
86
 
89
87
 
90
- def get_result(cell: Cell) -> str:
88
+ def get_text_markdown(cell: Cell, *, escape: bool = False) -> str:
89
+ text = str(cell.content.rstrip())
90
+
91
+ if lang := cell.image.attributes.get("result", ""):
92
+ return f"```{lang}\n{text}\n```"
93
+
94
+ if escape and cell.mime == "text/plain":
95
+ return html.escape(text)
96
+
97
+ return text
98
+
99
+
100
+ def get_image_markdown(cell: Cell) -> str:
91
101
  msg = f"{cell.image.url}#{cell.image.identifier} [{cell.mime}]"
92
102
  logger.debug(f"Converting image: {msg}")
93
103
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbsync
3
- Version: 0.3.4
3
+ Version: 0.3.5
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
@@ -1,11 +1,11 @@
1
1
  nbsync/__init__.py,sha256=3NuWx9D0LcBnXjEKrC-uypNDOz8rLWXI7mIjdN9xSeE,126
2
- nbsync/cell.py,sha256=bXzchf46DP0pxhgL1W98f9jfOGVJi4-EoK2b1RX0N1c,3921
2
+ nbsync/cell.py,sha256=cloyTpAbZDCwvdA463-7ZBPiYfpk8NO7XjhJ77VkU-4,4141
3
3
  nbsync/logger.py,sha256=snNRqi9xESj4B-Z9GQffCBlgqeVujvuXuBveWAebIWM,736
4
4
  nbsync/markdown.py,sha256=xcPhQKWpFDyVQ_xtZCpFrnR0QED_hYs4PAyaT7dF3t4,3830
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.4.dist-info/METADATA,sha256=9TEbtLM655UYB7rQ7YoxFuSkrBodGzf4ox41Nz8tsEo,6552
9
- nbsync-0.3.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- nbsync-0.3.4.dist-info/licenses/LICENSE,sha256=wy1pqn52upuo_qYwY-epWmspwE-3UWJso0xodciGXYc,1062
11
- nbsync-0.3.4.dist-info/RECORD,,
8
+ nbsync-0.3.5.dist-info/METADATA,sha256=5XZaO_etW_QhKUkqLiPb1Ll5tDUQP-P6pyRqDpM0d54,6552
9
+ nbsync-0.3.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ nbsync-0.3.5.dist-info/licenses/LICENSE,sha256=wy1pqn52upuo_qYwY-epWmspwE-3UWJso0xodciGXYc,1062
11
+ nbsync-0.3.5.dist-info/RECORD,,
File without changes