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

Update nbconvert pinning #1161

Merged
merged 9 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
martinRenou marked this conversation as resolved.
Show resolved Hide resolved
"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
Loading
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
Loading
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