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

Variable names in double curly braces don't evaluate in HTML export #3463

Open
bencaine1 opened this issue Mar 23, 2018 · 6 comments
Open

Variable names in double curly braces don't evaluate in HTML export #3463

bencaine1 opened this issue Mar 23, 2018 · 6 comments

Comments

@bencaine1
Copy link

bencaine1 commented Mar 23, 2018

For example:

[python cell]
my_var = 11

[markdown cell]
my_var evaluates to {{my_var}}

If the markdown cell is run in the jupyter notebook, it will say "my_var evaluates to 11". But if it's exported to html, it just says "my_var evaluates to {{my_var}}".

@takluyver
Copy link
Member

That's something that an extension does - we don't support variables in markdown cells by default. So nbconvert would need an extension as well.

@BoPeng
Copy link

BoPeng commented Mar 26, 2018

This is achieved in SoS Notebook through a %render magic which renders output from any cell in markdown (and other formats).

image

This is powerful but a bit troublesome to use, so I am thinking of a markdown kernel that renders its content in markdown. #2908 also discussed this.

@bencaine1
Copy link
Author

Gotcha. It'll probably be easier for me to just put the variable in a string in python and use IPython.core.display to display it with formatting, but it's good to know that this extension exists. Thanks for your time!

@BoPeng
Copy link

BoPeng commented Mar 26, 2018

The markdown-kernel is about the simplest kernel one can write so I just implemented it.

With this kernel and SoS, you can insert variables into cells of the markdown kernel (not markdown cells) using magic %expand.

image

Compared to regular markdown cells, cells from the markdown kernel are always displayed. This is not a big issue for sos users because sos generated HTML report hides cell inputs by default (documentation and example).

@jeremyabramson
Copy link

The markdown-kernel is about the simplest kernel one can write so I just implemented it.

With this kernel and SoS, you can insert variables into cells of the markdown kernel (not markdown cells) using magic %expand.

image

Compared to regular markdown cells, cells from the markdown kernel are always displayed. This is not a big issue for sos users because sos generated HTML report hides cell inputs by default (documentation and example).

Thanks @BoPeng for the solution! It's the only one I've seen that works at all. For my use case, however, the display of the originating MD cell isn't really workable. I'm trying to create presentations with significant textual content -- not just code dumps, as is typically done with Jupyter/reveal.js slide shows -- and would love to be able to templatize them (not to mention, integrate with RISE to allow for live code execution). In that context, I'd really love for the reveal.js slide output to hide the originating slide. Not sure if that's possible (it looks like SoS notebooks don't play nice with reveal.js output in the first place) but I just figured I'd mention it. I'd imagine I'm not the only one looking for this functionality.

Thanks again!

@BoPeng
Copy link

BoPeng commented Jun 19, 2019

There are different types of "hide input".

The first type is hiding input in the notebook interface as in the case of markdown cell, which was requested in vatlab/markdown-kernel#2 with no proper solution yet. The problem is that markdown-kernel is just a kernel and it needs help from a frontend extension to hide input. Then there are classic jupyter and jupyterlab, both have their own set of "hide input" stuff. For example, hide input is a popular extension for classic jupyter, and jupyterlab has extensive features for hiding cell input and output. It is therefore arguable if markdown-kernel should introduce yet another mechanism to hide input.

The second type is hiding input in the nbconvert output, typically in HTML format. SoS Notebook provides a number of templates that uses cell tags to control the output of cell content, so this case is covered.

You seem to need yet another type of hide input, namely hide input for presentation. I frankly have no experience with this and do not know what would be required. You meantioned that reveal.js does not work well with SoS Notebook so please register a ticket at either sos-notebook or markdown-kernel so that we can have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants