- Ipython Notebook Markdown Cheat Sheet
- Jupyter Text
- Ipython Notebook Markdown
- Ipynb Markdown
- Ipython Notebook Markdown Image
Cell Types¶
There are a few basic cell types for encapsulating code and text.All cells have the following basic structure:
Markdown cells¶
Markdown cells are used for body-text, and contain markdown,as defined in GitHub-flavored markdown, and implemented in marked.
Changed in version nbformat: 4.0
Heading cells have been removed, in favor of simple headings in markdown.
Code cells¶
Security in IPython notebooks¶ As IPython notebooks become more popular for sharing and collaboration, the potential for malicious people to attempt to exploit the notebook for their nefarious purposes increases. IPython 2.0 introduces a security model to prevent execution of untrusted code without explicit user input. In Ipython/Jupyter Notebooks it is very simple. Make sure the cell is indeed in markup and to display a image use:! alt text (imagename.png 'Title') Further advantage compared to the other methods proposed is that you can display all common file formats including jpg, png, and gif (animations).
Code cells are the primary content of Jupyter notebooks.They contain source code in the language of the document’s associated kernel,and a list of outputs associated with executing that code.They also have an execution_count, which must be an integer or null
.
Changed in version nbformat: 4.0
input
was renamed to source
, for consistency among cell types.
Changed in version nbformat: 4.0
prompt_number
renamed to execution_count
Code cell outputs¶
A code cell can have a variety of outputs (stream data or rich mime-type output).These correspond to messages produced as a result of executing the cell.
All outputs have an output_type
field,which is a string defining what type of output it is.
stream output¶
Changed in version nbformat: 4.0
The keys stream
key was changed to name
to matchthe stream message.
display_data¶
Rich display outputs, as created by display_data
messages,contain data keyed by mime-type. This is often called a mime-bundle,and shows up in various locations in the notebook format and message spec.The metadata of these messages may be keyed by mime-type as well.
Changed in version nbformat: 4.0
application/json
output is no longer double-serialized into a string.
Changed in version nbformat: 4.0
mime-types are used for keys, instead of a combination of short names (text
)and mime-types, and are stored in a data
key, rather than the top-level.i.e. output.data['image/png']
instead of output.png
.
execute_result¶
Results of executing a cell (as created by displayhook
in Python)are stored in execute_result
outputs.execute_result
outputs are identical to display_data
,adding only a execution_count
field, which must be an integer.
Ipython Notebook Markdown Cheat Sheet
Changed in version nbformat: 4.0
pyout
renamed to execute_result
Changed in version nbformat: 4.0
prompt_number
renamed to execution_count
error¶
Failed execution may show a traceback
Changed in version nbformat: 4.0
pyerr
renamed to error
Jupyter Text
Raw NBConvert cells¶
Ipython Notebook Markdown
A raw cell is defined as content that should be included unmodified in nbconvert output.For example, this cell could include raw LaTeX for nbconvert to pdf via latex,or restructured text for use in Sphinx documentation.
Ipynb Markdown
The notebook authoring environment does not render raw cells.
Ipython Notebook Markdown Image
The only logic in a raw cell is the format
metadata field.If defined, it specifies which nbconvert output format is the intended targetfor the raw cell. When outputting to any other format,the raw cell’s contents will be excluded.In the default case when this value is undefined,a raw cell’s contents will be included in any nbconvert output,regardless of format.