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
Preserve newlines in iframe srcdoc (#10668)
Trevor Manz7d0f7c477f7f
diff --git a/marimo/_output/formatting.py b/marimo/_output/formatting.pyindex ecf413f14d..5cfc911cc0 100644--- a/marimo/_output/formatting.py+++ b/marimo/_output/formatting.py@@ -410,12 +410,10 @@ def iframe(html: str, *, width: str = "100%", height: str = "400px") -> Html:"""return Html(- flatten_string(- h.iframe(- **src_or_src_doc(html),- onload="__resizeIframe(this)",- width=width,- height=height,- )+ h.iframe(+ **src_or_src_doc(html),+ onload="__resizeIframe(this)",+ width=width,+ height=height,),)diff --git a/tests/_output/formatters/test_iframe.py b/tests/_output/formatters/test_iframe.pyindex efeeb3c5de..90e662a101 100644--- a/tests/_output/formatters/test_iframe.py+++ b/tests/_output/formatters/test_iframe.py@@ -24,6 +24,20 @@ def test_maybe_wrap_in_iframe_with_inline_script():)+def test_maybe_wrap_in_iframe_preserves_inline_script_newlines():+ html = """<script>+// This comment must not consume the next line.+console.log("hello")+</script>"""+ assert (+ maybe_wrap_in_iframe(html)+ == """<iframe srcdoc='<script>+// This comment must not consume the next line.+console.log("hello")+</script>' width='100%' height='400px' onload='__resizeIframe(this)' frameborder='0'></iframe>"""+ )++def test_has_script_tag_without_src_no_script():html = "<div>Hello world</div>"assert not _has_script_tag_without_src(html)