marimo-md-export 0.4.2__tar.gz → 0.4.3__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,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: marimo-md-export
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: A minimal solution for exporting marimo notebooks to markdown *with* rendered HTML outputs, designed for mkdocs/zensical sites.
5
5
  Keywords: marimo,markdown,documentation
6
- Author: jmarshrossney
7
- Author-email: jmarshrossney <17361029+jmarshrossney@users.noreply.github.com>
6
+ Author: Joe Marsh Rossney
7
+ Author-email: Joe Marsh Rossney <17361029+jmarshrossney@users.noreply.github.com>
8
8
  License-Expression: MIT
9
9
  License-File: LICENSE
10
10
  Classifier: Development Status :: 3 - Alpha
@@ -32,9 +32,8 @@ Description-Content-Type: text/markdown
32
32
  [![CI](https://github.com/jmarshrossney/marimo-md-export/actions/workflows/ci.yml/badge.svg)](https://github.com/jmarshrossney/marimo-md-export/actions/workflows/ci.yml)
33
33
  [![Docs](https://github.com/jmarshrossney/marimo-md-export/actions/workflows/docs.yml/badge.svg)](https://jmarshrossney.github.io/marimo-md-export)
34
34
 
35
- A `uv` tool that wraps `marimo export`, extracts rendered outputs from the HTML export,
36
- and injects them into the markdown export. The result is a self-contained markdown
37
- document with embedded figures (as base64 `<img>` tags), tables (as GFM or HTML), and other cell outputs.
35
+ A `uv` tool that wraps `marimo export`, extracts rendered outputs from the HTML export, and injects them into the markdown export.
36
+ The result is a self-contained markdown document with embedded figures (as base64 `<img>` tags), tables (as GFM or HTML), and other cell outputs.
38
37
 
39
38
  **[Full documentation](https://jmarshrossney.github.io/marimo-md-export)**
40
39
 
@@ -56,9 +55,8 @@ uvx marimo-md-export notebook.py output.md
56
55
 
57
56
  ## Integrating with documentation sites
58
57
 
59
- `marimo-md-export` is designed to produce markdown pages for static site generators like
60
- [mkdocs](https://www.mkdocs.org/) (Python) or
61
- [zensical](https://zensical.org/) (Rust). Both work identically for this purpose.
58
+ `marimo-md-export` is designed to produce markdown pages for static site generators like [mkdocs](https://www.mkdocs.org/) or [zensical](https://zensical.org/).
59
+ Both work identically for this purpose.
62
60
 
63
61
  **1. Add as a docs dependency:**
64
62
 
@@ -76,8 +74,7 @@ docs:
76
74
  zensical build
77
75
  ```
78
76
 
79
- This runs `marimo-md-export` to produce a self-contained markdown page (with cell
80
- outputs injected), then builds the site.
77
+ This runs `marimo-md-export` to produce a self-contained markdown page (with cell outputs injected), then builds the site.
81
78
 
82
79
  ## Development
83
80
 
@@ -6,9 +6,8 @@
6
6
  [![CI](https://github.com/jmarshrossney/marimo-md-export/actions/workflows/ci.yml/badge.svg)](https://github.com/jmarshrossney/marimo-md-export/actions/workflows/ci.yml)
7
7
  [![Docs](https://github.com/jmarshrossney/marimo-md-export/actions/workflows/docs.yml/badge.svg)](https://jmarshrossney.github.io/marimo-md-export)
8
8
 
9
- A `uv` tool that wraps `marimo export`, extracts rendered outputs from the HTML export,
10
- and injects them into the markdown export. The result is a self-contained markdown
11
- document with embedded figures (as base64 `<img>` tags), tables (as GFM or HTML), and other cell outputs.
9
+ A `uv` tool that wraps `marimo export`, extracts rendered outputs from the HTML export, and injects them into the markdown export.
10
+ The result is a self-contained markdown document with embedded figures (as base64 `<img>` tags), tables (as GFM or HTML), and other cell outputs.
12
11
 
13
12
  **[Full documentation](https://jmarshrossney.github.io/marimo-md-export)**
14
13
 
@@ -30,9 +29,8 @@ uvx marimo-md-export notebook.py output.md
30
29
 
31
30
  ## Integrating with documentation sites
32
31
 
33
- `marimo-md-export` is designed to produce markdown pages for static site generators like
34
- [mkdocs](https://www.mkdocs.org/) (Python) or
35
- [zensical](https://zensical.org/) (Rust). Both work identically for this purpose.
32
+ `marimo-md-export` is designed to produce markdown pages for static site generators like [mkdocs](https://www.mkdocs.org/) or [zensical](https://zensical.org/).
33
+ Both work identically for this purpose.
36
34
 
37
35
  **1. Add as a docs dependency:**
38
36
 
@@ -50,8 +48,7 @@ docs:
50
48
  zensical build
51
49
  ```
52
50
 
53
- This runs `marimo-md-export` to produce a self-contained markdown page (with cell
54
- outputs injected), then builds the site.
51
+ This runs `marimo-md-export` to produce a self-contained markdown page (with cell outputs injected), then builds the site.
55
52
 
56
53
  ## Development
57
54
 
@@ -4,10 +4,10 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "marimo-md-export"
7
- version = "0.4.2"
7
+ version = "0.4.3"
8
8
  description = "A minimal solution for exporting marimo notebooks to markdown *with* rendered HTML outputs, designed for mkdocs/zensical sites."
9
9
  authors = [
10
- { name = "jmarshrossney", email = "17361029+jmarshrossney@users.noreply.github.com" }
10
+ { name = "Joe Marsh Rossney", email = "17361029+jmarshrossney@users.noreply.github.com" }
11
11
  ]
12
12
  readme = "README.md"
13
13
  license = "MIT"
@@ -31,7 +31,9 @@
31
31
  # Tables are stored as <marimo-table data-data='...'> web components.
32
32
  # `data-data` is a JSON-quoted string of row objects; NaN appears literally.
33
33
 
34
+ import ast
34
35
  import json
36
+ import pprint
35
37
  import re
36
38
  from html import escape, unescape
37
39
 
@@ -230,10 +232,10 @@ def _classify_and_build(data: dict[str, str]) -> tuple[str, str] | None:
230
232
  try:
231
233
  parsed = json.loads(json_val)
232
234
  cleaned = _strip_marimo_type_prefixes(parsed)
233
- formatted = json.dumps(cleaned, indent=2, ensure_ascii=False)
235
+ formatted = pprint.pformat(cleaned)
234
236
  except (json.JSONDecodeError, TypeError):
235
237
  formatted = json_val
236
- return "json", f"<pre><code>{escape(formatted)}</code></pre>"
238
+ return "json", f"<pre>{escape(formatted)}</pre>"
237
239
 
238
240
  # LaTeX output — wrap in $$ delimiters for math rendering.
239
241
  # NOTE: text/latex is a fallback MIME type and is not expected to appear
@@ -263,6 +265,21 @@ def _classify_and_build(data: dict[str, str]) -> tuple[str, str] | None:
263
265
  html_val = data.get("text/html")
264
266
  if html_val:
265
267
  decoded = unescape(html_val)
268
+ # Check for <pre> tag containing a Python string repr
269
+ pre_match = re.match(r"<pre[^>]*>(.*?)</pre>", decoded, re.DOTALL)
270
+ if pre_match:
271
+ content = pre_match.group(1)
272
+ if (
273
+ content.startswith(("'", '"'))
274
+ and content.endswith(("'", '"'))
275
+ and len(content) >= 2
276
+ ):
277
+ try:
278
+ content = ast.literal_eval(content)
279
+ except (ValueError, SyntaxError):
280
+ content = None
281
+ if content is not None:
282
+ return "text", f"<pre>{escape(content)}</pre>"
266
283
  if "<marimo-table" in decoded:
267
284
  table_html = _table_html_from_marimo_table(decoded)
268
285
  return "table", table_html
@@ -273,6 +290,15 @@ def _classify_and_build(data: dict[str, str]) -> tuple[str, str] | None:
273
290
 
274
291
  plain = data.get("text/plain", "")
275
292
  if plain and plain.strip():
293
+ if (
294
+ plain.startswith(("'", '"'))
295
+ and plain.endswith(("'", '"'))
296
+ and len(plain) >= 2
297
+ ):
298
+ try:
299
+ plain = ast.literal_eval(plain)
300
+ except (ValueError, SyntaxError):
301
+ pass
276
302
  return "text", f"<pre>{escape(plain)}</pre>"
277
303
 
278
304
  # Unsupported MIME types — leave a comment for debugging