You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
test-jupyter-notebooks/Working With Markdown Cells...

370 lines
42 KiB

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Markdown Cells"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Text can be added to Jupyter Notebooks using Markdown cells. You can change the cell type to Markdown by using the `Cell` menu, the toolbar, or the key shortcut `m`. Markdown is a popular markup language that is a superset of HTML. Its specification can be found here:\n",
"\n",
"<https://daringfireball.net/projects/markdown/>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Markdown basics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can make text *italic* or **bold** by surrounding a block of text with a single or double * respectively"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can build nested itemized or enumerated lists:\n",
"\n",
"* One\n",
" - Sublist\n",
" - This\n",
" - Sublist\n",
" - That\n",
" - The other thing\n",
"* Two\n",
" - Sublist\n",
"* Three\n",
" - Sublist\n",
"\n",
"Now another list:\n",
"\n",
"1. Here we go\n",
" 1. Sublist\n",
" 2. Sublist\n",
"2. There we go\n",
"3. Now this"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can add horizontal rules:\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here is a blockquote:\n",
"\n",
"> Beautiful is better than ugly.\n",
"> Explicit is better than implicit.\n",
"> Simple is better than complex.\n",
"> Complex is better than complicated.\n",
"> Flat is better than nested.\n",
"> Sparse is better than dense.\n",
"> Readability counts.\n",
"> Special cases aren't special enough to break the rules.\n",
"> Although practicality beats purity.\n",
"> Errors should never pass silently.\n",
"> Unless explicitly silenced.\n",
"> In the face of ambiguity, refuse the temptation to guess.\n",
"> There should be one-- and preferably only one --obvious way to do it.\n",
"> Although that way may not be obvious at first unless you're Dutch.\n",
"> Now is better than never.\n",
"> Although never is often better than *right* now.\n",
"> If the implementation is hard to explain, it's a bad idea.\n",
"> If the implementation is easy to explain, it may be a good idea.\n",
"> Namespaces are one honking great idea -- let's do more of those!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And shorthand for links:\n",
"\n",
"[Jupyter's website](https://jupyter.org)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can use backslash \\ to generate literal characters which would otherwise have special meaning in the Markdown syntax.\n",
"\n",
"```\n",
"\\*literal asterisks\\*\n",
" *literal asterisks*\n",
"```\n",
"\n",
"Use double backslash \\ \\ to generate the literal $ symbol."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Headings"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can add headings by starting a line with one (or multiple) `#` followed by a space, as in the following example:\n",
"\n",
"```\n",
"# Heading 1\n",
"# Heading 2\n",
"## Heading 2.1\n",
"## Heading 2.2\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Embedded code"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can embed code meant for illustration instead of execution in Python:\n",
"\n",
" def f(x):\n",
" \"\"\"a docstring\"\"\"\n",
" return x**2\n",
"\n",
"or other languages:\n",
"\n",
" for (i=0; i<n; i++) {\n",
" printf(\"hello %d\\n\", i);\n",
" x += 4;\n",
" }"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## LaTeX equations"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Courtesy of MathJax, you can include mathematical expressions both inline: \n",
"$e^{i\\pi} + 1 = 0$ and displayed:\n",
"\n",
"\\begin{equation}\n",
"e^x=\\sum_{i=0}^\\infty \\frac{1}{i!}x^i\n",
"\\end{equation}\n",
"\n",
"Inline expressions can be added by surrounding the latex code with `$`:\n",
"\n",
"```\n",
"$e^{i\\pi} + 1 = 0$\n",
"```\n",
"\n",
"Expressions on their own line are surrounded by `\\begin{equation}` and `\\end{equation}`:\n",
"\n",
"```latex\n",
"\\begin{equation}\n",
"e^x=\\sum_{i=0}^\\infty \\frac{1}{i!}x^i\n",
"\\end{equation}\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## GitHub flavored markdown"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The Notebook webapp supports Github flavored markdown meaning that you can use triple backticks for code blocks:\n",
"\n",
" ```python\n",
" print \"Hello World\"\n",
" ```\n",
"\n",
" ```javascript\n",
" console.log(\"Hello World\")\n",
" ```\n",
"\n",
"Gives:\n",
"\n",
"```python\n",
"print \"Hello World\"\n",
"```\n",
"\n",
"```javascript\n",
"console.log(\"Hello World\")\n",
"```\n",
"\n",
"And a table like this: \n",
"\n",
" | This | is |\n",
" |------|------|\n",
" | a | table| \n",
"\n",
"A nice HTML Table:\n",
"\n",
"| This | is |\n",
"|------|------|\n",
"| a | table| \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## General HTML"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Because Markdown is a superset of HTML you can even add things like HTML tables:\n",
"\n",
"<table>\n",
"<tr>\n",
"<th>Header 1</th>\n",
"<th>Header 2</th>\n",
"</tr>\n",
"<tr>\n",
"<td>row 1, cell 1</td>\n",
"<td>row 1, cell 2</td>\n",
"</tr>\n",
"<tr>\n",
"<td>row 2, cell 1</td>\n",
"<td>row 2, cell 2</td>\n",
"</tr>\n",
"</table>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Local files"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you have local files in your Notebook directory, you can refer to these files in Markdown cells directly:\n",
"\n",
" [subdirectory/]<filename>\n",
"\n",
"For example, in the images folder, we have the Python logo:\n",
"\n",
" <img src=\"../images/python_logo.svg\" />\n",
"\n",
"<img src=\"../images/python_logo.svg\" />\n",
"\n",
"and a video with the HTML5 video tag:\n",
"\n",
" <video controls src=\"../images/animation.m4v\">animation</video>\n",
"\n",
"<video controls src=\"../images/animation.m4v\">animation</video>\n",
"\n",
"These do not embed the data into the notebook file, and require that the files exist when you are viewing the notebook."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Security of local files"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that this means that the Jupyter notebook server also acts as a generic file server\n",
"for files inside the same tree as your notebooks. Access is not granted outside the\n",
"notebook folder so you have strict control over what files are visible, but for this\n",
"reason it is highly recommended that you do not run the notebook server with a notebook\n",
"directory at a high level in your filesystem (e.g. your home directory).\n",
"\n",
"When you run the notebook in a password-protected manner, local file access is restricted\n",
"to authenticated users unless read-only views are active."
]
},
{
"attachments": {
"pycon-logo.jpg": {
"image/jpeg": "/9j/4AAQSkZJRgABAQAAAQABAAD/4gKgSUNDX1BST0ZJTEUAAQEAAAKQbGNtcwQwAABtbnRyUkdCIFhZWiAH4AAJABUADgApADhhY3NwQVBQTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtkZXNjAAABCAAAADhjcHJ0AAABQAAAAE53dHB0AAABkAAAABRjaGFkAAABpAAAACxyWFlaAAAB0AAAABRiWFlaAAAB5AAAABRnWFlaAAAB+AAAABRyVFJDAAACDAAAACBnVFJDAAACLAAAACBiVFJDAAACTAAAACBjaHJtAAACbAAAACRtbHVjAAAAAAAAAAEAAAAMZW5VUwAAABwAAAAcAHMAUgBHAEIAIABiAHUAaQBsAHQALQBpAG4AAG1sdWMAAAAAAAAAAQAAAAxlblVTAAAAMgAAABwATgBvACAAYwBvAHAAeQByAGkAZwBoAHQALAAgAHUAcwBlACAAZgByAGUAZQBsAHkAAAAAWFlaIAAAAAAAAPbWAAEAAAAA0y1zZjMyAAAAAAABDEoAAAXj///zKgAAB5sAAP2H///7ov///aMAAAPYAADAlFhZWiAAAAAAAABvlAAAOO4AAAOQWFlaIAAAAAAAACSdAAAPgwAAtr5YWVogAAAAAAAAYqUAALeQAAAY3nBhcmEAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH//EADIQAAEEAgAEBAUDBAMBAAAAAAQBAgM
}
},
"cell_type": "markdown",
"metadata": {},
"source": [
"### Markdown attachments\n",
"\n",
"Since Jupyter notebook version 5.0, in addition to referencing external file you can attach a file to a markdown cell. \n",
"To do so drag the file from in a markdown cell while editing it:\n",
"\n",
"![pycon-logo.jpg](attachment:pycon-logo.jpg)\n",
"\n",
"Files are stored in cell metadata and will be automatically scrubbed at save-time if not referenced. You can recognized attached images from other files by their url that starts with `attachment:`. For the image above:\n",
"\n",
" ![pycon-logo.jpg](attachment:pycon-logo.jpg)\n",
" \n",
"Keep in mind that attached files will increase the size of your notebook. \n",
"\n",
"You can manually edit the attachment by using the `View > Cell Toolbar > Attachment` menu, but you should not need to. "
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 1
}