nbautoexport icon indicating copy to clipboard operation
nbautoexport copied to clipboard

Referencing images with markdown not carried over in output

Open adfi opened this issue 3 years ago • 4 comments

  • nbautoexport version: 0.3.1
  • Python version: 3.8
  • Operating System: Windows 10

I have a jupyter notebook and I have an image together in the same folder. I then inserted the image into the notebook using markdown i.e. ![png](image.png). This displays fine within the notebook.

When running nbautoexport to export the notebook to markdown the result is placed in a separate folder called markdown. However the path to the image stays the same which causes it to not be displayed. Is there a way to update the path such that it points to the original file?

There is a workaround which involves displaying the image using code. The image then does get copied over to the markdown folder.

What is your preferred use? Should we not use markdown to insert images?

adfi avatar Jul 09 '21 17:07 adfi

@adfi A few options that are workarounds: (1) You could use absolute paths (local only, so maybe not that useful) (2) You could edit jupyter_notebook_config.py to customize the save function like we do to also copy the files you reference in markdown separately to the markdown folder.

A couple options for us to better support this scenario: (3) Would it work for you if the markdown and the original notebook just lived in the same folder? That the relative links to resources would be the same. We could provide an organize_by option that does not place the output in a subfolder. (4) Would it work for you to specify a folder in .nbautoexport of assets to be copied to the subfolder? That's another possible implementation on our end.

pjbull avatar Jul 13 '21 00:07 pjbull

Thanks for your reply.

(1) As you say this one isn't what we're looking for (2) I don't really know how to customize the save function, if you have an example that would be helpful.

(3) That would be helpful in general (4) This would be a good backup in case (3) doesn't work

adfi avatar Jul 14 '21 17:07 adfi

Awesome, we'd definitely take a PR for 3, which should be easy. Here's the relevant code block: https://github.com/drivendataorg/nbautoexport/blob/3e9a1ed2e15e5089e3f2b20a849f26513a77ff05/nbautoexport/export.py#L99-L102

To implement it, we'd need a few things:

  • [ ] add new if block with organize_by == 'none' and set subfolder = None (which
  • [ ] add a test
  • [ ] add documentation

pjbull avatar Jul 15 '21 05:07 pjbull

Thanks for the guidance, I'll try to work on it this week.

adfi avatar Jul 15 '21 10:07 adfi