Skip to content

Commit

Permalink
Merge pull request #9795 from quarto-dev/fix/ipynb/encoded-svg
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv authored May 30, 2024
2 parents 122b0f3 + ab0d4d2 commit 1c9cef7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
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)
) {
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)
```

0 comments on commit 1c9cef7

Please sign in to comment.