Open pbacellar opened 2 years ago
I'm really not sure what the best behavior is. Isn't it considered good practice for ipynbs to embed the necessary images? Mightn't someone want to extract the contained images without destroying this feature of the ipynb?
I didn't know that was good practice, but I don't see how the behavior I expected should cause harm in that regard.
Someone interested in extracting the images while keeping the ipynb unchanged could simply discard the output file or pipe it to /dev/null and keep using the original. This way, both use cases would be covered.
Do you think this could be unwanted behavior?
I don't know, I'd like to hear from more ipynb users. @ickc any comments on this?
Isn't it considered good practice for ipynbs to embed the necessary images?
I'm not sure if this is a "good practice", or just that being self-contained by default is better for adoption. ipynb comes from the desire to replicate Mathematica notebook experience for data science using Python (and later on generalize to other languages.)
And it is more practical for generated assets (say a function plotting an image in png) within the same notebook as well. Then within the jupyter process, it is referencing something inside the data structure it is holding, rather than a reference to an external path that requires separate IOs.
Also, I've seen some people, just like how we would normally author in markdown, write markdown in Jupyter cell that references external image links. In this case it is no different than the "Expected output json" above.
Mightn't someone want to extract the contained images without destroying this feature of the ipynb?
Perhaps in this case they could just extract the media without outputting the file (and discard the stdout)?
Practically speaking, I don't think the proposed change would impact current users negatively for the above reasons. A few observations:
may be it is worth investigating other situations that a base64 data image would appears, e.g. using matplotlib to generate a png/pdf (or even svg). How/Can Jupyter handle this case where a cell output references external images? If it can't, pandoc test.ipynb --extract-media=images -o output_test.ipynb
replacing only some base64 data seems not a very good behavior? (But certainly doing the best pandoc can do given the limitation may not be a bad behavior.)
How --extract-media
in "endomorphisms" (like pandoc test.FORMAT --extract-media=images -o output_test.FORMAT
) should behave across different FORMAT
? For some format like docx, the current ipynb behavior seems to be the only right choice. Treating ipynb docx-like doesn't seem a bad behavior. The problem here is that ipynb, while technically is plain text, shares some characteristics of binary formats like docx/epub.
Explain the problem.
When running:
pandoc test.ipynb --extract-media=images -o output_test.ipynb
I would expect pandoc to extract the images from the ipynb into a folder and to modify the ipynb json to use the images in the folder. Instead, pandoc extracts the images but doesn't seem to correctly modify the json.
Original notebook:
Output notebook
Expected output json
This extraction process and redirection works fine with htmls:
Running
pandoc test.ipynb --self-contained --metadata title="test" -o test.html
produces a self contained html with base64 images.Then
pandoc test.html --extract-media=images -o output_test.html
produces the expected outputYou can find this simple test ipynb notebook attached Thanks in advance,
Pandoc version?
OS: Manjaro