Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referencing images with markdown not carried over in output #73

Open
adfi opened this issue Jul 9, 2021 · 4 comments
Open

Referencing images with markdown not carried over in output #73

adfi opened this issue Jul 9, 2021 · 4 comments

Comments

@adfi
Copy link

adfi commented Jul 9, 2021

  • 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?

@pjbull
Copy link
Member

pjbull commented Jul 13, 2021

@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
Copy link
Author

adfi commented Jul 14, 2021

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

@pjbull
Copy link
Member

pjbull commented Jul 15, 2021

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
Copy link
Author

adfi commented Jul 15, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants