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