Skip to content

Commit 1b61c86

Browse files
dmadisettimscolnickpre-commit-ci[bot]
authored
fix: ensure correct markdown serialization (#7016)
## 📝 Summary Continuation of #7013 Very aggressive verification that markdown correctly serializes now. --------- Co-authored-by: Myles Scolnick <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent f4718f2 commit 1b61c86

File tree

8 files changed

+516
-29
lines changed

8 files changed

+516
-29
lines changed

marimo/_ast/codegen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def format_markdown(cell: CellImpl) -> str:
183183
# We can blanket replace, because cell.markdown is not set
184184
# on f-strings with values.
185185
markdown = markdown.replace("{", "{{").replace("}", "}}")
186+
markdown = markdown.replace('""', '"\\"')
186187

187188
# We always use """ as per front end.
188189
body = construct_markdown_call(markdown, '"""', tag)

marimo/_ast/load.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535

3636
@dataclass
3737
class LoadResult:
38+
"""Result of attempting to load a marimo notebook.
39+
40+
status can be one of:
41+
- empty: No content, or only comments / a doc string
42+
- has_errors: Parsed, but has marimo-specific errors (**can load!!**)
43+
- invalid: Could not be parsed as a marimo notebook (**cannot load**)
44+
- valid: Parsed and valid marimo notebook
45+
"""
46+
3847
status: Literal["empty", "has_errors", "invalid", "valid"] = "empty"
3948
notebook: Optional[NotebookSerialization] = None
4049
contents: Optional[str] = None
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# INTENTIONALLY BROKEN!
2+
print("hello world
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import marimo
2+
3+
__generated_with = "0.17.4"
4+
app = marimo.App(width="medium")
5+
6+
7+
@app.cell
8+
def _(mo):
9+
mo.md("""
10+
r"""Markdown cell with error"""
11+
""")
12+
return
13+
14+
15+
@app.cell
16+
def _():
17+
import marimo as mo
18+
return (mo,)
19+
20+
21+
@app.cell
22+
def _():
23+
return
24+
25+
26+
if __name__ == "__main__":
27+
app.run()

tests/_ast/codegen_data/test_get_app_kwargs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import marimo
2-
32
app = marimo.App(
43
app_title="title",
54
auto_download="html",

0 commit comments

Comments
 (0)