Skip to content

Commit

Permalink
Merge pull request #1161 from martinRenou/test_nbconvert_master
Browse files Browse the repository at this point in the history
Update nbconvert pinning
  • Loading branch information
jtpio committed Oct 4, 2022
2 parents 04b3aef + 268511d commit 8244587
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies = [
"jupyter_server>=1.18,<2.0.0",
"jupyterlab_server>=2.3.0,<3",
"nbclient>=0.4.0,<0.7",
"nbconvert>=6.4.5,<7",
"nbconvert>=6.4.5,<8",
"traitlets>=5.0.3,<6",
"websockets>=9.0",
]
Expand Down Expand Up @@ -96,7 +96,7 @@ path = "hatch_build.py"
[tool.hatch.build.targets.sdist]
exclude = [
".github",
"*.gif",
"*.gif",
]

[tool.hatch.build.hooks.jupyter-builder]
Expand Down
4 changes: 2 additions & 2 deletions tests/notebooks/print_parameterized.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 4
}
"nbformat_minor": 5
}
Binary file modified ui-tests/tests/voila.test.ts-snapshots/interactive-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ui-tests/tests/voila.test.ts-snapshots/query-strings-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions voila/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@
class VoilaMarkdownRenderer(IPythonRenderer):
"""Custom markdown renderer that inlines images"""

def __init__(self, contents_manager, *args, **kwargs):
self.contents_manager = contents_manager
super().__init__(*args, **kwargs)

def image(self, src, title, text):
contents_manager = self.options['contents_manager']
contents_manager = self.contents_manager
if contents_manager.file_exists(src):
content = contents_manager.get(src, format='base64')
data = content['content'].replace('\n', '') # remove the newline
mime_type, encoding = mimetypes.guess_type(src)
src = 'data:{mime_type};base64,{data}'.format(mime_type=mime_type, data=data)
return super(VoilaMarkdownRenderer, self).image(src, title, text)
return super().image(src, title, text)


class VoilaExporter(HTMLExporter):
"""Custom HTMLExporter that inlines the images using VoilaMarkdownRenderer"""

base_url = traitlets.Unicode(help="Base url for resources").tag(config=True)
markdown_renderer_class = traitlets.Type('mistune.Renderer').tag(config=True)
markdown_renderer_class = traitlets.Type(VoilaMarkdownRenderer).tag(config=True)
# Can be a ContentsManager from notebook or jupyter_server, so Any will have to do for now
contents_manager = traitlets.Any()

Expand Down

0 comments on commit 8244587

Please sign in to comment.