Skip to content

Commit 4323da7

Browse files
{python.marimo} syntax
1 parent 48f8d55 commit 4323da7

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

_extensions/marimo/marimo-engine.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ function delay(ms, options = {}) {
406406

407407
// src/marimo-engine.ts
408408
var quarto;
409-
var MARIMO_CELL_REGEX = /^\s*(```+)\s*(?:python\s+\{\.|\{\.python\.|\{)(marimo)( *[ ,].*)?\}\s*$/;
409+
var MARIMO_CELL_REGEX = /^\s*(```+)\s*\{?(python)(?:\s+\{\.|\.)marimo( *[ ,].*)?\}\s*$/;
410410
async function executePython(command, args = [], stdin = "") {
411411
const cmd = new Deno.Command(command, {
412412
args,
@@ -532,7 +532,7 @@ var marimoEngineDiscovery = {
532532
return false;
533533
},
534534
claimsLanguage: (language) => {
535-
return language === "marimo";
535+
return language === "python";
536536
},
537537
canFreeze: false,
538538
generatesFigures: true,
@@ -603,6 +603,7 @@ var marimoEngineDiscovery = {
603603
const processedCells = [];
604604
let marimoIndex = 0;
605605
for (const cell of chunks.cells) {
606+
console.log("is marimo", cell, isMarimoCell(cell));
606607
if (isMarimoCell(cell)) {
607608
if (marimoIndex < marimoExecution.outputs.length) {
608609
const output = marimoExecution.outputs[marimoIndex];

src/marimo-engine.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ import type {
2525

2626
let quarto: QuartoAPI;
2727

28-
// Matches {marimo}, python {.marimo}, and {.python.marimo} syntax
28+
// Matches
29+
// ```python {.marimo}
30+
// ```{python.marimo}
2931
// Group 1: backticks (```+)
30-
// Group 2: language ("marimo")
31-
// Does NOT match {.marimo} alone (requires python prefix for dot syntax)
32-
const MARIMO_CELL_REGEX = /^\s*(```+)\s*(?:python\s+\{\.|\{\.python\.|\{)(marimo)( *[ ,].*)?\}\s*$/;
32+
// Group 2: language ("python")
33+
const MARIMO_CELL_REGEX = /^\s*(```+)\s*\{?(python)(?:\s+\{\.|\.)marimo( *[ ,].*)?\}\s*$/;
3334

3435
// Type for marimo cell output from extract.py
3536
interface MarimoOutput {
@@ -215,7 +216,7 @@ const marimoEngineDiscovery: ExecutionEngineDiscovery = {
215216
},
216217

217218
claimsLanguage: (language: string) => {
218-
return language === "marimo";
219+
return language === "python";
219220
},
220221

221222
canFreeze: false,

tutorials/example-pdf.qmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extract-media: _site/media
1515

1616
# PDF Output
1717

18-
```{.python.marimo}
18+
```{python.marimo}
1919
check = """
2020
Quarto can handle images and tables in PDF output, but not rich HTML outputs.
2121
Here's an example of what can be acccomplished with the `marimo` exports to pdf.
@@ -39,7 +39,7 @@ import matplotlib.pyplot as plt
3939
plt.plot([1, 2])
4040
```
4141

42-
```{.python.marimo}
42+
```{python.marimo}
4343
plt.plot([1, 2])
4444
plt.gca()
4545
```
@@ -57,7 +57,7 @@ df = pd.DataFrame({
5757
df
5858
```
5959

60-
```{.python.marimo}
60+
```{python.marimo}
6161
df = pd.DataFrame({
6262
'A': [1, 2, 3],
6363
'B': [4, 5, 6]
@@ -67,14 +67,14 @@ df
6767

6868
## Text / Markdown
6969

70-
```{.python.marimo}
70+
```{python.marimo}
7171
f"""You can also include text or markdown in the PDF output.
7272
Which can be useful for embedding computed values like the fact
7373
that this was rendered by Marimo {mo.__version__} on {datetime.datetime.now()}.
7474
"""
7575
```
7676

77-
```{.python.marimo}
77+
```{python.marimo}
7878
try:
7979
import matplotlib
8080
import matplotlib.pyplot as plt
@@ -90,6 +90,6 @@ if not missing_packages:
9090
```
9191

9292

93-
```{.python.marimo}
93+
```{python.marimo}
9494
import marimo as mo
9595
```

0 commit comments

Comments
 (0)