Skip to content

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.

docs: update markdown docs for f-strings (#4769)

Akshay Agrawal1cc41f36f168
diff --git a/docs/_static/docs-markdown-toggle.webm b/docs/_static/docs-markdown-toggle.webm
index 3797836163..36743bbaa8 100644
Binary files a/docs/_static/docs-markdown-toggle.webm and b/docs/_static/docs-markdown-toggle.webm differ
diff --git a/docs/guides/outputs.md b/docs/guides/outputs.md
index 430764b21b..2d0853e84d 100644
--- a/docs/guides/outputs.md
+++ b/docs/guides/outputs.md
@@ -64,22 +64,26 @@ mo.md(
### Markdown editor
-marimo automatically renders cells that only use `mo.md("")`, without an
-`f`-string, in a markdown editor that supports common hotkeys.
-
-Because the Markdown editor doesn't support f-strings, you'll need to use
-`mo.md` directly to interpolate Python values into your Markdown. You can
-switch between the Markdown and Python editors by clicking the button in the
-top right.
+marimo automatically renders cells that only use `mo.md` in a markdown editor
+that supports common hotkeys. You can switch between the Markdown and Python
+editors by clicking the button in the top right:
<div align="center">
<figure>
-<video autoplay muted loop playsinline width="100%" height="100%" align="center" src="/_static/docs-markdown-toggle.webm">
+<video autoplay muted loop playsinline width="80%" height="100%" align="center" src="/_static/docs-markdown-toggle.webm">
</video>
<figcaption>marimo is pure Python, even when you're using markdown.</figcaption>
</figure>
</div>
+**Writing LaTeX.** The markdown editor supports writing LaTeX. You should typically
+use a raw string for markdown with LaTeX, which you can activate by checking the `r`
+box in the bottom-right corner of the markdown editor.
+
+**Interpolating Python values.** Interpolating Python values requires using an
+`f`-string, which you can activate by checking the `f` box in the bottom-right
+corner of the markdown editor.
+
### Markdown extensions
#### Details
diff --git a/marimo/_tutorials/markdown.py b/marimo/_tutorials/markdown.py
index 9d7f1d14ef..40cd90ec44 100644
--- a/marimo/_tutorials/markdown.py
+++ b/marimo/_tutorials/markdown.py
@@ -11,7 +11,7 @@
import marimo
-__generated_with = "0.12.2"
+__generated_with = "0.13.3"
app = marimo.App()
@@ -45,20 +45,20 @@ def _(mo):
@app.cell
def _(mo):
mo.md(
- """
+ r"""
**Tip: toggling between the Markdown and Python editor**
Although markdown is written with `mo.md`, marimo provides a markdown editor
- that hides this boilerplate from you.
+ that hides this boilerplate from you, for cells that only contain `mo.md(...)`.
Toggle between the Markdown and Python
editors by clicking the blue icon in the top-right of the editor,
entering `Ctrl/Cmd+Shift+M`, or using the "cell actions menu". You can
also **hide** the markdown editor through the cell actions menu.
- **Tip**: To interpolate Python values into markdown strings, you'll
- need to use `mo.md(f"...")` directly; the markdown view does not support
- f-strings.
+ **Tip:** To interpolate Python values into markdown strings, you'll need to use
+ a Python f-string; do this by checking the `f` box in the bottom-right corner of the
+ markdown editor, or with `mo.md(f"...")` in the Python view.
"""
)
return
@@ -195,7 +195,7 @@ def _(mo):
@app.cell
def _(leaves, mo):
- mo.md(f"Your leaves: {'🍃' * leaves.value}")
+ mo.md(f"""Your leaves: {'🍃' * leaves.value}""")
return
@@ -239,7 +239,7 @@ def _(mo, np):
{mo.as_html(make_dataframe())}
"""
)
- return make_dataframe, pl
+ return
@app.cell(hide_code=True)