Skip to content

Commit e607284

Browse files
committed
ipynb - check if svg display data is encoded or not
We assumed svg mime type data was never encoded, but this is not the case when the SVG is produced by a pandoc convert `--to ipynb`. It happens in render context when embed is used. The svg data needs to be decoded before being written to the file at embedding time.
1 parent 122b0f3 commit e607284

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/core/jupyter/jupyter.ts

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

1933-
// base64 decode if it's not svg
1933+
// base64 decode if it's not encoded svg
1934+
// when used in embed context, Pandoc will generate ipynb with base64 encoded svg data
1935+
// https://github.com/quarto-dev/quarto-cli/issues/9793
19341936
const outputFile = join(options.assets.base_dir, imageFile);
1935-
if (mimeType !== kImageSvg) {
1937+
if (mimeType !== kImageSvg || !imageText.trimStart().startsWith("<svg")) {
19361938
const imageData = base64decode(imageText);
19371939

19381940
// if we are in retina mode, then derive width and height from the image

0 commit comments

Comments
 (0)