drivendataorg/nbautoexport

Referencing images with markdown not carried over in output

adfi opened this issue · 4 comments

adfi commented
  • 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 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.

adfi commented

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

Awesome, we'd definitely take a PR for 3, which should be easy. Here's the relevant code block:

if config.organize_by == "notebook":
subfolder = notebook_path.stem
elif config.organize_by == "extension":
subfolder = export_format.value

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
adfi commented

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