Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipynb - check if svg display data is encoded or not #9795

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ All changes included in 1.5:
- ([#9635](https://github.com/quarto-dev/quarto-cli/issues/9635)): Respect `{shortcodes=false}` when resolving `include` shortcodes.
- ([#9664](https://github.com/quarto-dev/quarto-cli/pull/9664)): Add `placeholder` shortcode to produce placeholder images.
- ([#9665](https://github.com/quarto-dev/quarto-cli/issues/9665)): Fix issue with key-value arguments of shortcode handlers in code contexts.
- ([#9793](https://github.com/quarto-dev/quarto-cli/issues/9793)): `embed` shortcode now correctly retrieve svg image from embdedded cell.

## Lightbox Images

Expand Down
10 changes: 8 additions & 2 deletions src/core/jupyter/jupyter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1930,9 +1930,15 @@ function mdImageOutput(
? (data as string[]).join("")
: data as string;

// base64 decode if it's not svg
const outputFile = join(options.assets.base_dir, imageFile);
if (mimeType !== kImageSvg) {
if (
// base64 decode if it's not svg
mimeType !== kImageSvg ||
// or if it is encoded svg; this could happen when used in embed context,
// as Pandoc will generate ipynb with base64 encoded svg data
// https://github.com/quarto-dev/quarto-cli/issues/9793
!/<svg/.test(imageText)
cderv marked this conversation as resolved.
Show resolved Hide resolved
) {
const imageData = base64decode(imageText);

// if we are in retina mode, then derive width and height from the image
Expand Down
8 changes: 8 additions & 0 deletions tests/docs/smoke-all/2024/05/29/9713/main.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
format: typst
_quarto:
tests:
typst: null
---

{{< embed plots.qmd#plot >}}
10 changes: 10 additions & 0 deletions tests/docs/smoke-all/2024/05/29/9713/plots.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "Plots"
fig-format: svg
---

```{r}
#| label: plot
plot(1:10)
```

Loading