MyST-NB icon indicating copy to clipboard operation
MyST-NB copied to clipboard

Attached images are not readable by sphinx build

Open kolibril13 opened this issue 2 years ago • 0 comments

Describe the bug

There's a feature in Jupyter markdown cells, that one can simply paste an image into a cell, and it will automatically be attached and rendered. Bug: These attached images don't render in MyST-NB documententation.

Reproduce the bug

  1. Copy an arbitrary image to the clipboard
  2. Paste that image into a selected Jupyter markdown cell
  3. run sphinx-build
  4. The log will now give an image file not readable warning:
updating environment: [new config] 5 added, 0 changed, 0 removed
reading sources... [100%] index                                                                                                                                 
/Users/jan-hendrik/projects/p/docs/3_ct_animation.ipynb:20002: WARNING: image file not readable: attachment:image.png
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index                                                                                                                                  
generating indices... genindex done
writing additional pages... search done
copying images... [100%] scanner.png                                                                                                                            
copying static files... done
copying extra files... done
dumping search index in German (code: de)... done
dumping object inventory... done
build finished with problems, 1 warning.

Extra Note 1

An ipynb notebook file with an attached image looks like this:

{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Hello"
   ]
  },
  {
   "attachments": {
    "image.png": {
     "image/png": "iVBORw0KGgoAAAANSUhEUgAAALAAAABgC ... and so on...  " }
   },
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![image.png](attachment:image.png)"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

and renders like this in VS Code: image

image

and renders like this in the sphinx build image


Extra Note 2

Rendering works with nbsphinx, but doesn't with myst-nb.

List your environment

latest myst_nb pip installation, python 3.11

kolibril13 avatar Apr 13 '23 17:04 kolibril13