Skip to content

{% filter solution %} for Jupyter notebooks #13

Open

Description

@frenzymadness

It'd be nice to have a possibility to hide solutions by {% filter solution %} also in Jupyter notebooks.

Activity

  1. encukou commented on Oct 16, 2019

    @encukou
    Member

    Maybe it would be easier to hide cells based on cell metadata. Would that work for you as well?

  2. frenzymadness commented on Oct 16, 2019

    @frenzymadness
    MemberAuthor

    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.

  3. hroncok commented on Oct 16, 2019

    @hroncok
    Member
  4. frenzymadness commented on Nov 13, 2019

    @frenzymadness
    MemberAuthor

    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.

  5. encukou commented on Nov 13, 2019

    @encukou
    Member

    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 to solution_url. The downside is that you then need Javascript to see the solution.

  6. transferred this issue frompyvec/naucseon Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions