You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, sure, whatever is easier to implement. I just don't know how does the machinery translating notebook to HTML works here. It would be nice if it would look the same as in MD/HTML and also with "uncover the solution" functionality.
I dive deeper a little bit and now I understand how I can adjust nbconvert templates. But what I don't know yet is how I can combine it all together. It seems that adding the right class to some div element is not enough because the solution filter is much more complicated.
I can imagine that a simple modification of nbconvert template would add a {% filter solution %} around a cell content based on a cell metadata/tags. But then, the resulting HTML would have to be processed once more with Jinja.
Is there a simple way how to process a result of nbconvert NaucseHTMLExporter with Jinja? nbconvert uses Jinja internally so it might be possible to just register a template filter and let nbconvert to handle it.
A quick temporary solution would be to avoid putting stuff in ctx['$solutions'], and omitting the link to solution_url. The downside is that you then need Javascript to see the solution.
Activity
encukou commentedon Oct 16, 2019
Maybe it would be easier to hide cells based on cell metadata. Would that work for you as well?
frenzymadness commentedon Oct 16, 2019
Yes, sure, whatever is easier to implement. I just don't know how does the machinery translating notebook to HTML works here. It would be nice if it would look the same as in MD/HTML and also with "uncover the solution" functionality.
hroncok commentedon Oct 16, 2019
This is the way we render Notebooks:
https://github.com/pyvec/naucse_render/blob/master/naucse_render/notebook.py
frenzymadness commentedon Nov 13, 2019
I dive deeper a little bit and now I understand how I can adjust nbconvert templates. But what I don't know yet is how I can combine it all together. It seems that adding the right class to some div element is not enough because the solution filter is much more complicated.
I can imagine that a simple modification of nbconvert template would add a
{% filter solution %}around a cell content based on a cell metadata/tags. But then, the resulting HTML would have to be processed once more with Jinja.Is there a simple way how to process a result of nbconvert
NaucseHTMLExporterwith Jinja? nbconvert uses Jinja internally so it might be possible to just register a template filter and let nbconvert to handle it.encukou commentedon Nov 13, 2019
There are three divs, see https://github.com/pyvec/naucse_render/blob/master/naucse_render/templates.py#L48
A quick temporary solution would be to avoid putting stuff in
ctx['$solutions'], and omitting the link tosolution_url. The downside is that you then need Javascript to see the solution.