spatialaudio / nbsphinx

:ledger: Sphinx source parser for Jupyter notebooks
https://nbsphinx.readthedocs.io/
MIT License
451 stars 130 forks source link

Cell Attachment requires preceeding text #525

Closed alanhdu closed 3 years ago

alanhdu commented 3 years ago

The current cell attachment logic seems to be incomplete. When I try to render the notebook in the gist https://gist.github.com/alanhdu/6f520fc0fa553ed1e06044c7c607ab8c, I get an:

WARNING: image file not readable: attachment:cbe9739f-7fcd-4ed5-866f-80d693d30fe8.png

error.

After debugging, I am fairly confident that the problem is that the markdown:

   "source": [
    "![logo-64x64.png](attachment:cbe9739f-7fcd-4ed5-866f-80d693d30fe8.png)"
   ]

is being translated into the following rst

.. image:: attachment:cbe9739f-7fcd-4ed5-866f-80d693d30fe8.png
   :alt: logo-64x64.png

Note that there is no file name preceeding the image! That only seems to appear if the original markdown is something like:

This is an image ![logo-64x64.png](attachment:cbe9739f-7fcd-4ed5-866f-80d693d30fe8.png)

which then gets translated into

This is an image: |logo-64x64.png|

.. |logo-64x64.png| image:: attachment:cbe9739f-7fcd-4ed5-866f-80d693d30fe8.png