forked from marimo-team/marimo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynamic_markdown.py
78 lines (55 loc) · 1.18 KB
/
dynamic_markdown.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import marimo
__generated_with = "0.10.19"
app = marimo.App()
@app.cell(hide_code=True)
def _(mo):
mo.md(r"""Use `mo.md` with an `f-string` to create markdown that depends on the value of Python objects.""")
return
@app.cell
def _():
name = "Alice"
return (name,)
@app.cell
def _(mo, name):
mo.md(
f"""
Hello, {name}!
"""
)
return
@app.cell(hide_code=True)
def _(mo):
mo.md(r"""Embed marimo UI elements in markdown directly:""")
return
@app.cell
def _(mo):
text_input = mo.ui.text(placeholder="My name is ...", debounce=False)
return (text_input,)
@app.cell
def _(mo, text_input):
mo.md(
f"""
What's your name? {text_input}
Hello, {text_input.value}!
"""
)
return
@app.cell(hide_code=True)
def _(mo):
mo.md(r"""Wrap plots and data structures in `mo.as_html()` to hook into marimo's rich media viewer:""")
return
@app.cell
def _(mo):
mo.md(
f"""
Here's a list of numbers:
{mo.as_html([1, 2, 3])}
"""
)
return
@app.cell
def _():
import marimo as mo
return (mo,)
if __name__ == "__main__":
app.run()