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
feat: support superscript in markdown (#7113)
Myles Scolnicke32b579408d2
diff --git a/marimo/_output/md.py b/marimo/_output/md.pyindex fd808f78f0..a71eeb0f50 100644--- a/marimo/_output/md.py+++ b/marimo/_output/md.py@@ -171,6 +171,8 @@ def _get_extensions() -> list[Union[str, markdown.Extension]]:# "pymdownx.b64",# Subscripts and strikethrough"pymdownx.tilde",+ # Superscripts and insert+ "pymdownx.caret",# Better code blocks"pymdownx.superfences",# Task listsdiff --git a/marimo/_smoke_tests/markdown/caret.py b/marimo/_smoke_tests/markdown/caret.pynew file mode 100644index 0000000000..4f77dc9490--- /dev/null+++ b/marimo/_smoke_tests/markdown/caret.py@@ -0,0 +1,60 @@+import marimo++__generated_with = "0.17.7"+app = marimo.App(width="medium")+++def _(mo):+ mo.md(r"""+ ## Superscript++ H^2^O++ E = mc^2^++ x^2^ + y^2^ = z^2^++ This is text^with\ superscript^ in the middle.+ """)+ return+++def _(mo):+ mo.md(r"""+ ## Insert (underline)++ ^^Insert me^^++ This is ^^important^^ text that should be underlined.++ Here is some ^^newly added content^^ in the document.+ """)+ return+++def _(mo):+ mo.md(r"""+ ## Combined with other formatting++ **Bold with ^^inserted^^ text**++ *Italic with ^superscript^ text*++ ~~Deleted text~~ and ^^inserted text^^++ CH~3~CH~2~OH with H^2^O+ """)+ return+++def _():+ import marimo as mo+ return (mo,)+++if __name__ == "__main__":+ app.run()diff --git a/tests/_output/test_md.py b/tests/_output/test_md.pyindex 2e09d80d02..9c3091cb11 100644--- a/tests/_output/test_md.py+++ b/tests/_output/test_md.py@@ -472,6 +472,51 @@ def test_md_mime_type_with_script():assert "Title" in content+def test_md_caret_superscript() -> None:+ # Test superscript conversion+ superscript_input = "H^2^O"+ expected_output = '<span class="paragraph">H<sup>2</sup>O</span>'+ assert (+ _md(superscript_input, apply_markdown_class=False).text+ == expected_output+ )++ # Test superscript with spaces+ superscript_spaces = "text^a\\ superscript^"+ expected_spaces = (+ '<span class="paragraph">text<sup>a superscript</sup></span>'+ )+ assert (+ _md(superscript_spaces, apply_markdown_class=False).text+ == expected_spaces+ )+++def test_md_caret_insert() -> None:+ # Test insert (underline) conversion+ insert_input = "^^Insert me^^"+ expected_output = '<span class="paragraph"><ins>Insert me</ins></span>'+ assert (+ _md(insert_input, apply_markdown_class=False).text == expected_output+ )++ # Test insert with markdown formatting+ insert_bold = "This is ^^important^^ text"+ expected_bold = (+ '<span class="paragraph">This is <ins>important</ins> text</span>'+ )+ assert _md(insert_bold, apply_markdown_class=False).text == expected_bold+++def test_md_caret_combined() -> None:+ # Test caret combined with tilde (subscript/strikethrough)+ combined_input = "CH~3~CH~2~OH with H^2^O"+ expected_output = '<span class="paragraph">CH<sub>3</sub>CH<sub>2</sub>OH with H<sup>2</sup>O</span>'+ assert (+ _md(combined_input, apply_markdown_class=False).text == expected_output+ )++@patch("marimo._runtime.output")def test_latex_via_path(output: MagicMock, tmp_path: Path) -> None:filename = tmp_path / "macros.tex"