Skip to content

Commit 1c9cef7

Browse files
authored
Merge pull request #9795 from quarto-dev/fix/ipynb/encoded-svg
2 parents 122b0f3 + ab0d4d2 commit 1c9cef7

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

news/changelog-1.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ All changes included in 1.5:
123123
- ([#9635](https://github.com/quarto-dev/quarto-cli/issues/9635)): Respect `{shortcodes=false}` when resolving `include` shortcodes.
124124
- ([#9664](https://github.com/quarto-dev/quarto-cli/pull/9664)): Add `placeholder` shortcode to produce placeholder images.
125125
- ([#9665](https://github.com/quarto-dev/quarto-cli/issues/9665)): Fix issue with key-value arguments of shortcode handlers in code contexts.
126+
- ([#9793](https://github.com/quarto-dev/quarto-cli/issues/9793)): `embed` shortcode now correctly retrieve svg image from embdedded cell.
126127

127128
## Lightbox Images
128129

src/core/jupyter/jupyter.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,9 +1930,15 @@ function mdImageOutput(
19301930
? (data as string[]).join("")
19311931
: data as string;
19321932

1933-
// base64 decode if it's not svg
19341933
const outputFile = join(options.assets.base_dir, imageFile);
1935-
if (mimeType !== kImageSvg) {
1934+
if (
1935+
// base64 decode if it's not svg
1936+
mimeType !== kImageSvg ||
1937+
// or if it is encoded svg; this could happen when used in embed context,
1938+
// as Pandoc will generate ipynb with base64 encoded svg data
1939+
// https://github.com/quarto-dev/quarto-cli/issues/9793
1940+
!/<svg/.test(imageText)
1941+
) {
19361942
const imageData = base64decode(imageText);
19371943

19381944
// if we are in retina mode, then derive width and height from the image
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
format: typst
3+
_quarto:
4+
tests:
5+
typst: null
6+
---
7+
8+
{{< embed plots.qmd#plot >}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: "Plots"
3+
fig-format: svg
4+
---
5+
6+
```{r}
7+
#| label: plot
8+
plot(1:10)
9+
```
10+

0 commit comments

Comments
 (0)