@@ -54,6 +54,52 @@ def export_html(notebook_path: str) -> None:
5454 print (result .stderr )
5555
5656
57+ def export_html_wasm (notebook_path : str ) -> None :
58+ """Export a single marimo notebook to HTML format."""
59+ output_path = f"{ notebook_path } .wasm.run.html"
60+ print (f"Exporting { notebook_path } to { output_path } " )
61+ result = subprocess .run (
62+ [
63+ "marimo" ,
64+ "export" ,
65+ "html-wasm" ,
66+ notebook_path ,
67+ "-o" ,
68+ f"public/{ output_path } " ,
69+ "--mode" ,
70+ "run" ,
71+ "--no-show-code" ,
72+ ],
73+ capture_output = True ,
74+ text = True ,
75+ )
76+
77+ if result .returncode != 0 :
78+ print (f"Error exporting { notebook_path } :" )
79+ print (result .stderr )
80+
81+ output_path = f"{ notebook_path } .wasm.edit.html"
82+ print (f"Exporting { notebook_path } to { output_path } " )
83+ result = subprocess .run (
84+ [
85+ "marimo" ,
86+ "export" ,
87+ "html-wasm" ,
88+ notebook_path ,
89+ "-o" ,
90+ f"public/{ output_path } " ,
91+ "--mode" ,
92+ "edit" ,
93+ ],
94+ capture_output = True ,
95+ text = True ,
96+ )
97+
98+ if result .returncode != 0 :
99+ print (f"Error exporting { notebook_path } :" )
100+ print (result .stderr )
101+
102+
57103def export_ipynb (notebook_path : str ) -> None :
58104 """Export a single marimo notebook to ipynb format."""
59105 output_path = f"{ notebook_path } .ipynb"
@@ -118,13 +164,19 @@ def generate_index(dir: str) -> None:
118164 )
119165 for notebook in WHITELISTED_NOTEBOOKS :
120166 notebook_name = notebook .split ("/" )[- 1 ].replace (".py" , "" )
167+ display_name = notebook_name .replace ("_" , " " ).title ()
168+
169+ # Static HTML
121170 f .write (
122- f' <a href="{ os .path .join (dir , notebook )} .html" class="block p-4 border border-gray-200 rounded hover:border-black">\n '
123- )
124- f .write (
125- f' <h3 class="text-lg font-semibold">{ notebook_name .replace ("_" , " " ).title ()} </h3>\n '
171+ f' <div class="p-4 border border-gray-200 rounded">\n '
172+ f' <h3 class="text-lg font-semibold mb-2">{ display_name } </h3>\n '
173+ f' <div class="flex gap-2">\n '
174+ f' <a href="{ os .path .join (dir , notebook )} .html" class="px-3 py-1 bg-gray-100 hover:bg-gray-200 rounded">Static HTML</a>\n '
175+ f' <a href="{ os .path .join (dir , notebook )} .wasm.run.html" class="px-3 py-1 bg-gray-100 hover:bg-gray-200 rounded">WASM Run</a>\n '
176+ f' <a href="{ os .path .join (dir , notebook )} .wasm.edit.html" class="px-3 py-1 bg-gray-100 hover:bg-gray-200 rounded">WASM Edit</a>\n '
177+ f" </div>\n "
178+ f" </div>\n "
126179 )
127- f .write (" </a>\n " )
128180 f .write (
129181 """ </div>
130182 </body>
@@ -154,6 +206,7 @@ def main():
154206 if os .path .exists (notebook_path ):
155207 export_markdown (notebook_path )
156208 export_html (notebook_path )
209+ export_html_wasm (notebook_path )
157210 export_ipynb (notebook_path )
158211 export_script (notebook_path )
159212 else :
0 commit comments