A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Added rendering script for static HTML exports to docs (#4441)
Apoorv Khandelwala6299dfde3eb
diff --git a/docs/guides/exporting.md b/docs/guides/exporting.mdindex 794f141730..bec9639ab3 100644--- a/docs/guides/exporting.md+++ b/docs/guides/exporting.md@@ -46,6 +46,38 @@ its visual outputs before saving as HTML.If any cells error during the export process, the status code will be non-zero. However, the export result may still be generated, with the error included in the output.Errors can be ignored by appending `|| true` to the command, e.g. `marimo export html notebook.py || true`.+### Pre-render HTML exports++Static marimo exports execute Javascript to render the notebook source code as HTML at browser runtime. If you would like to directly serve the HTML representation of your notebook, you can run the following post-processing script and serve the resulting file instead.++```python+# /// script+# requires-python = ">=3.9"+# dependencies = [+# "playwright",+# ]+# ///++import os+import subprocess+from playwright.sync_api import sync_playwright++input_file = "input.html"+output_file = "output.html"++subprocess.run(["playwright", "install", "chromium-headless-shell"], check=True)++with sync_playwright() as p:+ with p.chromium.launch(headless=True) as browser:+ page = browser.new_page()+ page.goto(+ f"file:///{os.path.abspath(input_file)}",+ wait_until="networkidle",+ )+ with open(output_file, "w", encoding="utf-8") as f:+ f.write(page.content())+```+## Export to a Python scriptExport to a flat Python script in topological order, so the cells adhere to