Skip to content

Embed for a Jupyter Percent script #10385

@cderv

Description

@cderv

Quarto supports now expressing notebook as Jupyter percent script and will render it using usual Jupyter engine pipeline

# %% [markdown]
# ---
# title: Palmer Penguins
# author: Norah Jones
# date: 3/12/23
# ---

# %%
#| echo: false
import pandas as pd
df = pd.read_csv("palmer-penguins.csv")

# %% [markdown]
"""
## Exploring the data

See @fig-bill-sizes for an exploration of bill sizes by species.
"""

# %% 
#| label: fig-bill-sizes
#| fig-cap: Bill Sizes by Species
                                          
import matplotlib.pyplot as plt           
import seaborn as sns

g = sns.FacetGrid(df, hue="species", height=3, aspect=3.5/1.5)
g.map(plt.scatter, "bill_length_mm", "bill_depth_mm").add_legend()

Howerver for now, this is seen as unsupported embed

ERROR: Unable to embed content from script.py - embedding content is not supported for this file type.

Stack trace:
    at unsupportedEmbed (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/core/jupyter/jupyter-embed.ts:149:11)
    at parseNotebookAddress (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/core/jupyter/jupyter-embed.ts:115:7)
    at Object.handle (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/core/handlers/embed.ts:46:31)
    at Object.directive (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/core/handlers/embed.ts:101:36)
    at handleLanguageCells (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/core/handlers/base.ts:511:38)
    at eventLoopTick (ext:core/01_core.js:153:7)
    at async file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/command/render/render-files.ts:631:41
    at async withTimingAsync (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/core/timing.ts:50:20)
    at async renderFileInternal (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/command/render/render-files.ts:629:9)
    at async renderFiles (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/command/render/render-files.ts:325:9)

Maybe it would be ok to support this ?

---
title: "test"
format: html
---

{{< embed script.py#fig-bill-sizes >}}     

Following discussion in #10366 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions