When the notebook is refreshed in Jupyter, cell inputs are loaded from the script or Markdown document and kernel variables are preserved.
This is a common feature and is supported by RStudio within R Markdown for example. Surprisingly, Jupyter Notebooks do not support the inclusion of variables in Markdown Cells out of the box. If you still use Jupyter Notebooks there is a readily solution: the Python Markdown extension. Quando scrivo qualcosa nel campo markdown del taccuino jupyter, gli errori di battitura non vengono evidenziati e spesso mi sono ritrovato con qualcosa del genere: In quasi tutti gli IDE che ho. In this guide, we'll be using Jupyter notebooks to demonstrate markdown, however note that markdown is not Jupyter specific. Many other services and products use it to allow easy text formatting. NOTE: In our quick guide on how to use Jupyter notebooks, we mentioned that Jupyter allows changing the type of a cell to make it a markdown cell.
Text can be added to Jupyter Notebooks using Markdown cells. Markdown isa popular markup language that is a superset of HTML. Its specificationcan be found here:
Markdown basics¶
You can make text italic or bold.
You can build nested itemized or enumerated lists:
- One
- Sublist
- This
- Sublist - That - The other thing
- Sublist
- Two
- Sublist
- Three
- Sublist
Now another list:
- Here we go
- Sublist
- Sublist
- There we go
- Now this
You can add horizontal rules:
Here is a blockquote:
And shorthand for links:
Headings¶
Edit Markdown Cell Jupyter
You can add headings by starting a line with one (or multiple) #
followed by a space, as in the following example:
Embedded code¶
You can embed code meant for illustration instead of execution inPython:
or other languages:
LaTeX equations¶
Courtesy of MathJax, you can include mathematical expressions bothinline: (e^{ipi} + 1 = 0) and displayed:
Inline expressions can be added by surrounding the latex code with$
:
Expressions on their own line are surrounded by $$
:
GitHub flavored markdown¶
The Notebook webapp supports Github flavored markdown meaning that youcan use triple backticks for code blocks:
Gives:
And a table like this:
A nice HTML Table:
This | is |
---|---|
a | table |
General HTML¶
Because Markdown is a superset of HTML you can even add things like HTMLtables:
Header 1 | Header 2 |
---|---|
row 1, cell 1 | row 1, cell 2 |
row 2, cell 1 | row 2, cell 2 |
Local files¶
If you have local files in your Notebook directory, you can refer tothese files in Markdown cells directly:
For example, in the images folder, we have the Python logo:
and a video with the HTML5 video tag:
Create Markdown Cell Jupyter
These do not embed the data into the notebook file, and require that thefiles exist when you are viewing the notebook.
Markdown Cell Jupyter Lab
Security of local files¶
Note that this means that the Jupyter notebook server also acts as ageneric file server for files inside the same tree as your notebooks.Access is not granted outside the notebook folder so you have strictcontrol over what files are visible, but for this reason it is highlyrecommended that you do not run the notebook server with a notebookdirectory at a high level in your filesystem (e.g. your home directory).
Markdown Cell Jupyter Notebook
When you run the notebook in a password-protected manner, local fileaccess is restricted to authenticated users unless read-only views areactive.