Markdown Cells.ipynb
271 lines
| 7.0 KiB
| text/plain
|
TextLexer
Brian Granger
|
r9191 | { | |
"metadata": { | |||
Brian E. Granger
|
r16108 | "name": "", | |
"signature": "sha256:056f083d2453c83c77ea0a659e9185084426263c9e42b4c0ccbb91c773d9503b" | |||
Brian Granger
|
r9191 | }, | |
"nbformat": 3, | |||
"nbformat_minor": 0, | |||
"worksheets": [ | |||
{ | |||
"cells": [ | |||
{ | |||
"cell_type": "heading", | |||
"level": 1, | |||
"metadata": {}, | |||
"source": [ | |||
"Markdown Cells" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
"Text can be added to IPython Notebooks using Markdown cells. Markdown is a popular markup language that is a superset of HTML. Its specification can be found here:\n", | |||
"\n", | |||
"<http://daringfireball.net/projects/markdown/>" | |||
] | |||
}, | |||
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
"metadata": {}, | |||
"source": [ | |||
"Markdown basics" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
"You can make text *italic* or **bold**." | |||
] | |||
}, | |||
{ | |||
"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", | |||
"[IPython's website](http://ipython.org)" | |||
] | |||
}, | |||
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
"metadata": {}, | |||
"source": [ | |||
"Headings" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
"If you want, you can add headings using Markdown's syntax:\n", | |||
"\n", | |||
"# Heading 1\n", | |||
"# Heading 2\n", | |||
"## Heading 2.1\n", | |||
"## Heading 2.2" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
"**BUT most of the time you should use the Notebook's Heading Cells to organize your Notebook content**, as they provide meaningful structure that can be interpreted by other tools, not just large bold fonts." | |||
] | |||
}, | |||
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
"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", | |||
" if (i=0; i<n; i++) {\n", | |||
" printf(\"hello %d\\n\", i);\n", | |||
" x += 4;\n", | |||
" }" | |||
] | |||
}, | |||
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
"metadata": {}, | |||
"source": [ | |||
Brian Granger
|
r9193 | "LaTeX equations" | |
Brian Granger
|
r9191 | ] | |
}, | |||
{ | |||
"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", | |||
"$$e^x=\\sum_{i=0}^\\infty \\frac{1}{i!}x^i$$" | |||
] | |||
}, | |||
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
"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>" | |||
] | |||
Brian Granger
|
r9193 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
"metadata": {}, | |||
"source": [ | |||
"Local files" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
Brian E. Granger
|
r16108 | "If you have local files in your Notebook directory, you can refer to these files in Markdown cells directly:\n", | |
Brian Granger
|
r9193 | "\n", | |
Brian E. Granger
|
r16108 | " [subdirectory/]<filename>\n", | |
Brian Granger
|
r9193 | "\n", | |
Brian E. Granger
|
r16108 | "For example, in the images folder, we have the Python logo:\n", | |
Brian Granger
|
r9193 | "\n", | |
Brian E. Granger
|
r16108 | " <img src=\"images/python-logo.svg\" />\n", | |
Brian Granger
|
r9193 | "\n", | |
Brian E. Granger
|
r16108 | "<img src=\"images/python-logo.svg\" />\n", | |
Brian Granger
|
r9193 | "\n", | |
"and a video with the HTML5 video tag:\n", | |||
"\n", | |||
Brian E. Granger
|
r16108 | " <video controls src=\"images/animation.m4v\" />\n", | |
Brian Granger
|
r9193 | "\n", | |
Brian E. Granger
|
r16108 | "<video controls src=\"images/animation.m4v\" />\n", | |
Brian Granger
|
r9193 | "\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": "heading", | |||
"level": 3, | |||
"metadata": {}, | |||
"source": [ | |||
"Security of local files" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
"Note that this means that the IPython 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." | |||
] | |||
Brian Granger
|
r9191 | } | |
], | |||
"metadata": {} | |||
} | |||
] | |||
} |