|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Markdown Cells" |
| 8 | + ] |
| 9 | + }, |
| 10 | + { |
| 11 | + "cell_type": "markdown", |
| 12 | + "metadata": {}, |
| 13 | + "source": [ |
| 14 | + "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", |
| 15 | + "\n", |
| 16 | + "<http://daringfireball.net/projects/markdown/>" |
| 17 | + ] |
| 18 | + }, |
| 19 | + { |
| 20 | + "cell_type": "markdown", |
| 21 | + "metadata": {}, |
| 22 | + "source": [ |
| 23 | + "## Markdown basics" |
| 24 | + ] |
| 25 | + }, |
| 26 | + { |
| 27 | + "cell_type": "markdown", |
| 28 | + "metadata": {}, |
| 29 | + "source": [ |
| 30 | + "You can make text *italic* or **bold**." |
| 31 | + ] |
| 32 | + }, |
| 33 | + { |
| 34 | + "cell_type": "markdown", |
| 35 | + "metadata": {}, |
| 36 | + "source": [ |
| 37 | + "You can build nested itemized or enumerated lists:\n", |
| 38 | + "\n", |
| 39 | + "* One\n", |
| 40 | + " - Sublist\n", |
| 41 | + " - This\n", |
| 42 | + " - Sublist\n", |
| 43 | + " - That\n", |
| 44 | + " - The other thing\n", |
| 45 | + "* Two\n", |
| 46 | + " - Sublist\n", |
| 47 | + "* Three\n", |
| 48 | + " - Sublist\n", |
| 49 | + "\n", |
| 50 | + "Now another list:\n", |
| 51 | + "\n", |
| 52 | + "1. Here we go\n", |
| 53 | + " 1. Sublist\n", |
| 54 | + " 2. Sublist\n", |
| 55 | + "2. There we go\n", |
| 56 | + "3. Now this" |
| 57 | + ] |
| 58 | + }, |
| 59 | + { |
| 60 | + "cell_type": "markdown", |
| 61 | + "metadata": {}, |
| 62 | + "source": [ |
| 63 | + "You can add horizontal rules:\n", |
| 64 | + "\n", |
| 65 | + "---" |
| 66 | + ] |
| 67 | + }, |
| 68 | + { |
| 69 | + "cell_type": "markdown", |
| 70 | + "metadata": {}, |
| 71 | + "source": [ |
| 72 | + "Here is a blockquote:\n", |
| 73 | + "\n", |
| 74 | + "> Beautiful is better than ugly.\n", |
| 75 | + "> Explicit is better than implicit.\n", |
| 76 | + "> Simple is better than complex.\n", |
| 77 | + "> Complex is better than complicated.\n", |
| 78 | + "> Flat is better than nested.\n", |
| 79 | + "> Sparse is better than dense.\n", |
| 80 | + "> Readability counts.\n", |
| 81 | + "> Special cases aren't special enough to break the rules.\n", |
| 82 | + "> Although practicality beats purity.\n", |
| 83 | + "> Errors should never pass silently.\n", |
| 84 | + "> Unless explicitly silenced.\n", |
| 85 | + "> In the face of ambiguity, refuse the temptation to guess.\n", |
| 86 | + "> There should be one-- and preferably only one --obvious way to do it.\n", |
| 87 | + "> Although that way may not be obvious at first unless you're Dutch.\n", |
| 88 | + "> Now is better than never.\n", |
| 89 | + "> Although never is often better than *right* now.\n", |
| 90 | + "> If the implementation is hard to explain, it's a bad idea.\n", |
| 91 | + "> If the implementation is easy to explain, it may be a good idea.\n", |
| 92 | + "> Namespaces are one honking great idea -- let's do more of those!" |
| 93 | + ] |
| 94 | + }, |
| 95 | + { |
| 96 | + "cell_type": "markdown", |
| 97 | + "metadata": {}, |
| 98 | + "source": [ |
| 99 | + "And shorthand for links:\n", |
| 100 | + "\n", |
| 101 | + "[IPython's website](http://ipython.org)" |
| 102 | + ] |
| 103 | + }, |
| 104 | + { |
| 105 | + "cell_type": "markdown", |
| 106 | + "metadata": {}, |
| 107 | + "source": [ |
| 108 | + "## Headings" |
| 109 | + ] |
| 110 | + }, |
| 111 | + { |
| 112 | + "cell_type": "markdown", |
| 113 | + "metadata": {}, |
| 114 | + "source": [ |
| 115 | + "If you want, you can add headings using Markdown's syntax:\n", |
| 116 | + "\n", |
| 117 | + "# Heading 1\n", |
| 118 | + "# Heading 2\n", |
| 119 | + "## Heading 2.1\n", |
| 120 | + "## Heading 2.2\n", |
| 121 | + "#### Nagłówek" |
| 122 | + ] |
| 123 | + }, |
| 124 | + { |
| 125 | + "cell_type": "markdown", |
| 126 | + "metadata": {}, |
| 127 | + "source": [ |
| 128 | + "**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." |
| 129 | + ] |
| 130 | + }, |
| 131 | + { |
| 132 | + "cell_type": "markdown", |
| 133 | + "metadata": {}, |
| 134 | + "source": [ |
| 135 | + "## Embedded code" |
| 136 | + ] |
| 137 | + }, |
| 138 | + { |
| 139 | + "cell_type": "markdown", |
| 140 | + "metadata": {}, |
| 141 | + "source": [ |
| 142 | + "You can embed code meant for illustration instead of execution in Python:\n", |
| 143 | + "\n", |
| 144 | + " def f(x):\n", |
| 145 | + " \"\"\"a docstring\"\"\"\n", |
| 146 | + " return x**2\n", |
| 147 | + "\n", |
| 148 | + "or other languages:\n", |
| 149 | + "\n", |
| 150 | + " if (i=0; i<n; i++) {\n", |
| 151 | + " printf(\"hello %d\\n\", i);\n", |
| 152 | + " x += 4;\n", |
| 153 | + " }" |
| 154 | + ] |
| 155 | + }, |
| 156 | + { |
| 157 | + "cell_type": "markdown", |
| 158 | + "metadata": {}, |
| 159 | + "source": [ |
| 160 | + "## LaTeX equations" |
| 161 | + ] |
| 162 | + }, |
| 163 | + { |
| 164 | + "cell_type": "markdown", |
| 165 | + "metadata": {}, |
| 166 | + "source": [ |
| 167 | + "Courtesy of MathJax, you can include mathematical expressions both inline: \n", |
| 168 | + "$e^{i\\pi} + 1 = 0$ and displayed:\n", |
| 169 | + "\n", |
| 170 | + "$$e^x=\\sum_{i=0}^\\infty \\frac{1}{i!}x^i$$" |
| 171 | + ] |
| 172 | + }, |
| 173 | + { |
| 174 | + "cell_type": "markdown", |
| 175 | + "metadata": {}, |
| 176 | + "source": [ |
| 177 | + "## General HTML" |
| 178 | + ] |
| 179 | + }, |
| 180 | + { |
| 181 | + "cell_type": "markdown", |
| 182 | + "metadata": {}, |
| 183 | + "source": [ |
| 184 | + "Because Markdown is a superset of HTML you can even add things like HTML tables:\n", |
| 185 | + "\n", |
| 186 | + "<table>\n", |
| 187 | + "<tr>\n", |
| 188 | + "<th>Header 1</th>\n", |
| 189 | + "<th>Header 2</th>\n", |
| 190 | + "</tr>\n", |
| 191 | + "<tr>\n", |
| 192 | + "<td>row 1, cell 1</td>\n", |
| 193 | + "<td>row 1, cell 2</td>\n", |
| 194 | + "</tr>\n", |
| 195 | + "<tr>\n", |
| 196 | + "<td>row 2, cell 1</td>\n", |
| 197 | + "<td>row 2, cell 2</td>\n", |
| 198 | + "</tr>\n", |
| 199 | + "</table>" |
| 200 | + ] |
| 201 | + }, |
| 202 | + { |
| 203 | + "cell_type": "markdown", |
| 204 | + "metadata": {}, |
| 205 | + "source": [ |
| 206 | + "## Local files" |
| 207 | + ] |
| 208 | + }, |
| 209 | + { |
| 210 | + "cell_type": "markdown", |
| 211 | + "metadata": {}, |
| 212 | + "source": [ |
| 213 | + "If you have local files in your Notebook directory, you can refer to these files in Markdown cells via relative URLs that are prefixed with `files/`:\n", |
| 214 | + "\n", |
| 215 | + " files/[subdirectory/]<filename>\n", |
| 216 | + "\n", |
| 217 | + "For example, in the example Notebook folder, we have the Python logo:\n", |
| 218 | + "\n", |
| 219 | + " <img src=\"files/python-logo.svg\" />\n", |
| 220 | + "\n", |
| 221 | + "<img src=\"files/python-logo.svg\" />\n", |
| 222 | + "\n", |
| 223 | + "and a video with the HTML5 video tag:\n", |
| 224 | + "\n", |
| 225 | + " <video controls src=\"files/animation.m4v\" />\n", |
| 226 | + "\n", |
| 227 | + "<video controls src=\"files/animation.m4v\" />\n", |
| 228 | + "\n", |
| 229 | + "These do not embed the data into the notebook file, and require that the files exist when you are viewing the notebook." |
| 230 | + ] |
| 231 | + }, |
| 232 | + { |
| 233 | + "cell_type": "markdown", |
| 234 | + "metadata": {}, |
| 235 | + "source": [ |
| 236 | + "### Security of local files" |
| 237 | + ] |
| 238 | + }, |
| 239 | + { |
| 240 | + "cell_type": "markdown", |
| 241 | + "metadata": {}, |
| 242 | + "source": [ |
| 243 | + "Note that this means that the IPython notebook server also acts as a generic file server\n", |
| 244 | + "for files inside the same tree as your notebooks. Access is not granted outside the\n", |
| 245 | + "notebook folder so you have strict control over what files are visible, but for this\n", |
| 246 | + "reason it is highly recommended that you do not run the notebook server with a notebook\n", |
| 247 | + "directory at a high level in your filesystem (e.g. your home directory).\n", |
| 248 | + "\n", |
| 249 | + "When you run the notebook in a password-protected manner, local file access is restricted\n", |
| 250 | + "to authenticated users unless read-only views are active." |
| 251 | + ] |
| 252 | + } |
| 253 | + ], |
| 254 | + "metadata": { |
| 255 | + "kernelspec": { |
| 256 | + "display_name": "Python 3", |
| 257 | + "language": "python", |
| 258 | + "name": "python3" |
| 259 | + }, |
| 260 | + "language_info": { |
| 261 | + "codemirror_mode": { |
| 262 | + "name": "ipython", |
| 263 | + "version": 3 |
| 264 | + }, |
| 265 | + "file_extension": ".py", |
| 266 | + "mimetype": "text/x-python", |
| 267 | + "name": "python", |
| 268 | + "nbconvert_exporter": "python", |
| 269 | + "pygments_lexer": "ipython3", |
| 270 | + "version": "3.6.1" |
| 271 | + } |
| 272 | + }, |
| 273 | + "nbformat": 4, |
| 274 | + "nbformat_minor": 1 |
| 275 | +} |
0 commit comments