diff --git a/pyproject.toml b/pyproject.toml index 921a73c4c..9d424ddf7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", ] @@ -96,7 +96,7 @@ path = "hatch_build.py" [tool.hatch.build.targets.sdist] exclude = [ ".github", - "*.gif", + "*.gif", ] [tool.hatch.build.hooks.jupyter-builder] diff --git a/tests/notebooks/print_parameterized.ipynb b/tests/notebooks/print_parameterized.ipynb index a5d9f2e94..87961bfa6 100644 --- a/tests/notebooks/print_parameterized.ipynb +++ b/tests/notebooks/print_parameterized.ipynb @@ -43,5 +43,5 @@ } }, "nbformat": 4, - "nbformat_minor": 4 -} \ No newline at end of file + "nbformat_minor": 5 +} diff --git a/ui-tests/tests/voila.test.ts-snapshots/interactive-linux.png b/ui-tests/tests/voila.test.ts-snapshots/interactive-linux.png index 770ebf536..91a27d71e 100644 Binary files a/ui-tests/tests/voila.test.ts-snapshots/interactive-linux.png and b/ui-tests/tests/voila.test.ts-snapshots/interactive-linux.png differ diff --git a/ui-tests/tests/voila.test.ts-snapshots/query-strings-linux.png b/ui-tests/tests/voila.test.ts-snapshots/query-strings-linux.png index 238fdc155..dc723c85a 100644 Binary files a/ui-tests/tests/voila.test.ts-snapshots/query-strings-linux.png and b/ui-tests/tests/voila.test.ts-snapshots/query-strings-linux.png differ diff --git a/voila/exporter.py b/voila/exporter.py index 7612836e1..635d57539 100644 --- a/voila/exporter.py +++ b/voila/exporter.py @@ -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()