-
Notifications
You must be signed in to change notification settings - Fork 572
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
WIP - Lab template #1005
WIP - Lab template #1005
Conversation
Just a note on highlight style. I believe the style is limited by our use of the pygments lexers. I made a style over at nb_pdf_template that mimics the notebook highlight scheme the best it can. |
Thanks for the pointer @t-makaro. Another goal of my PR is to use jupyterlab's CSS variable so that we can switch themes dynamically and nbconverted HTML can be used within JupyterLab while being consistent with the current Jupyterlab Theme. |
8c2c971
to
506a021
Compare
So this appears to work (and to support JupyterLab themes) but the way to include the JupyterLab CSS is still manual. At the moment, the CSS from the classic notebook (style.min.css) is included in the resources for the jinja template here. Either I replace |
b622cd1
to
ad54d66
Compare
In the last commit, I replace the style.min.css with the one generated for jlab. This can easily be tested now. This does not include the new pygment theme yet. The |
779fd57
to
950cb1d
Compare
9a1539a
to
8c47667
Compare
To compare the styles from before / after. I'm not sure what the stance has been for style of nbconvert (in particular the default style) as that was established a bit before I joined. So I think I'd want opinions from devs that have more context on style. It might be surprising in classic notebook to not see the same style exported as you saw on screen for example. @minrk @willingc I'm not sure if either of you had opinions on the topic or know how non-bug fix style decisions in nbconvert have been made in the past? |
Codewise the changes look solid. |
(Quick note: on your screenshot, "after" is on the left.)
|
@@ -311,7 +311,6 @@ def test_no_prompt(self): | |||
with open("notebook1.html",'r') as f: | |||
text = f.read() | |||
assert "In [" not in text | |||
assert "Out[" not in text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out[
is in fact in the jlab CSS bundle, so I had to remove that test.
This is looking great, @SylvainCorlay, thank you! Can we copy these files to make a new template so we keep the default as it is right now? |
Looks great! Any idea if it would be possible to hook in the jupyterlab mime rendering machinery? That'd be the only way to display custom rich output iiuc (extensions aren't supposed to render themselves anymore). |
Thanks. There is a small obstacle which is that beyond the jinja template files, the defaut I am actually thinking of using a custom HTML exporter in |
Actually, we already support rendering live widgets in nbconverted notebooks (see e.g. here or in the ipywidgets documentation, using the rst nbconvert exporter of nbsphinx) but this does not use generic rendermime. This is definitely something we should do, but it is somewhat orthogonal to the choice of template. |
Re: mimerenderers: this is greatly desired for me, but at that point, I'd
just want all (or as much as I want) of lab... but definitely out of scope
of this PR to get us to the next level!
This is totally possible:
https://deathbeds.github.io/jyve/lab/
(Implementation
https://github.com/deathbeds/jyve/blob/master/jyve/exporter.py)
The number of patches is smaller than one would imagine, mainly around
session management and contents warnings.
I've been tinkering with the voila stack to make it work there, there but
no demo yet... Lots of url mangling will be required.
The biggest challenge would be in documenting and then building with which
extensions you want baked in... I guess I'm thinking each deployed lab
would be specified with a config file (or a "master" notebook) which could
specify extensions and a workspace.
Looking further out: for an nbviewer formatter this gets a little crazy....
We'd basically have to offer a requirejs escape hatch.
…On Sun, May 5, 2019, 16:39 Sylvain Corlay ***@***.***> wrote:
Looks great!
Any idea if it would be possible to hook in the jupyterlab mime rendering
machinery? That'd be the only way to display custom rich output iiuc
(extensions aren't supposed to render themselves anymore).
Actually, we already support rendering live widgets in nbconverted
notebooks (see e.g. here
<https://nbviewer.jupyter.org/github/jupyter-widgets/ipywidgets/blob/master/docs/source/examples/Widget%20List.ipynb>
or in the ipywidgets documentation, using the rst nbconvert exporter of
nbsphinx) but this does not use generic rendermime. This is definitely
something we should do, but it is somewhat orthogonal to the choice of
template.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1005 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAALCREGU3FLCACA6BXENUDPT5AX7ANCNFSM4HJMXGVQ>
.
|
Got it, sorry for the offtopic. I also now found #755, which is the correct place to track plans for supporting mimerender. |
I opened jupyterlab/jupyterlab#6314 into JupyterLab to produce the CSS bundle. As soon as the package is released, I will be able to reference the |
@bollwyvl thanks for all the pointers! I was completely unaware of Jive. I would love to hear more about it! |
6ca3dda
to
78cea76
Compare
The JupyterLab CSS bundler has been merged and published to NPM. I have updated this PR to reflect this change. I think we are getting close to a mergeable state. |
Note: you can now select the dark theme with
|
@MSeal requested historical perspective: nbconvert HTML style has been defined as "what the notebook does" which is why we bundle the notebook css in nbconvert, and intend to reproduce the DOM of the live notebook. In that context, with JupyterLab as a peer to nbclassic and its intended replacement, it makes sense to me to add jupyterlab as an output style, and even in the future replace the nbclassic style with jupyterlab as the default, especially if the differences prove uncontroversial. |
Thanks for the context. @SylvainCorlay could you preserve the default as the classic look and make lab an adjacent template then? We'd likely need classic template available even if the default changes in the future. |
This may not be possible merely as an "alternative" jinja template for the HTML exporter, but only as a completely new template exporter (to both change the way the CSS header is composed and the jinja template). What I am thinking of is to enable the sort of template configuration that we have in voila, where a template is merely a directory in a conf.d, holding all the required resources. |
c31a83f
to
07cb2a1
Compare
07cb2a1
to
7163caf
Compare
That could work. I'd say use best judgement on how to achieve something mergable in this PR. If we need to hack the exporter a bit to avoid clobbering the current default view I'm ok with that if we have a longer term approach (this could be a change for 6.0?), but we do need a path to preserve the classic export look-n-feel as default for now imo. |
Absolutely. Let's hold this up for a bit more and see if we come up with a nicer approach than a completely new template exporter without too much change. |
Closing as this was included through another PR. |
This PR adds an nbconvert template producing the same DOM structure as JupyterLab.
Templates
The goal is to enable the styling of HTML produced with nbconvert with JupyterLab's themes.
basic.tpl
contains the main jinja2 block producing the JLab DOM structure.full.tpl
includes the CSS. The CSS is generated with the https://github.com/SylvainCorlay/labcss_bundler JS project.Pygments theme
Besides, I am working on a
pygments
theme using the JupyterLab CSS variables used by the Jupyter CodeMirror theme.For reference, the pygments stylesheet that produces the same colors as JupyterLab. (This pygments style requires the Pygments PR #814)
Light theme:
Dark theme:
cc @mpacer @MSeal @maartenbreddels @ivanov @ellisonbg