Hide markdown cell in Jupyter notebook - jupyter-notebook

I would like to hide the content of a markdown cell, so users can unhide it after. I have tried following https://jupyterbook.org/en/stable/interactive/hiding.html however this is just essentially giving me the text of the command
gives
What am I missing? I have tried other options including using {note} Hello and the other options on the page without any success.

Related

Padding in input cells and bigger output cells jupyter notebook slideshow presentation

I am struggling with jupyter notebook slideshow. At the beginning I made a presentation, everything looked normal. However later I wanted to align some text, move image to the ceneter, adding padding, setting margins etc. I was using html for that.
Now sth changed my settings gloabally and my input and output cells looks bizzare.
exemplary view
I tried to reinstall jupyter.
I tried creating new notebook.
I tried two different browsers with cleaning cache.
I used jt -r command.
I deleted manually custom.css
I have no idea how to make it look as it used to.
I make my presentation by this command in jupyter notebook terminal:
jupyter nbconvert "<test.ipynb" --to slides --post serve

How to collapse a Java code cell (made in Jupyter Notebook) on a website with Jekyll blog posts?

I have a blogging website using fastpages, which allows me to create Jekyll posts, along with posts created with Jupyter Notebook.
I'm creating a Jupyter Notebook post in VS Code that is using the Java kernel and want to hide a Java code cell.
The fastpages README says that you can hide a code cell with #collapse at the top of the code cell, while its blog website says that you can use #collapse-hide.
I tried both of these options on my code cell, but when I run them, it says illegal character: '#'
I think the issue might be that #collapse-hide might only work for Python cells, but I'm pretty lost when searching for the problem.
The Jupyter Notebook documentation says that you can hide code cells with
{
"tags": [
"hide-input",
]
}
but I do not know where to put this metadata in.
On that page, there is also a link to a cell tags guide. I tried Step 1 (by clicking View -> Cell Toolbar -> Tags), but after clicking the Tabs button, I do not know what to do. I also tried going to View -> Cell Toolbar -> Edit Metadata, but when I paste the metadata above, it says Could not save invalid JSON
(by the way, I am using Jupyter Notebook on my localhost now, not VS Code)
I tried removing the curly braces from the metadata (because I think the curly braces would be for if I only paste the metadata and there isn't the other stuff (like "vscode": {...?), but the same error occurs.
I don't know how to code in JSON, I would just like to be able to hide my code cell on my website, like this:
I do not even know if I am heading in the right direction. Basically, I would like to know: how can I hide my Java code cell?

Is it possible to customize markdown rendering in a Jupyter notebook to add custom links?

I want to add a custom link syntax in the Markdown cells in a Jupyter notebook so that I can have a Markdown cell that looks like this:
See Cell ref:label-1 for example
And the "ref:label-1" would be rendered as a hyperlink that when clicked on would jump to a cell in the notebook that was somehow labeled with "label-1". The hyperlink would also have a tooltip that shows the cell contents.
Is anything like this even possible? I have not found any starting points to build from so far.

How can I make a presentable PDF from a Jupyter Notebook?

I know that I can click on File -> Print Preview and let my browser save the result as a PDF. But that PDF will contain quite a bit of code.
Can I hide parts from the print preview or make a PDF with another tool?
Ideally, there would be magic functions:
%hide: Hide the cell and its output
%hide-code: Hide only the code of the cell, but show the output of the code
Print to PDF in the browser
In JupyterLab, you can hide the cell's input and output by clicking the side bar as demonstrated in the doc. After hiding, you can use the browser's printing menu to generate a PDF. I've tested it on FireFox and expect similar result on Chrome or Edge.
Export to PDF with nbconvert
If you aim at a native conversion from ipynb format to pdf, the nice old nbconvert tool is your friend. It usually comes together with Jupyter and can be invoked conveniently in the menu of JupyterLab File->Export Notebook As...->PDF or, in the classic Jupyter Notebook interface, File->Download as->PDF (via LaTeX).
Hiding input/output in cells can be realized by setting the cell's metadata hide_input=true and installing a nbextension as discussed in issue #155.
Print Preview menu in the classical Jupyter
Finally to your question
Can I hide parts from the print preview or make a PDF with another tool?
The "print preview" button in the classical Jupyter interface is a shortcut for calling nbconvert to generate a HTML file and redirect your browser to it. Therefore, similar configuration for nbconvert to hide input as discussed above (in issue #155) can be used. This feature is implemented by jupyter_contrib_nbextensions bundle and explained in the doc.
As the above-mentioned answers do not work for me; I found another solution:
I use an additional package notebook-as-pdf.
Read the tutorial here. It uses Chromium and is the only approach that worked for me so far reliably. The "print preview" does still not work. But it produces a clean PDF with no code input.
I do:
pip install -U notebook-as-pdf
pyppeteer-install
jupyter nbconvert --to PDFviaHTML --TemplateExporter.exclude_input=True PATH_TO_YOUR_FILE.ipynb
What did NOT work for me:
The solution above.
All the scripts mentioned in those answers

Is it possible to exclude some cells from the ipython notebook when using NBConvert

Is there a method to exclude some cells from the NBconvert process
For instance. An embedded video is cool when running to HTML, but when converting the HTML to PDF it creates a problem. So I want to exclude it in some instances.
Found a nice workaround for this, using the 'slides' option of nbconvert:
In your iPython notebook under "Cell Toolbar" select "Slideshow"
Then in the top right of the cells that you don't want to show select Slide Type "skip"
Now run python nbconvert your_notebook.ipynb --to slides
Instead of serving the slide, just open the resulting html in a browser.
And.. It doesn't contain the slides you told it to skip!
Hope this helps.

Resources