nbsync 0.3.5__tar.gz → 0.3.6__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.
Files changed (28) hide show
  1. {nbsync-0.3.5 → nbsync-0.3.6}/PKG-INFO +2 -2
  2. {nbsync-0.3.5 → nbsync-0.3.6}/pyproject.toml +2 -2
  3. {nbsync-0.3.5 → nbsync-0.3.6}/src/nbsync/cell.py +3 -2
  4. {nbsync-0.3.5 → nbsync-0.3.6}/src/nbsync/markdown.py +2 -2
  5. {nbsync-0.3.5 → nbsync-0.3.6}/tests/test_cell.py +20 -1
  6. {nbsync-0.3.5 → nbsync-0.3.6}/.devcontainer/devcontainer.json +0 -0
  7. {nbsync-0.3.5 → nbsync-0.3.6}/.devcontainer/postCreate.sh +0 -0
  8. {nbsync-0.3.5 → nbsync-0.3.6}/.devcontainer/starship.toml +0 -0
  9. {nbsync-0.3.5 → nbsync-0.3.6}/.gitattributes +0 -0
  10. {nbsync-0.3.5 → nbsync-0.3.6}/.github/workflows/ci.yaml +0 -0
  11. {nbsync-0.3.5 → nbsync-0.3.6}/.github/workflows/docs.yaml +0 -0
  12. {nbsync-0.3.5 → nbsync-0.3.6}/.github/workflows/publish.yaml +0 -0
  13. {nbsync-0.3.5 → nbsync-0.3.6}/.gitignore +0 -0
  14. {nbsync-0.3.5 → nbsync-0.3.6}/LICENSE +0 -0
  15. {nbsync-0.3.5 → nbsync-0.3.6}/README.md +0 -0
  16. {nbsync-0.3.5 → nbsync-0.3.6}/docs/index.md +0 -0
  17. {nbsync-0.3.5 → nbsync-0.3.6}/mkdocs.yaml +0 -0
  18. {nbsync-0.3.5 → nbsync-0.3.6}/src/nbsync/__init__.py +0 -0
  19. {nbsync-0.3.5 → nbsync-0.3.6}/src/nbsync/logger.py +0 -0
  20. {nbsync-0.3.5 → nbsync-0.3.6}/src/nbsync/notebook.py +0 -0
  21. {nbsync-0.3.5 → nbsync-0.3.6}/src/nbsync/py.typed +0 -0
  22. {nbsync-0.3.5 → nbsync-0.3.6}/src/nbsync/sync.py +0 -0
  23. {nbsync-0.3.5 → nbsync-0.3.6}/tests/__init__.py +0 -0
  24. {nbsync-0.3.5 → nbsync-0.3.6}/tests/conftest.py +0 -0
  25. {nbsync-0.3.5 → nbsync-0.3.6}/tests/test_logger.py +0 -0
  26. {nbsync-0.3.5 → nbsync-0.3.6}/tests/test_markdown.py +0 -0
  27. {nbsync-0.3.5 → nbsync-0.3.6}/tests/test_notebook.py +0 -0
  28. {nbsync-0.3.5 → nbsync-0.3.6}/tests/test_sync.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbsync
3
- Version: 0.3.5
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.4.11
42
+ Requires-Dist: nbstore>=0.5.2
43
43
  Description-Content-Type: text/markdown
44
44
 
45
45
  # nbsync
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "nbsync"
7
- version = "0.3.5"
7
+ version = "0.3.6"
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,7 +31,7 @@ classifiers = [
31
31
  "Topic :: Text Processing :: Markup :: Markdown",
32
32
  ]
33
33
  requires-python = ">=3.10"
34
- dependencies = ["nbstore>=0.4.11"]
34
+ dependencies = ["nbstore>=0.5.2"]
35
35
 
36
36
  [project.urls]
37
37
  Documentation = "https://daizutabi.github.io/nbsync/"
@@ -75,7 +75,8 @@ def get_source(
75
75
  ) -> str:
76
76
  attrs = [cell.language]
77
77
  if include_attrs:
78
- attrs.extend(cell.image.iter_parts())
78
+ parts = cell.image.iter_parts(exclude_attributes=["result"])
79
+ attrs.extend(parts)
79
80
  attr = " ".join(attrs)
80
81
 
81
82
  source = cell.image.source
@@ -125,7 +126,7 @@ def get_markdown(kind: str, source: str, result: str, tabs: str) -> str:
125
126
  return f"{result}\n\n{source}"
126
127
 
127
128
  if kind == "material-block":
128
- result = f'<div class="result" markdown="1">{result}</div>'
129
+ result = f'<div class="result" markdown="1">\n{result}\n</div>'
129
130
  return f"{source}\n\n{result}"
130
131
 
131
132
  if kind == "tabbed-left":
@@ -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 _convert_code_block_exec(elem)
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 _convert_code_block_exec(code_block: CodeBlock) -> CodeBlock | Image:
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
@@ -79,7 +79,7 @@ def test_below(convert):
79
79
 
80
80
  def test_material_block(convert):
81
81
  x = convert("![a](a.ipynb){#fig source='material-block' a b=c}")
82
- assert '<div class="result" markdown="1">![a]' in x
82
+ assert '<div class="result" markdown="1">\n![a]' in x
83
83
 
84
84
 
85
85
  def test_tabbed_left(convert):
@@ -125,6 +125,25 @@ def test_code_block_exec_result(convert):
125
125
  assert x == "```text\n2\n<1>\n```"
126
126
 
127
127
 
128
+ def test_code_block_exec_result_source(convert):
129
+ t = '```python exec="1" source="material-block" result="text"\n'
130
+ t += 'print(1+1)\nprint("<1>")\n```'
131
+ x = convert(t)
132
+ y = textwrap.dedent("""\
133
+ ```python
134
+ print(1+1)
135
+ print("<1>")
136
+ ```
137
+
138
+ <div class="result" markdown="1">
139
+ ```text
140
+ 2
141
+ <1>
142
+ ```
143
+ </div>""")
144
+ assert x == y
145
+
146
+
128
147
  def test_code_block_html(convert):
129
148
  src = textwrap.dedent("""\
130
149
  from IPython.display import HTML
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