File: Working%20With%20Markdown%20Cells.rst

package info (click to toggle)
jupyter-notebook 4.2.3-4~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 7,804 kB
  • sloc: python: 8,698; makefile: 240; sh: 74
file content (313 lines) | stat: -rw-r--r-- 5,390 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313

`View the original notebook on nbviewer <http://nbviewer.jupyter.org/github/jupyter/notebook/blob/master/docs/source/examples/Notebook/Working%20With%20Markdown%20Cells.ipynb>`__

Markdown Cells
==============

Text can be added to Jupyter Notebooks using Markdown cells. Markdown is
a popular markup language that is a superset of HTML. Its specification
can be found here:

http://daringfireball.net/projects/markdown/

Markdown basics
---------------

You can make text *italic* or **bold**.

You can build nested itemized or enumerated lists:

-  One

   -  Sublist

      -  This

-  Sublist - That - The other thing
-  Two
-  Sublist
-  Three
-  Sublist

Now another list:

1. Here we go

   1. Sublist
   2. Sublist

2. There we go
3. Now this

You can add horizontal rules:

--------------

Here is a blockquote:

    Beautiful is better than ugly. Explicit is better than implicit.
    Simple is better than complex. Complex is better than complicated.
    Flat is better than nested. Sparse is better than dense. Readability
    counts. Special cases aren't special enough to break the rules.
    Although practicality beats purity. Errors should never pass
    silently. Unless explicitly silenced. In the face of ambiguity,
    refuse the temptation to guess. There should be one-- and preferably
    only one --obvious way to do it. Although that way may not be
    obvious at first unless you're Dutch. Now is better than never.
    Although never is often better than *right* now. If the
    implementation is hard to explain, it's a bad idea. If the
    implementation is easy to explain, it may be a good idea. Namespaces
    are one honking great idea -- let's do more of those!

And shorthand for links:

`Jupyter's website <http://jupyter.org>`__

Headings
--------

You can add headings by starting a line with one (or multiple) ``#``
followed by a space, as in the following example:

Heading 1
=========

Heading 2
=========

Heading 2.1
-----------

Heading 2.2
-----------

Embedded code
-------------

You can embed code meant for illustration instead of execution in
Python:

::

    def f(x):
        """a docstring"""
        return x**2

or other languages:

::

    if (i=0; i<n; i++) {
      printf("hello %d\n", i);
      x += 4;
    }

LaTeX equations
---------------

Courtesy of MathJax, you can include mathematical expressions both
inline: :math:`e^{i\pi} + 1 = 0` and displayed:

.. math:: e^x=\sum_{i=0}^\infty \frac{1}{i!}x^i

Inline expressions can be added by surrounding the latex code with
``$``:

::

    $e^{i\pi} + 1 = 0$

Expressions on their own line are surrounded by ``$$``:

.. code:: latex

    $$e^x=\sum_{i=0}^\infty \frac{1}{i!}x^i$$

Github flavored markdown (GFM)
------------------------------

The Notebook webapp support Github flavored markdown meaning that you
can use triple backticks for code blocks

.. raw:: html

   <pre>
   ```python
   print "Hello World"
   ```

   ```javascript
   console.log("Hello World")
   ```
   </pre>

Gives

.. code:: python

    print "Hello World"

.. code:: javascript

    console.log("Hello World")

And a table like this :

.. raw:: html

   <pre>
   | This | is   |
   |------|------|
   |   a  | table| 
   </pre>

A nice Html Table

+--------+---------+
| This   | is      |
+========+=========+
| a      | table   |
+--------+---------+

General HTML
------------

Because Markdown is a superset of HTML you can even add things like HTML
tables:

.. raw:: html

   <table>

.. raw:: html

   <tr>

.. raw:: html

   <th>

Header 1

.. raw:: html

   </th>

.. raw:: html

   <th>

Header 2

.. raw:: html

   </th>

.. raw:: html

   </tr>

.. raw:: html

   <tr>

.. raw:: html

   <td>

row 1, cell 1

.. raw:: html

   </td>

.. raw:: html

   <td>

row 1, cell 2

.. raw:: html

   </td>

.. raw:: html

   </tr>

.. raw:: html

   <tr>

.. raw:: html

   <td>

row 2, cell 1

.. raw:: html

   </td>

.. raw:: html

   <td>

row 2, cell 2

.. raw:: html

   </td>

.. raw:: html

   </tr>

.. raw:: html

   </table>

Local files
-----------

If you have local files in your Notebook directory, you can refer to
these files in Markdown cells directly:

::

    [subdirectory/]<filename>

For example, in the images folder, we have the Python logo:

::

    <img src="../images/python_logo.svg" />

and a video with the HTML5 video tag:

::

    <video controls src="images/animation.m4v" />

.. raw:: html

   <video controls src="images/animation.m4v" />

These do not embed the data into the notebook file, and require that the
files exist when you are viewing the notebook.

Security of local files
~~~~~~~~~~~~~~~~~~~~~~~

Note that this means that the Jupyter notebook server also acts as a
generic file server for files inside the same tree as your notebooks.
Access is not granted outside the notebook folder so you have strict
control over what files are visible, but for this reason it is highly
recommended that you do not run the notebook server with a notebook
directory at a high level in your filesystem (e.g. your home directory).

When you run the notebook in a password-protected manner, local file
access is restricted to authenticated users unless read-only views are
active.

`View the original notebook on nbviewer <http://nbviewer.jupyter.org/github/jupyter/notebook/blob/master/docs/source/examples/Notebook/Working%20With%20Markdown%20Cells.ipynb>`__