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

Figures not extracted even with ExtractOutputPreprocessor #807

Closed
parthi2929 opened this issue May 6, 2018 · 2 comments
Closed

Figures not extracted even with ExtractOutputPreprocessor #807

parthi2929 opened this issue May 6, 2018 · 2 comments

Comments

@parthi2929
Copy link

Hi

I am trying to export html with base64 images as separate files (to import to wordpress blog). Below is code I am trying as per suggestion here. The 'ouptuts' dictionary is simply empty with no png files.

# from urllib.request import urlopen
from nbconvert import HTMLExporter
from traitlets.config import Config
import nbformat

# Load file
contentString = open('test.ipynb').read()
jake_notebook = nbformat.reads(contentString, as_version=4)


# Default HTML exporter
html_exporter = HTMLExporter()
html_exporter.template_file = 'basic'
# print("Resources:", resources.keys())
# print("Metadata:", resources['metadata'].keys())
# print("Inlining:", resources['inlining'].keys())
# print("Extension:", resources['output_extension'])

# HTML exporter with figures
c = Config()
c.HTMLExporter.preprocessors = ['nbconvert.preprocessors.ExtractOutputPreprocessor']
html_exporter_with_figs = HTMLExporter(config=c)
html_exporter_with_figs.preprocessors


(_, resources)          = html_exporter.from_notebook_node(jake_notebook)
(_, resources_with_fig) = html_exporter_with_figs.from_notebook_node(jake_notebook)

print("resources without figures:")
print(sorted(resources.keys()))

print("\nresources with extracted figures (notice that there's one more field called 'outputs'):")
print(sorted(resources_with_fig.keys()))

print("\nthe actual figures are:")
print(sorted(resources_with_fig['outputs'].keys()))

Kindly help. Here is the gist (please check raw, as gist does not seem to decode base64 inline image)

@takluyver
Copy link
Member

ExtractOutputPreprocessor only extracts outputs, not attachments in markdown cells. I think someone was investigating extracting attachments in another issue thread.

@tuncbkose
Copy link
Contributor

This should now be doable with #1978

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

No branches or pull requests

4 participants