##// END OF EJS Templates
A LOT OF CLEANUP IN examples/Notebook
Jonathan Frederic -
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -1,379 +1,295 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "# Running the Notebook Server"
7 "# Configuring the Notebook and Server"
8 ]
9 },
10 {
11 "cell_type": "markdown",
12 "metadata": {},
13 "source": [
14 "The IPython notebook server is a custom web server that runs the notebook web application. Most of the time, users run the notebook server on their local computer using IPython's command line interface."
15 ]
16 },
17 {
18 "cell_type": "markdown",
19 "metadata": {},
20 "source": [
21 "## Starting the notebook server using the command line"
22 ]
23 },
24 {
25 "cell_type": "markdown",
26 "metadata": {},
27 "source": [
28 "You can start the notebook server from the command line (Terminal on Mac/Linux, CMD prompt on Windows) by running the following command: \n",
29 "\n",
30 " ipython notebook\n",
31 "\n",
32 "This will print some information about the notebook server in your terminal, including the URL of the web application (by default, `http://127.0.0.1:8888`). It will then open your default web browser to this URL.\n",
33 "\n",
34 "When the notebook opens, you will see the **notebook dashboard**, which will show a list of the notebooks and subdirectories in the directory where the notebook server was started. As of IPython 2.0, the dashboard allows you to navigate to different subdirectories. Because of this, it is no longer necessary to start a separate notebook server for each subdirectory. Most of the time, you will want to start a notebook server in the highest directory in your filesystem where notebooks can be found. Often this will be your home directory.\n",
35 "\n",
36 "You can start more than one notebook server at the same time. By default, the first notebook server starts on port 8888 and later notebook servers search for open ports near that one.\n",
37 "\n",
38 "You can also specify the port manually:\n",
39 "\n",
40 " ipython notebook --port 9999\n",
41 "\n",
42 "Or start notebook server without opening a web browser.\n",
43 "\n",
44 " ipython notebook --no-browser\n",
45 "\n",
46 "The notebook server has a number of other command line arguments that can be displayed with the `--help` flag: \n",
47 "\n",
48 " ipython notebook --help\n",
49 "\n",
50 "<div class=\"alert alert-failure\">\n",
51 "It used to be possible to specify kernel options, such as <code>--pylab inline</code> from the command line. This is deprecated in IPython 2.0 and will be removed in IPython 3.0. To enable matplotlib based plotting for the Python kernel use the <code>%matplotlib</code> magic command.\n",
52 "</div>\n",
53 "\n"
54 ]
8 ]
55 },
9 },
56 {
10 {
57 "cell_type": "markdown",
11 "cell_type": "markdown",
58 "metadata": {},
12 "metadata": {},
59 "source": [
13 "source": [
60 "## Configuring the IPython Notebook"
14 "## Configuring the IPython Notebook"
61 ]
15 ]
62 },
16 },
63 {
17 {
64 "cell_type": "markdown",
18 "cell_type": "markdown",
65 "metadata": {},
19 "metadata": {},
66 "source": [
20 "source": [
67 "The notebook web server can also be configured using IPython profiles and configuration files. The Notebook web server configuration options are set in a file named `ipython_notebook_config.py` in your IPython *profile directory*. The profile directory is a subfolder of your IPython directory, which itself is usually `.ipython` in your home directory.\n",
21 "The notebook web server can also be configured using IPython profiles and configuration files. The Notebook web server configuration options are set in a file named `ipython_notebook_config.py` in your IPython *profile directory*. The profile directory is a subfolder of your IPython directory, which itself is usually `.ipython` in your home directory.\n",
68 "\n",
22 "\n",
69 "You can display the location of your default profile directory by running the command:"
23 "You can display the location of your default profile directory by running the command:"
70 ]
24 ]
71 },
25 },
72 {
26 {
73 "cell_type": "code",
27 "cell_type": "code",
74 "execution_count": 7,
28 "execution_count": null,
75 "metadata": {
29 "metadata": {
76 "collapsed": false
30 "collapsed": false
77 },
31 },
78 "outputs": [
32 "outputs": [],
79 {
80 "name": "stdout",
81 "output_type": "stream",
82 "text": [
83 "/Users/bgranger/.ipython/profile_default\r\n"
84 ]
85 }
86 ],
87 "source": [
33 "source": [
88 "!ipython profile locate default"
34 "!ipython profile locate default"
89 ]
35 ]
90 },
36 },
91 {
37 {
92 "cell_type": "markdown",
38 "cell_type": "markdown",
93 "metadata": {},
39 "metadata": {},
94 "source": [
40 "source": [
95 "The default version of `ipython_notebook_config.py` lists all of the options available along with documentation for each. Changes made to that file will affect all notebook servers run under that profile. Command line options always override those set in configuration files.\n",
41 "The default version of `ipython_notebook_config.py` lists all of the options available along with documentation for each. Changes made to that file will affect all notebook servers run under that profile. Command line options always override those set in configuration files.\n",
96 "\n",
42 "\n",
97 "You can create a new profile:"
43 "You can create a new profile:"
98 ]
44 ]
99 },
45 },
100 {
46 {
101 "cell_type": "code",
47 "cell_type": "code",
102 "execution_count": 3,
48 "execution_count": null,
103 "metadata": {
49 "metadata": {
104 "collapsed": false
50 "collapsed": false
105 },
51 },
106 "outputs": [
52 "outputs": [],
107 {
108 "name": "stdout",
109 "output_type": "stream",
110 "text": [
111 "[ProfileCreate] Generating default config file: u'/Users/bgranger/.ipython/profile_my_profile/ipython_config.py'\r\n",
112 "[ProfileCreate] Generating default config file: u'/Users/bgranger/.ipython/profile_my_profile/ipython_qtconsole_config.py'\r\n",
113 "[ProfileCreate] Generating default config file: u'/Users/bgranger/.ipython/profile_my_profile/ipython_notebook_config.py'\r\n",
114 "[ProfileCreate] Generating default config file: u'/Users/bgranger/.ipython/profile_my_profile/ipython_nbconvert_config.py'\r\n"
115 ]
116 }
117 ],
118 "source": [
53 "source": [
119 "!ipython profile create my_profile"
54 "!ipython profile create my_profile"
120 ]
55 ]
121 },
56 },
122 {
57 {
123 "cell_type": "markdown",
58 "cell_type": "markdown",
124 "metadata": {},
59 "metadata": {},
125 "source": [
60 "source": [
126 "And then view its location:"
61 "And then view its location:"
127 ]
62 ]
128 },
63 },
129 {
64 {
130 "cell_type": "code",
65 "cell_type": "code",
131 "execution_count": 5,
66 "execution_count": null,
132 "metadata": {
67 "metadata": {
133 "collapsed": false
68 "collapsed": false
134 },
69 },
135 "outputs": [
70 "outputs": [],
136 {
137 "name": "stdout",
138 "output_type": "stream",
139 "text": [
140 "/Users/bgranger/.ipython/profile_my_profile\r\n"
141 ]
142 }
143 ],
144 "source": [
71 "source": [
145 "!ipython profile locate my_profile"
72 "!ipython profile locate my_profile"
146 ]
73 ]
147 },
74 },
148 {
75 {
149 "cell_type": "markdown",
76 "cell_type": "markdown",
150 "metadata": {},
77 "metadata": {},
151 "source": [
78 "source": [
152 "To start the notebook server using a given profile, run the following:\n",
79 "To start the notebook server using a given profile, run the following:\n",
153 "\n",
80 "\n",
154 " ipython notebook --profile=my_profile"
81 " ipython notebook --profile=my_profile"
155 ]
82 ]
156 },
83 },
157 {
84 {
158 "cell_type": "markdown",
85 "cell_type": "markdown",
159 "metadata": {},
86 "metadata": {},
160 "source": [
87 "source": [
161 "More details about IPython configuration files and profiles can be found [here](http://ipython.org/ipython-doc/dev/config/intro.html)."
88 "More details about IPython configuration files and profiles can be found [here](http://ipython.org/ipython-doc/dev/config/intro.html)."
162 ]
89 ]
163 },
90 },
164 {
91 {
165 "cell_type": "markdown",
92 "cell_type": "markdown",
166 "metadata": {},
93 "metadata": {},
167 "source": [
94 "source": [
168 "## Securing the notebook server"
95 "## Securing the notebook server"
169 ]
96 ]
170 },
97 },
171 {
98 {
172 "cell_type": "markdown",
99 "cell_type": "markdown",
173 "metadata": {},
100 "metadata": {},
174 "source": [
101 "source": [
175 "The IPython Notebook allows arbitrary code execution on the computer running it. Thus, the notebook web server should never be run on the open internet without first securing it. By default, the notebook server only listens on local network interface (`127.0.0.1`) There are two steps required to secure the notebook server:\n",
102 "The IPython Notebook allows arbitrary code execution on the computer running it. Thus, the notebook web server should never be run on the open internet without first securing it. By default, the notebook server only listens on local network interface (`127.0.0.1`) There are two steps required to secure the notebook server:\n",
176 "\n",
103 "\n",
177 "1. Setting a password\n",
104 "1. Setting a password\n",
178 "2. Encrypt network traffic using SSL"
105 "2. Encrypt network traffic using SSL"
179 ]
106 ]
180 },
107 },
181 {
108 {
182 "cell_type": "markdown",
109 "cell_type": "markdown",
183 "metadata": {},
110 "metadata": {},
184 "source": [
111 "source": [
185 "### Setting a password"
112 "### Setting a password"
186 ]
113 ]
187 },
114 },
188 {
115 {
189 "cell_type": "markdown",
116 "cell_type": "markdown",
190 "metadata": {},
117 "metadata": {},
191 "source": [
118 "source": [
192 "You can protect your notebook server with a simple single password by setting the `NotebookApp.password` configurable. You can prepare a hashed password using the function `IPython.lib.passwd`:"
119 "You can protect your notebook server with a simple single password by setting the `NotebookApp.password` configurable. You can prepare a hashed password using the function `IPython.lib.passwd`:"
193 ]
120 ]
194 },
121 },
195 {
122 {
196 "cell_type": "code",
123 "cell_type": "code",
197 "execution_count": 1,
124 "execution_count": null,
198 "metadata": {
125 "metadata": {
199 "collapsed": false
126 "collapsed": false
200 },
127 },
201 "outputs": [
128 "outputs": [],
202 {
203 "data": {
204 "text/plain": [
205 "'sha1:6c2164fc2b22:ed55ecf07fc0f985ab46561483c0e888e8964ae6'"
206 ]
207 },
208 "execution_count": 1,
209 "metadata": {},
210 "output_type": "execute_result"
211 }
212 ],
213 "source": [
129 "source": [
214 "from IPython.lib import passwd\n",
130 "from IPython.lib import passwd\n",
215 "password = passwd(\"secret\")\n",
131 "password = passwd(\"secret\")\n",
216 "password"
132 "password"
217 ]
133 ]
218 },
134 },
219 {
135 {
220 "cell_type": "markdown",
136 "cell_type": "markdown",
221 "metadata": {},
137 "metadata": {},
222 "source": [
138 "source": [
223 "You can then add this to your `ipython_notebook_config.py`:\n",
139 "You can then add this to your `ipython_notebook_config.py`:\n",
224 "\n",
140 "\n",
225 "```python\n",
141 "```python\n",
226 "# Password to use for web authentication\n",
142 "# Password to use for web authentication\n",
227 "c = get_config()\n",
143 "c = get_config()\n",
228 "c.NotebookApp.password = \n",
144 "c.NotebookApp.password = \n",
229 "u'sha1:6c2164fc2b22:ed55ecf07fc0f985ab46561483c0e888e8964ae6'\n",
145 "u'sha1:6c2164fc2b22:ed55ecf07fc0f985ab46561483c0e888e8964ae6'\n",
230 "```"
146 "```"
231 ]
147 ]
232 },
148 },
233 {
149 {
234 "cell_type": "markdown",
150 "cell_type": "markdown",
235 "metadata": {},
151 "metadata": {},
236 "source": [
152 "source": [
237 "### Using SSL/HTTPS"
153 "### Using SSL/HTTPS"
238 ]
154 ]
239 },
155 },
240 {
156 {
241 "cell_type": "markdown",
157 "cell_type": "markdown",
242 "metadata": {},
158 "metadata": {},
243 "source": [
159 "source": [
244 "When using a password, it is a good idea to also use SSL, so that your \n",
160 "When using a password, it is a good idea to also use SSL, so that your \n",
245 "password is not sent unencrypted by your browser to the web server. When running the notebook on the public internet this is absolutely required.\n",
161 "password is not sent unencrypted by your browser to the web server. When running the notebook on the public internet this is absolutely required.\n",
246 "\n",
162 "\n",
247 "The first step is to generate an SSL certificate. A self-signed certificate can be generated with ``openssl``. For example, the following command will create a certificate valid for 365 days with both the key and certificate data written to the same file:\n",
163 "The first step is to generate an SSL certificate. A self-signed certificate can be generated with ``openssl``. For example, the following command will create a certificate valid for 365 days with both the key and certificate data written to the same file:\n",
248 "\n",
164 "\n",
249 " openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem\n",
165 " openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem\n",
250 "\n",
166 "\n",
251 "In most cases, you should run this command in your profile directory, which will make it easy to use the generated key and certificate.\n",
167 "In most cases, you should run this command in your profile directory, which will make it easy to use the generated key and certificate.\n",
252 "\n",
168 "\n",
253 "When you connect to a notebook server over HTTPS using a self-signed certificate, your browser will warn you of a dangerous certificate because it is self-signed. If you want to have a fully compliant certificate that will not raise warnings, it is possible (but rather involved) to obtain one,\n",
169 "When you connect to a notebook server over HTTPS using a self-signed certificate, your browser will warn you of a dangerous certificate because it is self-signed. If you want to have a fully compliant certificate that will not raise warnings, it is possible (but rather involved) to obtain one,\n",
254 "as explained in detail in [this tutorial](http://arstechnica.com/security/news/2009/12/how-to-get-set-with-a-secure-sertificate-for-free.ars)\n",
170 "as explained in detail in [this tutorial](http://arstechnica.com/security/news/2009/12/how-to-get-set-with-a-secure-sertificate-for-free.ars)\n",
255 "\t\n",
171 "\t\n",
256 "When you enable SSL support, you will need to access the notebook server over ``https://``, rather than plain ``http://``. The startup message from the notebook server prints the correct URL, but it is easy to overlook and think the server is for some reason non-responsive.\n",
172 "When you enable SSL support, you will need to access the notebook server over ``https://``, rather than plain ``http://``. The startup message from the notebook server prints the correct URL, but it is easy to overlook and think the server is for some reason non-responsive.\n",
257 "\n",
173 "\n",
258 "Once you have generated the key and certificate, you can configure the notebook server to use them, by adding the following to `ipython_notebook_config.py`:\n",
174 "Once you have generated the key and certificate, you can configure the notebook server to use them, by adding the following to `ipython_notebook_config.py`:\n",
259 "\n",
175 "\n",
260 "```python\n",
176 "```python\n",
261 "# The full path to an SSL/TLS certificate file.\n",
177 "# The full path to an SSL/TLS certificate file.\n",
262 "c.NotebookApp.certfile = u'/Users/bgranger/.ipython/profile_my_profile/mycert.crt'\n",
178 "c.NotebookApp.certfile = u'/Users/bgranger/.ipython/profile_my_profile/mycert.crt'\n",
263 "\n",
179 "\n",
264 "# The full path to a private key file for usage with SSL/TLS.\n",
180 "# The full path to a private key file for usage with SSL/TLS.\n",
265 "c.NotebookApp.keyfile = u'/Users/bgranger/.ipython/profile_my_profile/mycert.key'\n",
181 "c.NotebookApp.keyfile = u'/Users/bgranger/.ipython/profile_my_profile/mycert.key'\n",
266 "```"
182 "```"
267 ]
183 ]
268 },
184 },
269 {
185 {
270 "cell_type": "markdown",
186 "cell_type": "markdown",
271 "metadata": {},
187 "metadata": {},
272 "source": [
188 "source": [
273 "## Running a public notebook server"
189 "## Running a public notebook server"
274 ]
190 ]
275 },
191 },
276 {
192 {
277 "cell_type": "markdown",
193 "cell_type": "markdown",
278 "metadata": {},
194 "metadata": {},
279 "source": [
195 "source": [
280 "<div class=\"alert alert-error\">\n",
196 "<div class=\"alert alert-error\">\n",
281 "Don't run a public notebook server unless you first secure it with a password and SSL/HTTPS as described above\n",
197 "Don't run a public notebook server unless you first secure it with a password and SSL/HTTPS as described above\n",
282 "</div>\n",
198 "</div>\n",
283 "\n",
199 "\n",
284 "By default the notebook server only listens on the `localhost/127.0.0.1` network interface. If you want to connect to the notebook from another computers, or over the internet, you need to configure the notebook server to listen on all network interfaces and not open the browser. You will often also want to disable the automatic launching of the web browser.\n",
200 "By default the notebook server only listens on the `localhost/127.0.0.1` network interface. If you want to connect to the notebook from another computers, or over the internet, you need to configure the notebook server to listen on all network interfaces and not open the browser. You will often also want to disable the automatic launching of the web browser.\n",
285 "\n",
201 "\n",
286 "This can be accomplished by passing a command line options.\n",
202 "This can be accomplished by passing a command line options.\n",
287 "\n",
203 "\n",
288 " ipython notebook --ip=* --no-browser\n",
204 " ipython notebook --ip=* --no-browser\n",
289 "\n",
205 "\n",
290 "You can also add the following to your`ipython_notebook_config.py` file:\n",
206 "You can also add the following to your`ipython_notebook_config.py` file:\n",
291 "\n",
207 "\n",
292 "```python\n",
208 "```python\n",
293 "c.NotebookApp.ip = '*'\n",
209 "c.NotebookApp.ip = '*'\n",
294 "c.NotebookApp.open_browser = False\n",
210 "c.NotebookApp.open_browser = False\n",
295 "```"
211 "```"
296 ]
212 ]
297 },
213 },
298 {
214 {
299 "cell_type": "markdown",
215 "cell_type": "markdown",
300 "metadata": {},
216 "metadata": {},
301 "source": [
217 "source": [
302 "## Running with a different URL prefix"
218 "## Running with a different URL prefix"
303 ]
219 ]
304 },
220 },
305 {
221 {
306 "cell_type": "markdown",
222 "cell_type": "markdown",
307 "metadata": {},
223 "metadata": {},
308 "source": [
224 "source": [
309 "The notebook dashboard typically lives at the URL `http://localhost:8888/tree`. If you prefer that it lives, together with the \n",
225 "The notebook dashboard typically lives at the URL `http://localhost:8888/tree`. If you prefer that it lives, together with the \n",
310 "rest of the notebook web application, under a base URL prefix, such as `http://localhost:8888/ipython/tree`, you can do so by adding the following lines to your `ipython_notebook_config.py` file.\n",
226 "rest of the notebook web application, under a base URL prefix, such as `http://localhost:8888/ipython/tree`, you can do so by adding the following lines to your `ipython_notebook_config.py` file.\n",
311 "\n",
227 "\n",
312 "```python\n",
228 "```python\n",
313 "c.NotebookApp.base_url = '/ipython/'\n",
229 "c.NotebookApp.base_url = '/ipython/'\n",
314 "c.NotebookApp.webapp_settings = {'static_url_prefix':'/ipython/static/'}\n",
230 "c.NotebookApp.webapp_settings = {'static_url_prefix':'/ipython/static/'}\n",
315 "```"
231 "```"
316 ]
232 ]
317 },
233 },
318 {
234 {
319 "cell_type": "markdown",
235 "cell_type": "markdown",
320 "metadata": {},
236 "metadata": {},
321 "source": [
237 "source": [
322 "## Using a different notebook store"
238 "## Using a different notebook store"
323 ]
239 ]
324 },
240 },
325 {
241 {
326 "cell_type": "markdown",
242 "cell_type": "markdown",
327 "metadata": {},
243 "metadata": {},
328 "source": [
244 "source": [
329 "By default, the notebook server stores the notebook documents that it saves as files in the working directory of the notebook server, also known as the\n",
245 "By default, the notebook server stores the notebook documents that it saves as files in the working directory of the notebook server, also known as the\n",
330 "`notebook_dir`. This logic is implemented in the `FileNotebookManager` class. However, the server can be configured to use a different notebook manager class, which can store the notebooks in a different format. \n",
246 "`notebook_dir`. This logic is implemented in the `FileNotebookManager` class. However, the server can be configured to use a different notebook manager class, which can store the notebooks in a different format. \n",
331 "\n",
247 "\n",
332 "The [bookstore](https://github.com/rgbkrk/bookstore) package currently allows users to store notebooks on Rackspace CloudFiles or OpenStack Swift based object stores.\n",
248 "The [bookstore](https://github.com/rgbkrk/bookstore) package currently allows users to store notebooks on Rackspace CloudFiles or OpenStack Swift based object stores.\n",
333 "\n",
249 "\n",
334 "Writing a notebook manager is as simple as extending the base class `NotebookManager`. The [simple_notebook_manager](https://github.com/khinsen/simple_notebook_manager) provides a great example\n",
250 "Writing a notebook manager is as simple as extending the base class `NotebookManager`. The [simple_notebook_manager](https://github.com/khinsen/simple_notebook_manager) provides a great example\n",
335 "of an in memory notebook manager, created solely for the purpose of\n",
251 "of an in memory notebook manager, created solely for the purpose of\n",
336 "illustrating the notebook manager API."
252 "illustrating the notebook manager API."
337 ]
253 ]
338 },
254 },
339 {
255 {
340 "cell_type": "markdown",
256 "cell_type": "markdown",
341 "metadata": {},
257 "metadata": {},
342 "source": [
258 "source": [
343 "## Known issues"
259 "## Known issues"
344 ]
260 ]
345 },
261 },
346 {
262 {
347 "cell_type": "markdown",
263 "cell_type": "markdown",
348 "metadata": {},
264 "metadata": {},
349 "source": [
265 "source": [
350 "When behind a proxy, especially if your system or browser is set to autodetect the proxy, the notebook web application might fail to connect to the server's websockets, and present you with a warning at startup. In this case, you need to configure your system not to use the proxy for the server's address.\n",
266 "When behind a proxy, especially if your system or browser is set to autodetect the proxy, the notebook web application might fail to connect to the server's websockets, and present you with a warning at startup. In this case, you need to configure your system not to use the proxy for the server's address.\n",
351 "\n",
267 "\n",
352 "For example, in Firefox, go to the Preferences panel, Advanced section,\n",
268 "For example, in Firefox, go to the Preferences panel, Advanced section,\n",
353 "Network tab, click 'Settings...', and add the address of the notebook server\n",
269 "Network tab, click 'Settings...', and add the address of the notebook server\n",
354 "to the 'No proxy for' field."
270 "to the 'No proxy for' field."
355 ]
271 ]
356 }
272 }
357 ],
273 ],
358 "metadata": {
274 "metadata": {
359 "kernelspec": {
275 "kernelspec": {
360 "display_name": "Python 3",
276 "display_name": "Python 3",
361 "language": "python",
277 "language": "python",
362 "name": "python3"
278 "name": "python3"
363 },
279 },
364 "language_info": {
280 "language_info": {
365 "codemirror_mode": {
281 "codemirror_mode": {
366 "name": "ipython",
282 "name": "ipython",
367 "version": 3
283 "version": 3
368 },
284 },
369 "file_extension": ".py",
285 "file_extension": ".py",
370 "mimetype": "text/x-python",
286 "mimetype": "text/x-python",
371 "name": "python",
287 "name": "python",
372 "nbconvert_exporter": "python",
288 "nbconvert_exporter": "python",
373 "pygments_lexer": "ipython3",
289 "pygments_lexer": "ipython3",
374 "version": "3.4.2"
290 "version": "3.4.3"
375 }
291 }
376 },
292 },
377 "nbformat": 4,
293 "nbformat": 4,
378 "nbformat_minor": 0
294 "nbformat_minor": 0
379 }
295 }
@@ -1,155 +1,132 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "# Connecting to an existing IPython kernel using the Qt Console"
7 "# Connecting to an existing IPython kernel using the Qt Console"
8 ]
8 ]
9 },
9 },
10 {
10 {
11 "cell_type": "markdown",
11 "cell_type": "markdown",
12 "metadata": {},
12 "metadata": {},
13 "source": [
13 "source": [
14 "## The Frontend/Kernel Model"
14 "## The Frontend/Kernel Model"
15 ]
15 ]
16 },
16 },
17 {
17 {
18 "cell_type": "markdown",
18 "cell_type": "markdown",
19 "metadata": {},
19 "metadata": {},
20 "source": [
20 "source": [
21 "The traditional IPython (`ipython`) consists of a single process that combines a terminal based UI with the process that runs the users code.\n",
21 "The traditional IPython (`ipython`) consists of a single process that combines a terminal based UI with the process that runs the users code.\n",
22 "\n",
22 "\n",
23 "While this traditional application still exists, the modern IPython consists of two processes:\n",
23 "While this traditional application still exists, the modern IPython consists of two processes:\n",
24 "\n",
24 "\n",
25 "* Kernel: this is the process that runs the users code.\n",
25 "* Kernel: this is the process that runs the users code.\n",
26 "* Frontend: this is the process that provides the user interface where the user types code and sees results.\n",
26 "* Frontend: this is the process that provides the user interface where the user types code and sees results.\n",
27 "\n",
27 "\n",
28 "IPython currently has 3 frontends:\n",
28 "IPython currently has 3 frontends:\n",
29 "\n",
29 "\n",
30 "* Terminal Console (`ipython console`)\n",
30 "* Terminal Console (`ipython console`)\n",
31 "* Qt Console (`ipython qtconsole`)\n",
31 "* Qt Console (`ipython qtconsole`)\n",
32 "* Notebook (`ipython notebook`)\n",
32 "* Notebook (`ipython notebook`)\n",
33 "\n",
33 "\n",
34 "The Kernel and Frontend communicate over a ZeroMQ/JSON based messaging protocol, which allows multiple Frontends (even of different types) to communicate with a single Kernel. This opens the door for all sorts of interesting things, such as connecting a Console or Qt Console to a Notebook's Kernel. For example, you may want to connect a Qt console to your Notebook's Kernel and use it as a help\n",
34 "The Kernel and Frontend communicate over a ZeroMQ/JSON based messaging protocol, which allows multiple Frontends (even of different types) to communicate with a single Kernel. This opens the door for all sorts of interesting things, such as connecting a Console or Qt Console to a Notebook's Kernel. For example, you may want to connect a Qt console to your Notebook's Kernel and use it as a help\n",
35 "browser, calling `??` on objects in the Qt console (whose pager is more flexible than the\n",
35 "browser, calling `??` on objects in the Qt console (whose pager is more flexible than the\n",
36 "one in the notebook). \n",
36 "one in the notebook). \n",
37 "\n",
37 "\n",
38 "This Notebook describes how you would connect another Frontend to a Kernel that is associated with a Notebook."
38 "This Notebook describes how you would connect another Frontend to a Kernel that is associated with a Notebook."
39 ]
39 ]
40 },
40 },
41 {
41 {
42 "cell_type": "markdown",
42 "cell_type": "markdown",
43 "metadata": {},
43 "metadata": {},
44 "source": [
44 "source": [
45 "## Manual connection"
45 "## Manual connection"
46 ]
46 ]
47 },
47 },
48 {
48 {
49 "cell_type": "markdown",
49 "cell_type": "markdown",
50 "metadata": {},
50 "metadata": {},
51 "source": [
51 "source": [
52 "To connect another Frontend to a Kernel manually, you first need to find out the connection information for the Kernel using the `%connect_info` magic:"
52 "To connect another Frontend to a Kernel manually, you first need to find out the connection information for the Kernel using the `%connect_info` magic:"
53 ]
53 ]
54 },
54 },
55 {
55 {
56 "cell_type": "code",
56 "cell_type": "code",
57 "execution_count": 6,
57 "execution_count": null,
58 "metadata": {
58 "metadata": {
59 "collapsed": false
59 "collapsed": false
60 },
60 },
61 "outputs": [
61 "outputs": [],
62 {
63 "name": "stdout",
64 "output_type": "stream",
65 "text": [
66 "{\n",
67 " \"stdin_port\": 52858, \n",
68 " \"ip\": \"127.0.0.1\", \n",
69 " \"hb_port\": 52859, \n",
70 " \"key\": \"7efd45ca-d8a2-41b0-9cea-d9116d0fb883\", \n",
71 " \"shell_port\": 52856, \n",
72 " \"iopub_port\": 52857\n",
73 "}\n",
74 "\n",
75 "Paste the above JSON into a file, and connect with:\n",
76 " $> ipython <app> --existing <file>\n",
77 "or, if you are local, you can connect with just:\n",
78 " $> ipython <app> --existing kernel-b3bac7c1-8b2c-4536-8082-8d1df24f99ac.json \n",
79 "or even just:\n",
80 " $> ipython <app> --existing \n",
81 "if this is the most recent IPython session you have started.\n"
82 ]
83 }
84 ],
85 "source": [
62 "source": [
86 "%connect_info"
63 "%connect_info"
87 ]
64 ]
88 },
65 },
89 {
66 {
90 "cell_type": "markdown",
67 "cell_type": "markdown",
91 "metadata": {},
68 "metadata": {},
92 "source": [
69 "source": [
93 "You can see that this magic displays everything you need to connect to this Notebook's Kernel."
70 "You can see that this magic displays everything you need to connect to this Notebook's Kernel."
94 ]
71 ]
95 },
72 },
96 {
73 {
97 "cell_type": "markdown",
74 "cell_type": "markdown",
98 "metadata": {},
75 "metadata": {},
99 "source": [
76 "source": [
100 "## Automatic connection using a new Qt Console"
77 "## Automatic connection using a new Qt Console"
101 ]
78 ]
102 },
79 },
103 {
80 {
104 "cell_type": "markdown",
81 "cell_type": "markdown",
105 "metadata": {},
82 "metadata": {},
106 "source": [
83 "source": [
107 "You can also start a new Qt Console connected to your current Kernel by using the `%qtconsole` magic. This will detect the necessary connection\n",
84 "You can also start a new Qt Console connected to your current Kernel by using the `%qtconsole` magic. This will detect the necessary connection\n",
108 "information and start the Qt Console for you automatically."
85 "information and start the Qt Console for you automatically."
109 ]
86 ]
110 },
87 },
111 {
88 {
112 "cell_type": "code",
89 "cell_type": "code",
113 "execution_count": 1,
90 "execution_count": null,
114 "metadata": {
91 "metadata": {
115 "collapsed": false
92 "collapsed": false
116 },
93 },
117 "outputs": [],
94 "outputs": [],
118 "source": [
95 "source": [
119 "a = 10"
96 "a = 10"
120 ]
97 ]
121 },
98 },
122 {
99 {
123 "cell_type": "code",
100 "cell_type": "code",
124 "execution_count": 2,
101 "execution_count": null,
125 "metadata": {
102 "metadata": {
126 "collapsed": false
103 "collapsed": false
127 },
104 },
128 "outputs": [],
105 "outputs": [],
129 "source": [
106 "source": [
130 "%qtconsole"
107 "%qtconsole"
131 ]
108 ]
132 }
109 }
133 ],
110 ],
134 "metadata": {
111 "metadata": {
135 "kernelspec": {
112 "kernelspec": {
136 "display_name": "Python 3",
113 "display_name": "Python 3",
137 "language": "python",
114 "language": "python",
138 "name": "python3"
115 "name": "python3"
139 },
116 },
140 "language_info": {
117 "language_info": {
141 "codemirror_mode": {
118 "codemirror_mode": {
142 "name": "ipython",
119 "name": "ipython",
143 "version": 3
120 "version": 3
144 },
121 },
145 "file_extension": ".py",
122 "file_extension": ".py",
146 "mimetype": "text/x-python",
123 "mimetype": "text/x-python",
147 "name": "python",
124 "name": "python",
148 "nbconvert_exporter": "python",
125 "nbconvert_exporter": "python",
149 "pygments_lexer": "ipython3",
126 "pygments_lexer": "ipython3",
150 "version": "3.4.2"
127 "version": "3.4.3"
151 }
128 }
152 },
129 },
153 "nbformat": 4,
130 "nbformat": 4,
154 "nbformat_minor": 0
131 "nbformat_minor": 0
155 }
132 }
@@ -1,503 +1,317 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "# NbConvert"
7 "# NbConvert"
8 ]
8 ]
9 },
9 },
10 {
10 {
11 "cell_type": "markdown",
11 "cell_type": "markdown",
12 "metadata": {},
12 "metadata": {},
13 "source": [
13 "source": [
14 "## Command line usage"
14 "## Command line usage"
15 ]
15 ]
16 },
16 },
17 {
17 {
18 "cell_type": "markdown",
18 "cell_type": "markdown",
19 "metadata": {},
19 "metadata": {},
20 "source": [
20 "source": [
21 "`NbConvert` is the library, and the command line tool that allow to convert from notebook to other formats.\n",
21 "`NbConvert` is both a library and command line tool that allows you to convert notebooks to other formats. It ships with many common formats: `html`, `latex`, `markdown`, `python`, `rst`, and `slides`\n",
22 "It is a technological preview in 1.0 but is already usable and highly configurable.\n",
22 "NbConvert relys on the Jinja templating engine, so implementing a new format or tweeking an existing one is easy."
23 "It ships already with many default available formats : `html`, `latex`, `markdown`, `python`, `rst` and `slides`\n",
24 "which are fully base on Jinja templating engine, so writing a converter for your custom format or tweeking the existing \n",
25 "one should be extra simple."
26 ]
23 ]
27 },
24 },
28 {
25 {
29 "cell_type": "markdown",
26 "cell_type": "markdown",
30 "metadata": {},
27 "metadata": {},
31 "source": [
28 "source": [
32 "You can invoke nbconvert by doing\n",
29 "You can invoke nbconvert by running\n",
33 "\n",
30 "\n",
34 "```bash\n",
31 "```bash\n",
35 "$ ipython nbconvert <options and arguments>\n",
32 "$ ipython nbconvert <options and arguments>\n",
36 "```\n",
33 "```\n",
37 "\n",
34 "\n",
38 "Call `ipython nbconvert` with the `--help` flag or no aruments to get basic help on how to use it.\n",
35 "Call `ipython nbconvert` with the `--help` flag or without any aruments to display the basic help. For detailed configuration help, use the `--help-all` flag."
39 "For more information about configuration use the `--help-all` flag"
40 ]
36 ]
41 },
37 },
42 {
38 {
43 "cell_type": "markdown",
39 "cell_type": "markdown",
44 "metadata": {},
40 "metadata": {},
45 "source": [
41 "source": [
46 "### Basic export"
42 "### Basic export"
47 ]
43 ]
48 },
44 },
49 {
45 {
50 "cell_type": "markdown",
46 "cell_type": "markdown",
51 "metadata": {},
47 "metadata": {},
52 "source": [
48 "source": [
53 "We will be converting `Custom Display Logic.ipynb`. \n",
49 "As a test, the `Index.ipynb` notebook in the directory will be convert. \n",
54 "Be sure to have runed some of the cells in it to have output otherwise you will only see input in nbconvert.\n",
50 "\n",
55 "Nbconvert **do not execute the code** in the notebook files, it only converts what is inside."
51 "If you're converting a notebook with code in it, make sure to run the code cells that you're interested in before attempting to convert the notebook. Nbconvert **does not execute the code cell** of the notebooks that it converts."
56 ]
52 ]
57 },
53 },
58 {
54 {
59 "cell_type": "code",
55 "cell_type": "code",
60 "execution_count": 1,
56 "execution_count": null,
61 "metadata": {
57 "metadata": {
62 "collapsed": false
58 "collapsed": false
63 },
59 },
64 "outputs": [
60 "outputs": [],
65 {
66 "name": "stderr",
67 "output_type": "stream",
68 "text": [
69 "[NbConvertApp] Using existing profile dir: u'/Users/bussonniermatthias/.ipython/profile_default'\n",
70 "[NbConvertApp] Converting notebook 04 - Custom Display Logic.ipynb to html\n",
71 "[NbConvertApp] Support files will be in 04 - Custom Display Logic_files/\n",
72 "[NbConvertApp] Loaded template html_full.tpl\n",
73 "[NbConvertApp] Writing 221081 bytes to 04 - Custom Display Logic.html\n"
74 ]
75 }
76 ],
77 "source": [
61 "source": [
78 "%%bash\n",
62 "%%bash\n",
79 "ipython nbconvert '04 - Custom Display Logic.ipynb'"
63 "ipython nbconvert 'Index.ipynb'"
80 ]
64 ]
81 },
65 },
82 {
66 {
83 "cell_type": "markdown",
67 "cell_type": "markdown",
84 "metadata": {},
68 "metadata": {},
85 "source": [
69 "source": [
86 "Html is the default value (that can be configured) , so the verbose form would be "
70 "Html is the (configurable) default value. The verbose form of the same command as above is "
87 ]
71 ]
88 },
72 },
89 {
73 {
90 "cell_type": "code",
74 "cell_type": "code",
91 "execution_count": 2,
75 "execution_count": null,
92 "metadata": {
76 "metadata": {
93 "collapsed": false
77 "collapsed": false
94 },
78 },
95 "outputs": [
79 "outputs": [],
96 {
97 "name": "stderr",
98 "output_type": "stream",
99 "text": [
100 "[NbConvertApp] Using existing profile dir: u'/Users/bussonniermatthias/.ipython/profile_default'\n",
101 "[NbConvertApp] Converting notebook 04 - Custom Display Logic.ipynb to html\n",
102 "[NbConvertApp] Support files will be in 04 - Custom Display Logic_files/\n",
103 "[NbConvertApp] Loaded template html_full.tpl\n",
104 "[NbConvertApp] Writing 221081 bytes to 04 - Custom Display Logic.html\n"
105 ]
106 }
107 ],
108 "source": [
80 "source": [
109 "%%bash\n",
81 "%%bash\n",
110 "ipython nbconvert --to=html '04 - Custom Display Logic.ipynb'"
82 "ipython nbconvert --to=html 'Index.ipynb'"
111 ]
83 ]
112 },
84 },
113 {
85 {
114 "cell_type": "markdown",
86 "cell_type": "markdown",
115 "metadata": {},
87 "metadata": {},
116 "source": [
88 "source": [
117 "You can also convert to latex, which will take care of extractin the embeded base64 encoded png, or the svg and call inkscape to convert those svg to pdf if necessary :"
89 "You can also convert to latex, which will extract the embeded images. If the embeded images are SVGs, inkscape is used to convert them to pdf:"
118 ]
90 ]
119 },
91 },
120 {
92 {
121 "cell_type": "code",
93 "cell_type": "code",
122 "execution_count": 3,
94 "execution_count": null,
123 "metadata": {
95 "metadata": {
124 "collapsed": false
96 "collapsed": false
125 },
97 },
126 "outputs": [
98 "outputs": [],
127 {
128 "name": "stderr",
129 "output_type": "stream",
130 "text": [
131 "[NbConvertApp] Using existing profile dir: u'/Users/bussonniermatthias/.ipython/profile_default'\n",
132 "[NbConvertApp] Converting notebook 04 - Custom Display Logic.ipynb to latex\n",
133 "[NbConvertApp] Support files will be in 04 - Custom Display Logic_files/\n",
134 "Setting Language: .UTF-8\n",
135 "\n",
136 "(process:26432): Gtk-WARNING **: Locale not supported by C library.\n",
137 "\tUsing the fallback 'C' locale.\n",
138 "Setting Language: .UTF-8\n",
139 "\n",
140 "(process:26472): Gtk-WARNING **: Locale not supported by C library.\n",
141 "\tUsing the fallback 'C' locale.\n",
142 "Setting Language: .UTF-8\n",
143 "\n",
144 "(process:26512): Gtk-WARNING **: Locale not supported by C library.\n",
145 "\tUsing the fallback 'C' locale.\n",
146 "Setting Language: .UTF-8\n",
147 "\n",
148 "(process:26552): Gtk-WARNING **: Locale not supported by C library.\n",
149 "\tUsing the fallback 'C' locale.\n",
150 "Setting Language: .UTF-8\n",
151 "\n",
152 "(process:26592): Gtk-WARNING **: Locale not supported by C library.\n",
153 "\tUsing the fallback 'C' locale.\n",
154 "[NbConvertApp] Loaded template latex_article.tplx\n",
155 "[NbConvertApp] Writing 41196 bytes to 04 - Custom Display Logic.tex\n"
156 ]
157 }
158 ],
159 "source": [
99 "source": [
160 "%%bash\n",
100 "%%bash\n",
161 "ipython nbconvert --to=latex '04 - Custom Display Logic.ipynb'"
101 "ipython nbconvert --to=latex 'Index.ipynb'"
162 ]
102 ]
163 },
103 },
164 {
104 {
165 "cell_type": "markdown",
105 "cell_type": "markdown",
166 "metadata": {},
106 "metadata": {},
167 "source": [
107 "source": [
168 "You should just have to compile the generated `.tex` file. If you get the required packages installed, if should compile out of the box.\n",
108 "Note that the latex conversion creates latex, not a PDF. To create a PDF you need the required third party packages to compile the latex.\n",
169 "\n",
109 "\n",
170 "For convenience we allow to run extra action after the conversion has been done, in particular for `latex` we have a `pdf` post-processor. \n",
110 "A `--post` flag is provided for convinience which allows you to have nbconvert automatically compile a PDF for you from your output."
171 "You can define the postprocessor tu run with the `--post` flag."
172 ]
111 ]
173 },
112 },
174 {
113 {
175 "cell_type": "code",
114 "cell_type": "code",
176 "execution_count": 4,
115 "execution_count": null,
177 "metadata": {
116 "metadata": {
178 "collapsed": false
117 "collapsed": false
179 },
118 },
180 "outputs": [
119 "outputs": [],
181 {
182 "name": "stderr",
183 "output_type": "stream",
184 "text": [
185 "[NbConvertApp] Using existing profile dir: u'/Users/bussonniermatthias/.ipython/profile_default'\n",
186 "[NbConvertApp] Converting notebook 04 - Custom Display Logic.ipynb to latex\n",
187 "[NbConvertApp] Support files will be in 04 - Custom Display Logic_files/\n",
188 "Setting Language: .UTF-8\n",
189 "\n",
190 "(process:26658): Gtk-WARNING **: Locale not supported by C library.\n",
191 "\tUsing the fallback 'C' locale.\n",
192 "Setting Language: .UTF-8\n",
193 "\n",
194 "(process:26698): Gtk-WARNING **: Locale not supported by C library.\n",
195 "\tUsing the fallback 'C' locale.\n",
196 "Setting Language: .UTF-8\n",
197 "\n",
198 "(process:26738): Gtk-WARNING **: Locale not supported by C library.\n",
199 "\tUsing the fallback 'C' locale.\n",
200 "Setting Language: .UTF-8\n",
201 "\n",
202 "(process:26778): Gtk-WARNING **: Locale not supported by C library.\n",
203 "\tUsing the fallback 'C' locale.\n",
204 "Setting Language: .UTF-8\n",
205 "\n",
206 "(process:26818): Gtk-WARNING **: Locale not supported by C library.\n",
207 "\tUsing the fallback 'C' locale.\n",
208 "[NbConvertApp] Loaded template latex_article.tplx\n",
209 "[NbConvertApp] Writing 41196 bytes to 04 - Custom Display Logic.tex\n",
210 "[NbConvertApp] Building PDF: ['pdflatex', '04 - Custom Display Logic.tex']\n"
211 ]
212 }
213 ],
214 "source": [
120 "source": [
215 "%%bash\n",
121 "%%bash\n",
216 "ipython nbconvert --to=latex '04 - Custom Display Logic.ipynb' --post=pdf"
122 "ipython nbconvert --to=latex 'Index.ipynb' --post=pdf"
217 ]
123 ]
218 },
124 },
219 {
125 {
220 "cell_type": "markdown",
126 "cell_type": "markdown",
221 "metadata": {},
127 "metadata": {},
222 "source": [
128 "source": [
223 "Have a look at `04 - Custom Display Logic.pdf`, toward the end, where we compared `display()` vs `display_html()` and returning the object.\n",
129 "## Custom templates"
224 "See how the cell where we use `display_html` was not able to display the circle, whereas the two other ones were able to select one of the oher representation they know how to display."
225 ]
130 ]
226 },
131 },
227 {
132 {
228 "cell_type": "markdown",
133 "cell_type": "markdown",
229 "metadata": {},
134 "metadata": {},
230 "source": [
135 "source": [
231 "### Customizing template"
136 "Look at the first 20 lines of the `python` exporter"
232 ]
233 },
234 {
235 "cell_type": "markdown",
236 "metadata": {},
237 "source": [
238 "let's look at the first 20 lines of the `python` exporter"
239 ]
137 ]
240 },
138 },
241 {
139 {
242 "cell_type": "code",
140 "cell_type": "code",
243 "execution_count": 5,
141 "execution_count": null,
244 "metadata": {
142 "metadata": {
245 "collapsed": false
143 "collapsed": false
246 },
144 },
247 "outputs": [
145 "outputs": [],
248 {
249 "name": "stdout",
250 "output_type": "stream",
251 "text": [
252 "# 1. Implementing special display methods such as `_repr_html_`.\n",
253 "# 2. Registering a display function for a particular type.\n",
254 "# \n",
255 "# In this Notebook we show how both approaches work.\n",
256 "\n",
257 "# Before we get started, we will import the various display functions for displaying the different formats we will create.\n",
258 "\n",
259 "# In[54]:\n",
260 "\n",
261 "from IPython.display import display\n",
262 "from IPython.display import (\n",
263 " display_html, display_jpeg, display_png,\n",
264 " display_javascript, display_svg, display_latex\n",
265 ")\n",
266 "\n",
267 "\n",
268 "### Implementing special display methods\n",
269 "\n",
270 "# The main idea of the first approach is that you have to implement special display methods, one for each representation you want to use. Here is a list of the names of the special methods and the values they must return:\n",
271 "# \n"
272 ]
273 }
274 ],
275 "source": [
146 "source": [
276 "pyfile = !ipython nbconvert --to python '04 - Custom Display Logic.ipynb' --stdout\n",
147 "pyfile = !ipython nbconvert --to python 'Index.ipynb' --stdout\n",
277 "for l in pyfile[20:40]:\n",
148 "for l in pyfile[20:40]:\n",
278 " print l"
149 " print l"
279 ]
150 ]
280 },
151 },
281 {
152 {
282 "cell_type": "markdown",
153 "cell_type": "markdown",
283 "metadata": {},
154 "metadata": {},
284 "source": [
155 "source": [
285 "We see that the non-code cell are exported to the file. To have a cleaner script, we will export only the code contained in the code cells.\n",
156 "From the code, you can see that non-code cells are also exported. If you want to change this behavior, you can use a custom template. The custom template inherits from the Python template and overwrites the markdown blocks so that they are empty."
286 "\n",
287 "To do so, we will inherit the python template, and overwrite the markdown blocks to be empty."
288 ]
157 ]
289 },
158 },
290 {
159 {
291 "cell_type": "code",
160 "cell_type": "code",
292 "execution_count": 6,
161 "execution_count": null,
293 "metadata": {
162 "metadata": {
294 "collapsed": false
163 "collapsed": false
295 },
164 },
296 "outputs": [
165 "outputs": [],
297 {
298 "name": "stdout",
299 "output_type": "stream",
300 "text": [
301 "Overwriting simplepython.tpl\n"
302 ]
303 }
304 ],
305 "source": [
166 "source": [
306 "%%writefile simplepython.tpl\n",
167 "%%writefile simplepython.tpl\n",
307 "{% extends 'python.tpl'%}\n",
168 "{% extends 'python.tpl'%}\n",
308 "\n",
169 "\n",
309 "{% block markdowncell -%}\n",
170 "{% block markdowncell -%}\n",
310 "{% endblock markdowncell %}\n",
171 "{% endblock markdowncell %}\n",
311 "\n",
172 "\n",
312 "## we also want to get rig of header cell\n",
173 "## we also want to get rig of header cell\n",
313 "{% block headingcell -%}\n",
174 "{% block headingcell -%}\n",
314 "{% endblock headingcell %}\n",
175 "{% endblock headingcell %}\n",
315 "\n",
176 "\n",
316 "## and let's change the appearance of input prompt\n",
177 "## and let's change the appearance of input prompt\n",
317 "{% block in_prompt %}\n",
178 "{% block in_prompt %}\n",
318 "# This was input cell with prompt number : {{ cell.prompt_number if cell.prompt_number else ' ' }}\n",
179 "# This was input cell with prompt number : {{ cell.prompt_number if cell.prompt_number else ' ' }}\n",
319 "{%- endblock in_prompt %}"
180 "{%- endblock in_prompt %}"
320 ]
181 ]
321 },
182 },
322 {
183 {
323 "cell_type": "code",
184 "cell_type": "code",
324 "execution_count": 7,
185 "execution_count": null,
325 "metadata": {
186 "metadata": {
326 "collapsed": false
187 "collapsed": false
327 },
188 },
328 "outputs": [
189 "outputs": [],
329 {
330 "name": "stdout",
331 "output_type": "stream",
332 "text": [
333 "\n",
334 "# This was input cell with prompt number : 54\n",
335 "from IPython.display import display\n",
336 "from IPython.display import (\n",
337 " display_html, display_jpeg, display_png,\n",
338 " display_javascript, display_svg, display_latex\n",
339 ")\n",
340 "\n",
341 "\n",
342 "# This was input cell with prompt number : 55\n",
343 "get_ipython().magic(u'load soln/mycircle.py')\n",
344 "\n",
345 "\n",
346 "# This was input cell with prompt number : 56\n",
347 "class MyCircle(object):\n",
348 " \n",
349 " def _repr_html_(self):\n",
350 " return \"&#x25CB; (<b>html</b>)\"\n",
351 "\n",
352 " def _repr_svg_(self):\n",
353 " return \"\"\"<svg width='100px' height='100px'>\n",
354 " <circle cx=\"50\" cy=\"50\" r=\"20\" stroke=\"black\" stroke-width=\"1\" fill=\"blue\"/>\n",
355 " </svg>\"\"\"\n",
356 " \n",
357 " def _repr_latex_(self):\n",
358 " return r\"$\\bigcirc \\LaTeX$\"\n",
359 "\n",
360 " def _repr_javascript_(self):\n",
361 " return \"alert('I am a circle!');\"\n",
362 "\n",
363 "\n",
364 "# This was input cell with prompt number : 57\n",
365 "c = MyCircle()\n",
366 "\n",
367 "\n",
368 "# This was input cell with prompt number : 58\n",
369 "...\n"
370 ]
371 }
372 ],
373 "source": [
190 "source": [
374 "pyfile = !ipython nbconvert --to python '04 - Custom Display Logic.ipynb' --stdout --template=simplepython.tpl\n",
191 "pyfile = !ipython nbconvert --to python 'Index.ipynb' --stdout --template=simplepython.tpl\n",
375 "\n",
192 "\n",
376 "for l in pyfile[4:40]:\n",
193 "for l in pyfile[4:40]:\n",
377 " print l\n",
194 " print l\n",
378 "print '...'"
195 "print '...'"
379 ]
196 ]
380 },
197 },
381 {
198 {
382 "cell_type": "markdown",
199 "cell_type": "markdown",
383 "metadata": {},
200 "metadata": {},
384 "source": [
201 "source": [
385 "I'll let you read Jinja manual for the exact syntax of the template."
202 "For details about the template syntax, refer to [Jinja's manual](http://jinja.pocoo.org/docs/dev/)."
386 ]
203 ]
387 },
204 },
388 {
205 {
389 "cell_type": "markdown",
206 "cell_type": "markdown",
390 "metadata": {},
207 "metadata": {},
391 "source": [
208 "source": [
392 "## Template that use cells metadata"
209 "## Template that use cells metadata"
393 ]
210 ]
394 },
211 },
395 {
212 {
396 "cell_type": "markdown",
213 "cell_type": "markdown",
397 "metadata": {},
214 "metadata": {},
398 "source": [
215 "source": [
399 "Notebook fileformat support attaching arbitrary JSON metadata to each cell of a notebook. In this part we will use those metadata."
216 "The notebook file format supports attaching arbitrary JSON metadata to each cell. Here, as an exercise, you will use the metadata to tags cells."
400 ]
217 ]
401 },
218 },
402 {
219 {
403 "cell_type": "markdown",
220 "cell_type": "markdown",
404 "metadata": {},
221 "metadata": {},
405 "source": [
222 "source": [
406 "First you need to choose another notebook you want to convert to html, and tag some of the cell with metadata.\n",
223 "First you need to choose another notebook you want to convert to html, and tag some of the cell with metadata. You can refere to the file `soln/celldiff.js` as an example or follow the Javascript tutorial to figure out how do change cell metadata. Assuming you have a notebook with some of the cells tagged as `Easy`|`Medium`|`Hard`|`<None>`, the notebook can be converted specially using a custom template. Design your remplate in the cells provided below.\n",
407 "You can see the file `soln/celldiff.js` for a solution on how to tag, or follow the javascript tutorial to see how to do that. Use what we have written there to tag cells of some notebooks to `Easy`|`Medium`|`Hard`|`<None>`, and convert this notebook using your template."
224 "\n",
225 "The following, unorganized lines of code, may be of help:"
408 ]
226 ]
409 },
227 },
410 {
228 {
411 "cell_type": "markdown",
229 "cell_type": "markdown",
412 "metadata": {},
230 "metadata": {},
413 "source": [
231 "source": [
414 "you might need the following : \n",
415 "```\n",
232 "```\n",
416 "{% extends 'html_full.tpl'%}\n",
233 "{% extends 'html_full.tpl'%}\n",
417 "{% block any_cell %}\n",
234 "{% block any_cell %}\n",
418 "{{ super() }}\n",
235 "{{ super() }}\n",
419 "<div style=\"background-color:red\">\n",
236 "<div style=\"background-color:red\">\n",
420 "<div style='background-color:orange'>\n",
237 "<div style='background-color:orange'>\n",
421 "```\n",
238 "```\n",
422 "\n",
239 "\n",
423 "`metadata` might not exist, be sure to :\n",
240 "If your key name under `cell.metadata.example.difficulty`, the following code would get the value of it:\n",
424 "\n",
241 "\n",
425 "`cell['metadata'].get('example',{}).get('difficulty','')`\n",
242 "`cell['metadata'].get('example',{}).get('difficulty','')`\n",
426 "\n",
243 "\n",
427 "tip: use `%%writefile` to edit the template in the notebook :-)"
244 "Tip: Use `%%writefile` to edit the template in the notebook."
428 ]
245 ]
429 },
246 },
430 {
247 {
431 "cell_type": "code",
248 "cell_type": "code",
432 "execution_count": 8,
249 "execution_count": null,
433 "metadata": {
250 "metadata": {
434 "collapsed": false
251 "collapsed": false
435 },
252 },
436 "outputs": [],
253 "outputs": [],
437 "source": [
254 "source": [
438 "%%bash\n",
255 "%%bash\n",
439 "# ipython nbconvert --to html <your chosen notebook.ipynb> --template=<your template file>"
256 "# ipython nbconvert --to html <your chosen notebook.ipynb> --template=<your template file>"
440 ]
257 ]
441 },
258 },
442 {
259 {
443 "cell_type": "code",
260 "cell_type": "code",
444 "execution_count": null,
261 "execution_count": null,
445 "metadata": {
262 "metadata": {
446 "collapsed": false
263 "collapsed": false
447 },
264 },
448 "outputs": [],
265 "outputs": [],
449 "source": [
266 "source": [
450 "%loadpy soln/coloreddiff.tpl"
267 "%loadpy soln/coloreddiff.tpl"
451 ]
268 ]
452 },
269 },
453 {
270 {
454 "cell_type": "code",
271 "cell_type": "code",
455 "execution_count": null,
272 "execution_count": null,
456 "metadata": {
273 "metadata": {
457 "collapsed": false
274 "collapsed": false
458 },
275 },
459 "outputs": [],
276 "outputs": [],
460 "source": [
277 "source": [
461 "# ipython nbconvert --to html '04 - Custom Display Logic.ipynb' --template=soln/coloreddiff.tpl"
278 "# ipython nbconvert --to html '04 - Custom Display Logic.ipynb' --template=soln/coloreddiff.tpl"
462 ]
279 ]
463 },
280 },
464 {
281 {
465 "cell_type": "markdown",
282 "cell_type": "markdown",
466 "metadata": {},
283 "metadata": {},
467 "source": [
284 "source": [
468 "### Get rid of all command line flags."
285 "### Get rid of all command line flags."
469 ]
286 ]
470 },
287 },
471 {
288 {
472 "cell_type": "markdown",
289 "cell_type": "markdown",
473 "metadata": {},
290 "metadata": {},
474 "source": [
291 "source": [
475 "As of all of IPython nbconvert can be configured using profiles and passing the `--profile` flag. \n",
292 "IPython nbconvert can be configured using the default profile and by selecting a non-default a profile via `--profile` flag. Additionally, if a `config.py` file exist in current working directory, nbconvert will use that as config."
476 "Moreover if a `config.py` file exist in current working directory nbconvert will use that, or read the config file you give to it with the `--config=<file>` flag. \n",
477 "\n",
478 "In the end, if you are often running nbconvert on the sam project, `$ ipython nbconvert` should be enough to get you up and ready."
479 ]
293 ]
480 }
294 }
481 ],
295 ],
482 "metadata": {
296 "metadata": {
483 "kernelspec": {
297 "kernelspec": {
484 "display_name": "Python 3",
298 "display_name": "Python 3",
485 "language": "python",
299 "language": "python",
486 "name": "python3"
300 "name": "python3"
487 },
301 },
488 "language_info": {
302 "language_info": {
489 "codemirror_mode": {
303 "codemirror_mode": {
490 "name": "ipython",
304 "name": "ipython",
491 "version": 3
305 "version": 3
492 },
306 },
493 "file_extension": ".py",
307 "file_extension": ".py",
494 "mimetype": "text/x-python",
308 "mimetype": "text/x-python",
495 "name": "python",
309 "name": "python",
496 "nbconvert_exporter": "python",
310 "nbconvert_exporter": "python",
497 "pygments_lexer": "ipython3",
311 "pygments_lexer": "ipython3",
498 "version": "3.4.2"
312 "version": "3.4.3"
499 }
313 }
500 },
314 },
501 "nbformat": 4,
315 "nbformat": 4,
502 "nbformat_minor": 0
316 "nbformat_minor": 0
503 }
317 }
@@ -1,165 +1,113 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "# Keyboard Shortcut Customization"
7 "# Keyboard Shortcut Customization"
8 ]
8 ]
9 },
9 },
10 {
10 {
11 "cell_type": "markdown",
11 "cell_type": "markdown",
12 "metadata": {},
12 "metadata": {},
13 "source": [
13 "source": [
14 "Starting with IPython 2.0 keyboard shortcuts in command and edit mode are fully customizable. These customizations are made using the IPython JavaScript API. Here is an example that makes the `r` key available for running a cell:"
14 "Starting with IPython 2.0 keyboard shortcuts in command and edit mode are fully customizable. These customizations are made using the IPython JavaScript API. Here is an example that makes the `r` key available for running a cell:"
15 ]
15 ]
16 },
16 },
17 {
17 {
18 "cell_type": "code",
18 "cell_type": "code",
19 "execution_count": 7,
19 "execution_count": null,
20 "metadata": {
20 "metadata": {
21 "collapsed": false
21 "collapsed": false
22 },
22 },
23 "outputs": [
23 "outputs": [],
24 {
25 "data": {
26 "application/javascript": [
27 "\n",
28 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n",
29 " help : 'run cell',\n",
30 " help_index : 'zz',\n",
31 " handler : function (event) {\n",
32 " IPython.notebook.execute_cell();\n",
33 " return false;\n",
34 " }}\n",
35 ");"
36 ],
37 "text/plain": [
38 "<IPython.core.display.Javascript at 0x10e8d1890>"
39 ]
40 },
41 "metadata": {},
42 "output_type": "display_data"
43 }
44 ],
45 "source": [
24 "source": [
46 "%%javascript\n",
25 "%%javascript\n",
47 "\n",
26 "\n",
48 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n",
27 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n",
49 " help : 'run cell',\n",
28 " help : 'run cell',\n",
50 " help_index : 'zz',\n",
29 " help_index : 'zz',\n",
51 " handler : function (event) {\n",
30 " handler : function (event) {\n",
52 " IPython.notebook.execute_cell();\n",
31 " IPython.notebook.execute_cell();\n",
53 " return false;\n",
32 " return false;\n",
54 " }}\n",
33 " }}\n",
55 ");"
34 ");"
56 ]
35 ]
57 },
36 },
58 {
37 {
59 "cell_type": "markdown",
38 "cell_type": "markdown",
60 "metadata": {},
39 "metadata": {},
61 "source": [
40 "source": [
62 "There are a couple of points to mention about this API:\n",
41 "There are a couple of points to mention about this API:\n",
63 "\n",
42 "\n",
64 "* The `help_index` field is used to sort the shortcuts in the Keyboard Shortcuts help dialog. It defaults to `zz`.\n",
43 "* The `help_index` field is used to sort the shortcuts in the Keyboard Shortcuts help dialog. It defaults to `zz`.\n",
65 "* When a handler returns `false` it indicates that the event should stop propagating and the default action should not be performed. For further details about the `event` object or event handling, see the jQuery docs.\n",
44 "* When a handler returns `false` it indicates that the event should stop propagating and the default action should not be performed. For further details about the `event` object or event handling, see the jQuery docs.\n",
66 "* If you don't need a `help` or `help_index` field, you can simply pass a function as the second argument to `add_shortcut`."
45 "* If you don't need a `help` or `help_index` field, you can simply pass a function as the second argument to `add_shortcut`."
67 ]
46 ]
68 },
47 },
69 {
48 {
70 "cell_type": "code",
49 "cell_type": "code",
71 "execution_count": 11,
50 "execution_count": null,
72 "metadata": {
51 "metadata": {
73 "collapsed": false
52 "collapsed": false
74 },
53 },
75 "outputs": [
54 "outputs": [],
76 {
77 "data": {
78 "application/javascript": [
79 "\n",
80 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n",
81 " IPython.notebook.execute_cell();\n",
82 " return false;\n",
83 "});"
84 ],
85 "text/plain": [
86 "<IPython.core.display.Javascript at 0x1019baf90>"
87 ]
88 },
89 "metadata": {},
90 "output_type": "display_data"
91 }
92 ],
93 "source": [
55 "source": [
94 "%%javascript\n",
56 "%%javascript\n",
95 "\n",
57 "\n",
96 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n",
58 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n",
97 " IPython.notebook.execute_cell();\n",
59 " IPython.notebook.execute_cell();\n",
98 " return false;\n",
60 " return false;\n",
99 "});"
61 "});"
100 ]
62 ]
101 },
63 },
102 {
64 {
103 "cell_type": "markdown",
65 "cell_type": "markdown",
104 "metadata": {},
66 "metadata": {},
105 "source": [
67 "source": [
106 "Likewise, to remove a shortcut, use `remove_shortcut`:"
68 "Likewise, to remove a shortcut, use `remove_shortcut`:"
107 ]
69 ]
108 },
70 },
109 {
71 {
110 "cell_type": "code",
72 "cell_type": "code",
111 "execution_count": 8,
73 "execution_count": null,
112 "metadata": {
74 "metadata": {
113 "collapsed": false
75 "collapsed": false
114 },
76 },
115 "outputs": [
77 "outputs": [],
116 {
117 "data": {
118 "application/javascript": [
119 "\n",
120 "IPython.keyboard_manager.command_shortcuts.remove_shortcut('r');"
121 ],
122 "text/plain": [
123 "<IPython.core.display.Javascript at 0x10e8d1950>"
124 ]
125 },
126 "metadata": {},
127 "output_type": "display_data"
128 }
129 ],
130 "source": [
78 "source": [
131 "%%javascript\n",
79 "%%javascript\n",
132 "\n",
80 "\n",
133 "IPython.keyboard_manager.command_shortcuts.remove_shortcut('r');"
81 "IPython.keyboard_manager.command_shortcuts.remove_shortcut('r');"
134 ]
82 ]
135 },
83 },
136 {
84 {
137 "cell_type": "markdown",
85 "cell_type": "markdown",
138 "metadata": {},
86 "metadata": {},
139 "source": [
87 "source": [
140 "If you want your keyboard shortcuts to be active for all of your notebooks, put the above API calls into your `<profile>/static/custom/custom.js` file."
88 "If you want your keyboard shortcuts to be active for all of your notebooks, put the above API calls into your `<profile>/static/custom/custom.js` file."
141 ]
89 ]
142 }
90 }
143 ],
91 ],
144 "metadata": {
92 "metadata": {
145 "kernelspec": {
93 "kernelspec": {
146 "display_name": "Python 3",
94 "display_name": "Python 3",
147 "language": "python",
95 "language": "python",
148 "name": "python3"
96 "name": "python3"
149 },
97 },
150 "language_info": {
98 "language_info": {
151 "codemirror_mode": {
99 "codemirror_mode": {
152 "name": "ipython",
100 "name": "ipython",
153 "version": 3
101 "version": 3
154 },
102 },
155 "file_extension": ".py",
103 "file_extension": ".py",
156 "mimetype": "text/x-python",
104 "mimetype": "text/x-python",
157 "name": "python",
105 "name": "python",
158 "nbconvert_exporter": "python",
106 "nbconvert_exporter": "python",
159 "pygments_lexer": "ipython3",
107 "pygments_lexer": "ipython3",
160 "version": "3.4.2"
108 "version": "3.4.3"
161 }
109 }
162 },
110 },
163 "nbformat": 4,
111 "nbformat": 4,
164 "nbformat_minor": 0
112 "nbformat_minor": 0
165 }
113 }
@@ -1,733 +1,521 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "# Importing IPython Notebooks as Modules"
7 "# Importing IPython Notebooks as Modules"
8 ]
8 ]
9 },
9 },
10 {
10 {
11 "cell_type": "markdown",
11 "cell_type": "markdown",
12 "metadata": {},
12 "metadata": {},
13 "source": [
13 "source": [
14 "It is a common problem that people want to import code from IPython Notebooks.\n",
14 "It is a common problem that people want to import code from IPython Notebooks.\n",
15 "This is made difficult by the fact that Notebooks are not plain Python files,\n",
15 "This is made difficult by the fact that Notebooks are not plain Python files,\n",
16 "and thus cannot be imported by the regular Python machinery.\n",
16 "and thus cannot be imported by the regular Python machinery.\n",
17 "\n",
17 "\n",
18 "Fortunately, Python provides some fairly sophisticated [hooks](http://www.python.org/dev/peps/pep-0302/) into the import machinery,\n",
18 "Fortunately, Python provides some fairly sophisticated [hooks](http://www.python.org/dev/peps/pep-0302/) into the import machinery,\n",
19 "so we can actually make IPython notebooks importable without much difficulty,\n",
19 "so we can actually make IPython notebooks importable without much difficulty,\n",
20 "and only using public APIs."
20 "and only using public APIs."
21 ]
21 ]
22 },
22 },
23 {
23 {
24 "cell_type": "code",
24 "cell_type": "code",
25 "execution_count": 1,
25 "execution_count": null,
26 "metadata": {
26 "metadata": {
27 "collapsed": false
27 "collapsed": false
28 },
28 },
29 "outputs": [],
29 "outputs": [],
30 "source": [
30 "source": [
31 "import io, os, sys, types"
31 "import io, os, sys, types"
32 ]
32 ]
33 },
33 },
34 {
34 {
35 "cell_type": "code",
35 "cell_type": "code",
36 "execution_count": 2,
36 "execution_count": null,
37 "metadata": {
37 "metadata": {
38 "collapsed": false
38 "collapsed": false
39 },
39 },
40 "outputs": [],
40 "outputs": [],
41 "source": [
41 "source": [
42 "from IPython.nbformat import current\n",
42 "from IPython.nbformat import current\n",
43 "from IPython.core.interactiveshell import InteractiveShell"
43 "from IPython.core.interactiveshell import InteractiveShell"
44 ]
44 ]
45 },
45 },
46 {
46 {
47 "cell_type": "markdown",
47 "cell_type": "markdown",
48 "metadata": {},
48 "metadata": {},
49 "source": [
49 "source": [
50 "Import hooks typically take the form of two objects:\n",
50 "Import hooks typically take the form of two objects:\n",
51 "\n",
51 "\n",
52 "1. a Module **Loader**, which takes a module name (e.g. `'IPython.display'`), and returns a Module\n",
52 "1. a Module **Loader**, which takes a module name (e.g. `'IPython.display'`), and returns a Module\n",
53 "2. a Module **Finder**, which figures out whether a module might exist, and tells Python what **Loader** to use"
53 "2. a Module **Finder**, which figures out whether a module might exist, and tells Python what **Loader** to use"
54 ]
54 ]
55 },
55 },
56 {
56 {
57 "cell_type": "code",
57 "cell_type": "code",
58 "execution_count": 3,
58 "execution_count": null,
59 "metadata": {
59 "metadata": {
60 "collapsed": false
60 "collapsed": false
61 },
61 },
62 "outputs": [],
62 "outputs": [],
63 "source": [
63 "source": [
64 "def find_notebook(fullname, path=None):\n",
64 "def find_notebook(fullname, path=None):\n",
65 " \"\"\"find a notebook, given its fully qualified name and an optional path\n",
65 " \"\"\"find a notebook, given its fully qualified name and an optional path\n",
66 " \n",
66 " \n",
67 " This turns \"foo.bar\" into \"foo/bar.ipynb\"\n",
67 " This turns \"foo.bar\" into \"foo/bar.ipynb\"\n",
68 " and tries turning \"Foo_Bar\" into \"Foo Bar\" if Foo_Bar\n",
68 " and tries turning \"Foo_Bar\" into \"Foo Bar\" if Foo_Bar\n",
69 " does not exist.\n",
69 " does not exist.\n",
70 " \"\"\"\n",
70 " \"\"\"\n",
71 " name = fullname.rsplit('.', 1)[-1]\n",
71 " name = fullname.rsplit('.', 1)[-1]\n",
72 " if not path:\n",
72 " if not path:\n",
73 " path = ['']\n",
73 " path = ['']\n",
74 " for d in path:\n",
74 " for d in path:\n",
75 " nb_path = os.path.join(d, name + \".ipynb\")\n",
75 " nb_path = os.path.join(d, name + \".ipynb\")\n",
76 " if os.path.isfile(nb_path):\n",
76 " if os.path.isfile(nb_path):\n",
77 " return nb_path\n",
77 " return nb_path\n",
78 " # let import Notebook_Name find \"Notebook Name.ipynb\"\n",
78 " # let import Notebook_Name find \"Notebook Name.ipynb\"\n",
79 " nb_path = nb_path.replace(\"_\", \" \")\n",
79 " nb_path = nb_path.replace(\"_\", \" \")\n",
80 " if os.path.isfile(nb_path):\n",
80 " if os.path.isfile(nb_path):\n",
81 " return nb_path\n",
81 " return nb_path\n",
82 " "
82 " "
83 ]
83 ]
84 },
84 },
85 {
85 {
86 "cell_type": "markdown",
86 "cell_type": "markdown",
87 "metadata": {},
87 "metadata": {},
88 "source": [
88 "source": [
89 "## Notebook Loader"
89 "## Notebook Loader"
90 ]
90 ]
91 },
91 },
92 {
92 {
93 "cell_type": "markdown",
93 "cell_type": "markdown",
94 "metadata": {},
94 "metadata": {},
95 "source": [
95 "source": [
96 "Here we have our Notebook Loader.\n",
96 "Here we have our Notebook Loader.\n",
97 "It's actually quite simple - once we figure out the filename of the module,\n",
97 "It's actually quite simple - once we figure out the filename of the module,\n",
98 "all it does is:\n",
98 "all it does is:\n",
99 "\n",
99 "\n",
100 "1. load the notebook document into memory\n",
100 "1. load the notebook document into memory\n",
101 "2. create an empty Module\n",
101 "2. create an empty Module\n",
102 "3. execute every cell in the Module namespace\n",
102 "3. execute every cell in the Module namespace\n",
103 "\n",
103 "\n",
104 "Since IPython cells can have extended syntax,\n",
104 "Since IPython cells can have extended syntax,\n",
105 "the IPython transform is applied to turn each of these cells into their pure-Python counterparts before executing them.\n",
105 "the IPython transform is applied to turn each of these cells into their pure-Python counterparts before executing them.\n",
106 "If all of your notebook cells are pure-Python,\n",
106 "If all of your notebook cells are pure-Python,\n",
107 "this step is unnecessary."
107 "this step is unnecessary."
108 ]
108 ]
109 },
109 },
110 {
110 {
111 "cell_type": "code",
111 "cell_type": "code",
112 "execution_count": 4,
112 "execution_count": null,
113 "metadata": {
113 "metadata": {
114 "collapsed": false
114 "collapsed": false
115 },
115 },
116 "outputs": [],
116 "outputs": [],
117 "source": [
117 "source": [
118 "class NotebookLoader(object):\n",
118 "class NotebookLoader(object):\n",
119 " \"\"\"Module Loader for IPython Notebooks\"\"\"\n",
119 " \"\"\"Module Loader for IPython Notebooks\"\"\"\n",
120 " def __init__(self, path=None):\n",
120 " def __init__(self, path=None):\n",
121 " self.shell = InteractiveShell.instance()\n",
121 " self.shell = InteractiveShell.instance()\n",
122 " self.path = path\n",
122 " self.path = path\n",
123 " \n",
123 " \n",
124 " def load_module(self, fullname):\n",
124 " def load_module(self, fullname):\n",
125 " \"\"\"import a notebook as a module\"\"\"\n",
125 " \"\"\"import a notebook as a module\"\"\"\n",
126 " path = find_notebook(fullname, self.path)\n",
126 " path = find_notebook(fullname, self.path)\n",
127 " \n",
127 " \n",
128 " print (\"importing IPython notebook from %s\" % path)\n",
128 " print (\"importing IPython notebook from %s\" % path)\n",
129 " \n",
129 " \n",
130 " # load the notebook object\n",
130 " # load the notebook object\n",
131 " with io.open(path, 'r', encoding='utf-8') as f:\n",
131 " with io.open(path, 'r', encoding='utf-8') as f:\n",
132 " nb = current.read(f, 'json')\n",
132 " nb = current.read(f, 'json')\n",
133 " \n",
133 " \n",
134 " \n",
134 " \n",
135 " # create the module and add it to sys.modules\n",
135 " # create the module and add it to sys.modules\n",
136 " # if name in sys.modules:\n",
136 " # if name in sys.modules:\n",
137 " # return sys.modules[name]\n",
137 " # return sys.modules[name]\n",
138 " mod = types.ModuleType(fullname)\n",
138 " mod = types.ModuleType(fullname)\n",
139 " mod.__file__ = path\n",
139 " mod.__file__ = path\n",
140 " mod.__loader__ = self\n",
140 " mod.__loader__ = self\n",
141 " sys.modules[fullname] = mod\n",
141 " sys.modules[fullname] = mod\n",
142 " \n",
142 " \n",
143 " # extra work to ensure that magics that would affect the user_ns\n",
143 " # extra work to ensure that magics that would affect the user_ns\n",
144 " # actually affect the notebook module's ns\n",
144 " # actually affect the notebook module's ns\n",
145 " save_user_ns = self.shell.user_ns\n",
145 " save_user_ns = self.shell.user_ns\n",
146 " self.shell.user_ns = mod.__dict__\n",
146 " self.shell.user_ns = mod.__dict__\n",
147 " \n",
147 " \n",
148 " try:\n",
148 " try:\n",
149 " for cell in nb.worksheets[0].cells:\n",
149 " for cell in nb.worksheets[0].cells:\n",
150 " if cell.cell_type == 'code' and cell.language == 'python':\n",
150 " if cell.cell_type == 'code' and cell.language == 'python':\n",
151 " # transform the input to executable Python\n",
151 " # transform the input to executable Python\n",
152 " code = self.shell.input_transformer_manager.transform_cell(cell.input)\n",
152 " code = self.shell.input_transformer_manager.transform_cell(cell.input)\n",
153 " # run the code in themodule\n",
153 " # run the code in themodule\n",
154 " exec(code, mod.__dict__)\n",
154 " exec(code, mod.__dict__)\n",
155 " finally:\n",
155 " finally:\n",
156 " self.shell.user_ns = save_user_ns\n",
156 " self.shell.user_ns = save_user_ns\n",
157 " return mod\n"
157 " return mod\n"
158 ]
158 ]
159 },
159 },
160 {
160 {
161 "cell_type": "markdown",
161 "cell_type": "markdown",
162 "metadata": {},
162 "metadata": {},
163 "source": [
163 "source": [
164 "## The Module Finder"
164 "## The Module Finder"
165 ]
165 ]
166 },
166 },
167 {
167 {
168 "cell_type": "markdown",
168 "cell_type": "markdown",
169 "metadata": {},
169 "metadata": {},
170 "source": [
170 "source": [
171 "The finder is a simple object that tells you whether a name can be imported,\n",
171 "The finder is a simple object that tells you whether a name can be imported,\n",
172 "and returns the appropriate loader.\n",
172 "and returns the appropriate loader.\n",
173 "All this one does is check, when you do:\n",
173 "All this one does is check, when you do:\n",
174 "\n",
174 "\n",
175 "```python\n",
175 "```python\n",
176 "import mynotebook\n",
176 "import mynotebook\n",
177 "```\n",
177 "```\n",
178 "\n",
178 "\n",
179 "it checks whether `mynotebook.ipynb` exists.\n",
179 "it checks whether `mynotebook.ipynb` exists.\n",
180 "If a notebook is found, then it returns a NotebookLoader.\n",
180 "If a notebook is found, then it returns a NotebookLoader.\n",
181 "\n",
181 "\n",
182 "Any extra logic is just for resolving paths within packages."
182 "Any extra logic is just for resolving paths within packages."
183 ]
183 ]
184 },
184 },
185 {
185 {
186 "cell_type": "code",
186 "cell_type": "code",
187 "execution_count": 5,
187 "execution_count": null,
188 "metadata": {
188 "metadata": {
189 "collapsed": false
189 "collapsed": false
190 },
190 },
191 "outputs": [],
191 "outputs": [],
192 "source": [
192 "source": [
193 "class NotebookFinder(object):\n",
193 "class NotebookFinder(object):\n",
194 " \"\"\"Module finder that locates IPython Notebooks\"\"\"\n",
194 " \"\"\"Module finder that locates IPython Notebooks\"\"\"\n",
195 " def __init__(self):\n",
195 " def __init__(self):\n",
196 " self.loaders = {}\n",
196 " self.loaders = {}\n",
197 " \n",
197 " \n",
198 " def find_module(self, fullname, path=None):\n",
198 " def find_module(self, fullname, path=None):\n",
199 " nb_path = find_notebook(fullname, path)\n",
199 " nb_path = find_notebook(fullname, path)\n",
200 " if not nb_path:\n",
200 " if not nb_path:\n",
201 " return\n",
201 " return\n",
202 " \n",
202 " \n",
203 " key = path\n",
203 " key = path\n",
204 " if path:\n",
204 " if path:\n",
205 " # lists aren't hashable\n",
205 " # lists aren't hashable\n",
206 " key = os.path.sep.join(path)\n",
206 " key = os.path.sep.join(path)\n",
207 " \n",
207 " \n",
208 " if key not in self.loaders:\n",
208 " if key not in self.loaders:\n",
209 " self.loaders[key] = NotebookLoader(path)\n",
209 " self.loaders[key] = NotebookLoader(path)\n",
210 " return self.loaders[key]\n"
210 " return self.loaders[key]\n"
211 ]
211 ]
212 },
212 },
213 {
213 {
214 "cell_type": "markdown",
214 "cell_type": "markdown",
215 "metadata": {},
215 "metadata": {},
216 "source": [
216 "source": [
217 "## Register the hook"
217 "## Register the hook"
218 ]
218 ]
219 },
219 },
220 {
220 {
221 "cell_type": "markdown",
221 "cell_type": "markdown",
222 "metadata": {},
222 "metadata": {},
223 "source": [
223 "source": [
224 "Now we register the `NotebookFinder` with `sys.meta_path`"
224 "Now we register the `NotebookFinder` with `sys.meta_path`"
225 ]
225 ]
226 },
226 },
227 {
227 {
228 "cell_type": "code",
228 "cell_type": "code",
229 "execution_count": 6,
229 "execution_count": null,
230 "metadata": {
230 "metadata": {
231 "collapsed": false
231 "collapsed": false
232 },
232 },
233 "outputs": [],
233 "outputs": [],
234 "source": [
234 "source": [
235 "sys.meta_path.append(NotebookFinder())"
235 "sys.meta_path.append(NotebookFinder())"
236 ]
236 ]
237 },
237 },
238 {
238 {
239 "cell_type": "markdown",
239 "cell_type": "markdown",
240 "metadata": {},
240 "metadata": {},
241 "source": [
241 "source": [
242 "After this point, my notebooks should be importable.\n",
242 "After this point, my notebooks should be importable.\n",
243 "\n",
243 "\n",
244 "Let's look at what we have in the CWD:"
244 "Let's look at what we have in the CWD:"
245 ]
245 ]
246 },
246 },
247 {
247 {
248 "cell_type": "code",
248 "cell_type": "code",
249 "execution_count": 7,
249 "execution_count": null,
250 "metadata": {
250 "metadata": {
251 "collapsed": false
251 "collapsed": false
252 },
252 },
253 "outputs": [
253 "outputs": [],
254 {
255 "name": "stdout",
256 "output_type": "stream",
257 "text": [
258 "__init__.py mynotebook.ipynb \u001b[34mnbs\u001b[m\u001b[m/\r\n"
259 ]
260 }
261 ],
262 "source": [
254 "source": [
263 "ls nbpackage"
255 "ls nbpackage"
264 ]
256 ]
265 },
257 },
266 {
258 {
267 "cell_type": "markdown",
259 "cell_type": "markdown",
268 "metadata": {},
260 "metadata": {},
269 "source": [
261 "source": [
270 "So I should be able to `import nbimp.mynotebook`.\n"
262 "So I should be able to `import nbimp.mynotebook`.\n"
271 ]
263 ]
272 },
264 },
273 {
265 {
274 "cell_type": "markdown",
266 "cell_type": "markdown",
275 "metadata": {},
267 "metadata": {},
276 "source": [
268 "source": [
277 "### Aside: displaying notebooks"
269 "### Aside: displaying notebooks"
278 ]
270 ]
279 },
271 },
280 {
272 {
281 "cell_type": "markdown",
273 "cell_type": "markdown",
282 "metadata": {},
274 "metadata": {},
283 "source": [
275 "source": [
284 "Here is some simple code to display the contents of a notebook\n",
276 "Here is some simple code to display the contents of a notebook\n",
285 "with syntax highlighting, etc."
277 "with syntax highlighting, etc."
286 ]
278 ]
287 },
279 },
288 {
280 {
289 "cell_type": "code",
281 "cell_type": "code",
290 "execution_count": 8,
282 "execution_count": null,
291 "metadata": {
283 "metadata": {
292 "collapsed": false
284 "collapsed": false
293 },
285 },
294 "outputs": [
286 "outputs": [],
295 {
296 "data": {
297 "text/html": [
298 "\n",
299 "<style type='text/css'>\n",
300 ".hll { background-color: #ffffcc }\n",
301 ".c { color: #408080; font-style: italic } /* Comment */\n",
302 ".err { border: 1px solid #FF0000 } /* Error */\n",
303 ".k { color: #008000; font-weight: bold } /* Keyword */\n",
304 ".o { color: #666666 } /* Operator */\n",
305 ".cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
306 ".cp { color: #BC7A00 } /* Comment.Preproc */\n",
307 ".c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
308 ".cs { color: #408080; font-style: italic } /* Comment.Special */\n",
309 ".gd { color: #A00000 } /* Generic.Deleted */\n",
310 ".ge { font-style: italic } /* Generic.Emph */\n",
311 ".gr { color: #FF0000 } /* Generic.Error */\n",
312 ".gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
313 ".gi { color: #00A000 } /* Generic.Inserted */\n",
314 ".go { color: #888888 } /* Generic.Output */\n",
315 ".gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
316 ".gs { font-weight: bold } /* Generic.Strong */\n",
317 ".gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
318 ".gt { color: #0044DD } /* Generic.Traceback */\n",
319 ".kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
320 ".kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
321 ".kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
322 ".kp { color: #008000 } /* Keyword.Pseudo */\n",
323 ".kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
324 ".kt { color: #B00040 } /* Keyword.Type */\n",
325 ".m { color: #666666 } /* Literal.Number */\n",
326 ".s { color: #BA2121 } /* Literal.String */\n",
327 ".na { color: #7D9029 } /* Name.Attribute */\n",
328 ".nb { color: #008000 } /* Name.Builtin */\n",
329 ".nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
330 ".no { color: #880000 } /* Name.Constant */\n",
331 ".nd { color: #AA22FF } /* Name.Decorator */\n",
332 ".ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
333 ".ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
334 ".nf { color: #0000FF } /* Name.Function */\n",
335 ".nl { color: #A0A000 } /* Name.Label */\n",
336 ".nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
337 ".nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
338 ".nv { color: #19177C } /* Name.Variable */\n",
339 ".ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
340 ".w { color: #bbbbbb } /* Text.Whitespace */\n",
341 ".mf { color: #666666 } /* Literal.Number.Float */\n",
342 ".mh { color: #666666 } /* Literal.Number.Hex */\n",
343 ".mi { color: #666666 } /* Literal.Number.Integer */\n",
344 ".mo { color: #666666 } /* Literal.Number.Oct */\n",
345 ".sb { color: #BA2121 } /* Literal.String.Backtick */\n",
346 ".sc { color: #BA2121 } /* Literal.String.Char */\n",
347 ".sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
348 ".s2 { color: #BA2121 } /* Literal.String.Double */\n",
349 ".se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
350 ".sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
351 ".si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
352 ".sx { color: #008000 } /* Literal.String.Other */\n",
353 ".sr { color: #BB6688 } /* Literal.String.Regex */\n",
354 ".s1 { color: #BA2121 } /* Literal.String.Single */\n",
355 ".ss { color: #19177C } /* Literal.String.Symbol */\n",
356 ".bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
357 ".vc { color: #19177C } /* Name.Variable.Class */\n",
358 ".vg { color: #19177C } /* Name.Variable.Global */\n",
359 ".vi { color: #19177C } /* Name.Variable.Instance */\n",
360 ".il { color: #666666 } /* Literal.Number.Integer.Long */\n",
361 "</style>\n"
362 ],
363 "text/plain": [
364 "<IPython.core.display.HTML at 0x1072303d0>"
365 ]
366 },
367 "metadata": {},
368 "output_type": "display_data"
369 }
370 ],
371 "source": [
287 "source": [
372 "from pygments import highlight\n",
288 "from pygments import highlight\n",
373 "from pygments.lexers import PythonLexer\n",
289 "from pygments.lexers import PythonLexer\n",
374 "from pygments.formatters import HtmlFormatter\n",
290 "from pygments.formatters import HtmlFormatter\n",
375 "\n",
291 "\n",
376 "from IPython.display import display, HTML\n",
292 "from IPython.display import display, HTML\n",
377 "\n",
293 "\n",
378 "formatter = HtmlFormatter()\n",
294 "formatter = HtmlFormatter()\n",
379 "lexer = PythonLexer()\n",
295 "lexer = PythonLexer()\n",
380 "\n",
296 "\n",
381 "# publish the CSS for pygments highlighting\n",
297 "# publish the CSS for pygments highlighting\n",
382 "display(HTML(\"\"\"\n",
298 "display(HTML(\"\"\"\n",
383 "<style type='text/css'>\n",
299 "<style type='text/css'>\n",
384 "%s\n",
300 "%s\n",
385 "</style>\n",
301 "</style>\n",
386 "\"\"\" % formatter.get_style_defs()\n",
302 "\"\"\" % formatter.get_style_defs()\n",
387 "))"
303 "))"
388 ]
304 ]
389 },
305 },
390 {
306 {
391 "cell_type": "code",
307 "cell_type": "code",
392 "execution_count": 10,
308 "execution_count": null,
393 "metadata": {
309 "metadata": {
394 "collapsed": false
310 "collapsed": false
395 },
311 },
396 "outputs": [
312 "outputs": [],
397 {
398 "data": {
399 "text/html": [
400 "<h4>heading cell</h4>\n",
401 "<pre>My Notebook</pre>\n",
402 "<h4>code cell</h4>\n",
403 "<div class=\"highlight\"><pre><span class=\"k\">def</span> <span class=\"nf\">foo</span><span class=\"p\">():</span>\n",
404 " <span class=\"k\">return</span> <span class=\"s\">&quot;foo&quot;</span>\n",
405 "</pre></div>\n",
406 "\n",
407 "<h4>code cell</h4>\n",
408 "<div class=\"highlight\"><pre><span class=\"k\">def</span> <span class=\"nf\">has_ip_syntax</span><span class=\"p\">():</span>\n",
409 " <span class=\"n\">listing</span> <span class=\"o\">=</span> <span class=\"err\">!</span><span class=\"n\">ls</span>\n",
410 " <span class=\"k\">return</span> <span class=\"n\">listing</span>\n",
411 "</pre></div>\n",
412 "\n",
413 "<h4>code cell</h4>\n",
414 "<div class=\"highlight\"><pre><span class=\"k\">def</span> <span class=\"nf\">whatsmyname</span><span class=\"p\">():</span>\n",
415 " <span class=\"k\">return</span> <span class=\"n\">__name__</span>\n",
416 "</pre></div>\n"
417 ],
418 "text/plain": [
419 "<IPython.core.display.HTML at 0x10775a150>"
420 ]
421 },
422 "metadata": {},
423 "output_type": "display_data"
424 }
425 ],
426 "source": [
313 "source": [
427 "def show_notebook(fname):\n",
314 "def show_notebook(fname):\n",
428 " \"\"\"display a short summary of the cells of a notebook\"\"\"\n",
315 " \"\"\"display a short summary of the cells of a notebook\"\"\"\n",
429 " with io.open(fname, 'r', encoding='utf-8') as f:\n",
316 " with io.open(fname, 'r', encoding='utf-8') as f:\n",
430 " nb = current.read(f, 'json')\n",
317 " nb = current.read(f, 'json')\n",
431 " html = []\n",
318 " html = []\n",
432 " for cell in nb.worksheets[0].cells:\n",
319 " for cell in nb.worksheets[0].cells:\n",
433 " html.append(\"<h4>%s cell</h4>\" % cell.cell_type)\n",
320 " html.append(\"<h4>%s cell</h4>\" % cell.cell_type)\n",
434 " if cell.cell_type == 'code':\n",
321 " if cell.cell_type == 'code':\n",
435 " html.append(highlight(cell.input, lexer, formatter))\n",
322 " html.append(highlight(cell.input, lexer, formatter))\n",
436 " else:\n",
323 " else:\n",
437 " html.append(\"<pre>%s</pre>\" % cell.source)\n",
324 " html.append(\"<pre>%s</pre>\" % cell.source)\n",
438 " display(HTML('\\n'.join(html)))\n",
325 " display(HTML('\\n'.join(html)))\n",
439 "\n",
326 "\n",
440 "show_notebook(os.path.join(\"nbpackage\", \"mynotebook.ipynb\"))"
327 "show_notebook(os.path.join(\"nbpackage\", \"mynotebook.ipynb\"))"
441 ]
328 ]
442 },
329 },
443 {
330 {
444 "cell_type": "markdown",
331 "cell_type": "markdown",
445 "metadata": {},
332 "metadata": {},
446 "source": [
333 "source": [
447 "So my notebook has a heading cell and some code cells,\n",
334 "So my notebook has a heading cell and some code cells,\n",
448 "one of which contains some IPython syntax.\n",
335 "one of which contains some IPython syntax.\n",
449 "\n",
336 "\n",
450 "Let's see what happens when we import it"
337 "Let's see what happens when we import it"
451 ]
338 ]
452 },
339 },
453 {
340 {
454 "cell_type": "code",
341 "cell_type": "code",
455 "execution_count": 11,
342 "execution_count": null,
456 "metadata": {
343 "metadata": {
457 "collapsed": false
344 "collapsed": false
458 },
345 },
459 "outputs": [
346 "outputs": [],
460 {
461 "name": "stdout",
462 "output_type": "stream",
463 "text": [
464 "importing IPython notebook from nbpackage/mynotebook.ipynb\n"
465 ]
466 }
467 ],
468 "source": [
347 "source": [
469 "from nbpackage import mynotebook"
348 "from nbpackage import mynotebook"
470 ]
349 ]
471 },
350 },
472 {
351 {
473 "cell_type": "markdown",
352 "cell_type": "markdown",
474 "metadata": {},
353 "metadata": {},
475 "source": [
354 "source": [
476 "Hooray, it imported! Does it work?"
355 "Hooray, it imported! Does it work?"
477 ]
356 ]
478 },
357 },
479 {
358 {
480 "cell_type": "code",
359 "cell_type": "code",
481 "execution_count": 12,
360 "execution_count": null,
482 "metadata": {
361 "metadata": {
483 "collapsed": false
362 "collapsed": false
484 },
363 },
485 "outputs": [
364 "outputs": [],
486 {
487 "data": {
488 "text/plain": [
489 "'foo'"
490 ]
491 },
492 "execution_count": 12,
493 "metadata": {},
494 "output_type": "execute_result"
495 }
496 ],
497 "source": [
365 "source": [
498 "mynotebook.foo()"
366 "mynotebook.foo()"
499 ]
367 ]
500 },
368 },
501 {
369 {
502 "cell_type": "markdown",
370 "cell_type": "markdown",
503 "metadata": {},
371 "metadata": {},
504 "source": [
372 "source": [
505 "Hooray again!\n",
373 "Hooray again!\n",
506 "\n",
374 "\n",
507 "Even the function that contains IPython syntax works:"
375 "Even the function that contains IPython syntax works:"
508 ]
376 ]
509 },
377 },
510 {
378 {
511 "cell_type": "code",
379 "cell_type": "code",
512 "execution_count": 13,
380 "execution_count": null,
513 "metadata": {
381 "metadata": {
514 "collapsed": false
382 "collapsed": false
515 },
383 },
516 "outputs": [
384 "outputs": [],
517 {
518 "data": {
519 "text/plain": [
520 "['Animations Using clear_output.ipynb',\n",
521 " 'Connecting with the Qt Console.ipynb',\n",
522 " 'Importing Notebooks.ipynb',\n",
523 " 'Progress Bars.ipynb',\n",
524 " 'Raw Input.ipynb',\n",
525 " 'SymPy.ipynb',\n",
526 " 'Trapezoid Rule.ipynb',\n",
527 " 'nbpackage']"
528 ]
529 },
530 "execution_count": 13,
531 "metadata": {},
532 "output_type": "execute_result"
533 }
534 ],
535 "source": [
385 "source": [
536 "mynotebook.has_ip_syntax()"
386 "mynotebook.has_ip_syntax()"
537 ]
387 ]
538 },
388 },
539 {
389 {
540 "cell_type": "markdown",
390 "cell_type": "markdown",
541 "metadata": {},
391 "metadata": {},
542 "source": [
392 "source": [
543 "## Notebooks in packages"
393 "## Notebooks in packages"
544 ]
394 ]
545 },
395 },
546 {
396 {
547 "cell_type": "markdown",
397 "cell_type": "markdown",
548 "metadata": {},
398 "metadata": {},
549 "source": [
399 "source": [
550 "We also have a notebook inside the `nb` package,\n",
400 "We also have a notebook inside the `nb` package,\n",
551 "so let's make sure that works as well."
401 "so let's make sure that works as well."
552 ]
402 ]
553 },
403 },
554 {
404 {
555 "cell_type": "code",
405 "cell_type": "code",
556 "execution_count": 14,
406 "execution_count": null,
557 "metadata": {
407 "metadata": {
558 "collapsed": false
408 "collapsed": false
559 },
409 },
560 "outputs": [
410 "outputs": [],
561 {
562 "name": "stdout",
563 "output_type": "stream",
564 "text": [
565 "__init__.py other.ipynb\r\n"
566 ]
567 }
568 ],
569 "source": [
411 "source": [
570 "ls nbpackage/nbs"
412 "ls nbpackage/nbs"
571 ]
413 ]
572 },
414 },
573 {
415 {
574 "cell_type": "markdown",
416 "cell_type": "markdown",
575 "metadata": {},
417 "metadata": {},
576 "source": [
418 "source": [
577 "Note that the `__init__.py` is necessary for `nb` to be considered a package,\n",
419 "Note that the `__init__.py` is necessary for `nb` to be considered a package,\n",
578 "just like usual."
420 "just like usual."
579 ]
421 ]
580 },
422 },
581 {
423 {
582 "cell_type": "code",
424 "cell_type": "code",
583 "execution_count": 15,
425 "execution_count": null,
584 "metadata": {
426 "metadata": {
585 "collapsed": false
427 "collapsed": false
586 },
428 },
587 "outputs": [
429 "outputs": [],
588 {
589 "data": {
590 "text/html": [
591 "<h4>markdown cell</h4>\n",
592 "<pre>This notebook just defines `bar`</pre>\n",
593 "<h4>code cell</h4>\n",
594 "<div class=\"highlight\"><pre><span class=\"k\">def</span> <span class=\"nf\">bar</span><span class=\"p\">(</span><span class=\"n\">x</span><span class=\"p\">):</span>\n",
595 " <span class=\"k\">return</span> <span class=\"s\">&quot;bar&quot;</span> <span class=\"o\">*</span> <span class=\"n\">x</span>\n",
596 "</pre></div>\n"
597 ],
598 "text/plain": [
599 "<IPython.core.display.HTML at 0x10775a250>"
600 ]
601 },
602 "metadata": {},
603 "output_type": "display_data"
604 }
605 ],
606 "source": [
430 "source": [
607 "show_notebook(os.path.join(\"nbpackage\", \"nbs\", \"other.ipynb\"))"
431 "show_notebook(os.path.join(\"nbpackage\", \"nbs\", \"other.ipynb\"))"
608 ]
432 ]
609 },
433 },
610 {
434 {
611 "cell_type": "code",
435 "cell_type": "code",
612 "execution_count": 16,
436 "execution_count": null,
613 "metadata": {
437 "metadata": {
614 "collapsed": false
438 "collapsed": false
615 },
439 },
616 "outputs": [
440 "outputs": [],
617 {
618 "name": "stdout",
619 "output_type": "stream",
620 "text": [
621 "importing IPython notebook from nbpackage/nbs/other.ipynb\n"
622 ]
623 },
624 {
625 "data": {
626 "text/plain": [
627 "'barbarbarbarbar'"
628 ]
629 },
630 "execution_count": 16,
631 "metadata": {},
632 "output_type": "execute_result"
633 }
634 ],
635 "source": [
441 "source": [
636 "from nbpackage.nbs import other\n",
442 "from nbpackage.nbs import other\n",
637 "other.bar(5)"
443 "other.bar(5)"
638 ]
444 ]
639 },
445 },
640 {
446 {
641 "cell_type": "markdown",
447 "cell_type": "markdown",
642 "metadata": {},
448 "metadata": {},
643 "source": [
449 "source": [
644 "So now we have importable notebooks, from both the local directory and inside packages.\n",
450 "So now we have importable notebooks, from both the local directory and inside packages.\n",
645 "\n",
451 "\n",
646 "I can even put a notebook inside IPython, to further demonstrate that this is working properly:"
452 "I can even put a notebook inside IPython, to further demonstrate that this is working properly:"
647 ]
453 ]
648 },
454 },
649 {
455 {
650 "cell_type": "code",
456 "cell_type": "code",
651 "execution_count": 17,
457 "execution_count": null,
652 "metadata": {
458 "metadata": {
653 "collapsed": false
459 "collapsed": false
654 },
460 },
655 "outputs": [],
461 "outputs": [],
656 "source": [
462 "source": [
657 "import shutil\n",
463 "import shutil\n",
658 "from IPython.utils.path import get_ipython_package_dir\n",
464 "from IPython.utils.path import get_ipython_package_dir\n",
659 "\n",
465 "\n",
660 "utils = os.path.join(get_ipython_package_dir(), 'utils')\n",
466 "utils = os.path.join(get_ipython_package_dir(), 'utils')\n",
661 "shutil.copy(os.path.join(\"nbpackage\", \"mynotebook.ipynb\"),\n",
467 "shutil.copy(os.path.join(\"nbpackage\", \"mynotebook.ipynb\"),\n",
662 " os.path.join(utils, \"inside_ipython.ipynb\")\n",
468 " os.path.join(utils, \"inside_ipython.ipynb\")\n",
663 ")"
469 ")"
664 ]
470 ]
665 },
471 },
666 {
472 {
667 "cell_type": "markdown",
473 "cell_type": "markdown",
668 "metadata": {},
474 "metadata": {},
669 "source": [
475 "source": [
670 "and import the notebook from `IPython.utils`"
476 "and import the notebook from `IPython.utils`"
671 ]
477 ]
672 },
478 },
673 {
479 {
674 "cell_type": "code",
480 "cell_type": "code",
675 "execution_count": 18,
481 "execution_count": null,
676 "metadata": {
482 "metadata": {
677 "collapsed": false
483 "collapsed": false
678 },
484 },
679 "outputs": [
485 "outputs": [],
680 {
681 "name": "stdout",
682 "output_type": "stream",
683 "text": [
684 "importing IPython notebook from /Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/utils/inside_ipython.ipynb\n"
685 ]
686 },
687 {
688 "data": {
689 "text/plain": [
690 "'IPython.utils.inside_ipython'"
691 ]
692 },
693 "execution_count": 18,
694 "metadata": {},
695 "output_type": "execute_result"
696 }
697 ],
698 "source": [
486 "source": [
699 "from IPython.utils import inside_ipython\n",
487 "from IPython.utils import inside_ipython\n",
700 "inside_ipython.whatsmyname()"
488 "inside_ipython.whatsmyname()"
701 ]
489 ]
702 },
490 },
703 {
491 {
704 "cell_type": "markdown",
492 "cell_type": "markdown",
705 "metadata": {},
493 "metadata": {},
706 "source": [
494 "source": [
707 "This approach can even import functions and classes that are defined in a notebook using the `%%cython` magic."
495 "This approach can even import functions and classes that are defined in a notebook using the `%%cython` magic."
708 ]
496 ]
709 }
497 }
710 ],
498 ],
711 "metadata": {
499 "metadata": {
712 "gist_id": "6011986",
500 "gist_id": "6011986",
713 "kernelspec": {
501 "kernelspec": {
714 "display_name": "Python 3",
502 "display_name": "Python 3",
715 "language": "python",
503 "language": "python",
716 "name": "python3"
504 "name": "python3"
717 },
505 },
718 "language_info": {
506 "language_info": {
719 "codemirror_mode": {
507 "codemirror_mode": {
720 "name": "ipython",
508 "name": "ipython",
721 "version": 3
509 "version": 3
722 },
510 },
723 "file_extension": ".py",
511 "file_extension": ".py",
724 "mimetype": "text/x-python",
512 "mimetype": "text/x-python",
725 "name": "python",
513 "name": "python",
726 "nbconvert_exporter": "python",
514 "nbconvert_exporter": "python",
727 "pygments_lexer": "ipython3",
515 "pygments_lexer": "ipython3",
728 "version": "3.4.2"
516 "version": "3.4.3"
729 }
517 }
730 },
518 },
731 "nbformat": 4,
519 "nbformat": 4,
732 "nbformat_minor": 0
520 "nbformat_minor": 0
733 }
521 }
@@ -1,92 +1,91 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "<img src=\"../images/ipython_logo.png\">"
7 "<img src=\"../images/ipython_logo.png\">"
8 ]
8 ]
9 },
9 },
10 {
10 {
11 "cell_type": "markdown",
11 "cell_type": "markdown",
12 "metadata": {},
12 "metadata": {},
13 "source": [
13 "source": [
14 "Back to the main [Index](../Index.ipynb)"
14 "Back to the main [Index](../Index.ipynb)"
15 ]
15 ]
16 },
16 },
17 {
17 {
18 "cell_type": "markdown",
18 "cell_type": "markdown",
19 "metadata": {},
19 "metadata": {},
20 "source": [
20 "source": [
21 "# Notebook"
21 "# Notebook"
22 ]
22 ]
23 },
23 },
24 {
24 {
25 "cell_type": "markdown",
25 "cell_type": "markdown",
26 "metadata": {},
26 "metadata": {},
27 "source": [
27 "source": [
28 "The IPython Notebook is a web-based interactive computing system that enables users to author documents that include live code, narrative text, LaTeX equations, HTML, images and video. These documents contain a full record of a computation and its results and can be shared on email, [Dropbox](http://dropbox.com), version control systems (like git/[GitHub](http://github.com)) or [nbviewer.ipython.org](http://nbviewer.ipython.org)."
28 "The IPython Notebook is a web-based interactive computing system that enables users to author documents that include live code, narrative text, LaTeX equations, HTML, images and video. These documents contain a full record of a computation and its results and can be shared on email, [Dropbox](http://dropbox.com), version control systems (like git/[GitHub](http://github.com)) or [nbviewer.ipython.org](http://nbviewer.ipython.org)."
29 ]
29 ]
30 },
30 },
31 {
31 {
32 "cell_type": "markdown",
32 "cell_type": "markdown",
33 "metadata": {},
33 "metadata": {},
34 "source": [
34 "source": [
35 "## Tutorials"
35 "## Tutorials"
36 ]
36 ]
37 },
37 },
38 {
38 {
39 "cell_type": "markdown",
39 "cell_type": "markdown",
40 "metadata": {},
40 "metadata": {},
41 "source": [
41 "source": [
42 "* [What is the IPython Notebook](What is the IPython Notebook.ipynb)\n",
42 "* [What is the IPython Notebook](What is the IPython Notebook.ipynb)\n",
43 "* [Running the Notebook Server](Running the Notebook Server.ipynb)\n",
44 "* [Notebook Basics](Notebook Basics.ipynb)\n",
43 "* [Notebook Basics](Notebook Basics.ipynb)\n",
45 "* [Running Code](Running Code.ipynb)\n",
44 "* [Running Code](Running Code.ipynb)\n",
46 "* [Working With Markdown Cells](Working With Markdown Cells.ipynb)\n",
45 "* [Working With Markdown Cells](Working With Markdown Cells.ipynb)\n",
46 "* [Configuring the Notebook and Server](Configuring the Notebook and Server.ipynb)\n",
47 "* [Custom Keyboard Shortcuts](Custom Keyboard Shortcuts.ipynb)\n",
47 "* [Custom Keyboard Shortcuts](Custom Keyboard Shortcuts.ipynb)\n",
48 "* [JavaScript Notebook Extensions](JavaScript Notebook Extensions.ipynb)\n",
48 "* [JavaScript Notebook Extensions](JavaScript Notebook Extensions.ipynb)\n",
49 "* [Notebook Security](Notebook Security.ipynb)\n",
50 "* [Converting Notebooks With nbconvert](Converting Notebooks With nbconvert.ipynb)\n",
49 "* [Converting Notebooks With nbconvert](Converting Notebooks With nbconvert.ipynb)\n",
51 "* [Using nbconvert as a Library](Using nbconvert as a Library.ipynb)"
50 "* [Using nbconvert as a Library](Using nbconvert as a Library.ipynb)"
52 ]
51 ]
53 },
52 },
54 {
53 {
55 "cell_type": "markdown",
54 "cell_type": "markdown",
56 "metadata": {},
55 "metadata": {},
57 "source": [
56 "source": [
58 "## Examples"
57 "## Examples"
59 ]
58 ]
60 },
59 },
61 {
60 {
62 "cell_type": "markdown",
61 "cell_type": "markdown",
63 "metadata": {},
62 "metadata": {},
64 "source": [
63 "source": [
65 "* [Importing Notebooks](Importing Notebooks.ipynb)\n",
64 "* [Importing Notebooks](Importing Notebooks.ipynb)\n",
66 "* [Connecting with the Qt Console](Connecting with the Qt Console.ipynb)\n",
65 "* [Connecting with the Qt Console](Connecting with the Qt Console.ipynb)\n",
67 "* [Typesetting Equations](Typesetting Equations.ipynb)"
66 "* [Typesetting Equations](Typesetting Equations.ipynb)"
68 ]
67 ]
69 }
68 }
70 ],
69 ],
71 "metadata": {
70 "metadata": {
72 "kernelspec": {
71 "kernelspec": {
73 "display_name": "Python 3",
72 "display_name": "Python 3",
74 "language": "python",
73 "language": "python",
75 "name": "python3"
74 "name": "python3"
76 },
75 },
77 "language_info": {
76 "language_info": {
78 "codemirror_mode": {
77 "codemirror_mode": {
79 "name": "ipython",
78 "name": "ipython",
80 "version": 3
79 "version": 3
81 },
80 },
82 "file_extension": ".py",
81 "file_extension": ".py",
83 "mimetype": "text/x-python",
82 "mimetype": "text/x-python",
84 "name": "python",
83 "name": "python",
85 "nbconvert_exporter": "python",
84 "nbconvert_exporter": "python",
86 "pygments_lexer": "ipython3",
85 "pygments_lexer": "ipython3",
87 "version": "3.4.2"
86 "version": "3.4.3"
88 }
87 }
89 },
88 },
90 "nbformat": 4,
89 "nbformat": 4,
91 "nbformat_minor": 0
90 "nbformat_minor": 0
92 }
91 }
@@ -1,773 +1,612 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "# Embrasing web standards"
7 "# Embrasing web standards"
8 ]
8 ]
9 },
9 },
10 {
10 {
11 "cell_type": "markdown",
11 "cell_type": "markdown",
12 "metadata": {},
12 "metadata": {},
13 "source": [
13 "source": [
14 "One of the main reason that allowed us to developp the current notebook web application \n",
14 "One of the main reason that allowed us to developp the current notebook web application \n",
15 "was to embrase the web technology. \n",
15 "was to embrase the web technology. \n",
16 "\n",
16 "\n",
17 "By beeing a pure web application using HTML, Javascript and CSS, the Notebook can get \n",
17 "By beeing a pure web application using HTML, Javascript and CSS, the Notebook can get \n",
18 "all the web technology improvement for free. Thus, as browsers support for different \n",
18 "all the web technology improvement for free. Thus, as browsers support for different \n",
19 "media extend, The notebook web app should be able to be compatible without modification. \n",
19 "media extend, The notebook web app should be able to be compatible without modification. \n",
20 "\n",
20 "\n",
21 "This is also true with performance of the User Interface as the speed of javascript VM increase. "
21 "This is also true with performance of the User Interface as the speed of javascript VM increase. "
22 ]
22 ]
23 },
23 },
24 {
24 {
25 "cell_type": "markdown",
25 "cell_type": "markdown",
26 "metadata": {},
26 "metadata": {},
27 "source": [
27 "source": [
28 "The other advantage of using only web technology is that the code of the interface is fully accessible to the end user, and modifiable live.\n",
28 "The other advantage of using only web technology is that the code of the interface is fully accessible to the end user, and modifiable live.\n",
29 "Even if this task is not always easy, we strive to keep our code as accessible and reusable as possible.\n",
29 "Even if this task is not always easy, we strive to keep our code as accessible and reusable as possible.\n",
30 "This should allow with minimum effort to develop small extensions that customize the behavior of the web interface. "
30 "This should allow with minimum effort to develop small extensions that customize the behavior of the web interface. "
31 ]
31 ]
32 },
32 },
33 {
33 {
34 "cell_type": "markdown",
34 "cell_type": "markdown",
35 "metadata": {},
35 "metadata": {},
36 "source": [
36 "source": [
37 "## Tempering with Notebook app"
37 "## Tempering with Notebook app"
38 ]
38 ]
39 },
39 },
40 {
40 {
41 "cell_type": "markdown",
41 "cell_type": "markdown",
42 "metadata": {},
42 "metadata": {},
43 "source": [
43 "source": [
44 "The first tool that is availlable to you and that you shoudl be aware of are browser \"developpers tool\". The exact naming can change across browser, and might require the installation of extensions. But basically they can allow you to inspect/modify the DOM, and interact with the javascript code that run the frontend.\n",
44 "The first tool that is availlable to you and that you shoudl be aware of are browser \"developpers tool\". The exact naming can change across browser, and might require the installation of extensions. But basically they can allow you to inspect/modify the DOM, and interact with the javascript code that run the frontend.\n",
45 "\n",
45 "\n",
46 " - In Chrome and safari Developper tools are in the menu [Put mmenu name in english here] \n",
46 " - In Chrome and safari Developper tools are in the menu [Put mmenu name in english here] \n",
47 " - In firefox you might need to install [Firebug](http://getfirebug.com/)\n",
47 " - In firefox you might need to install [Firebug](http://getfirebug.com/)\n",
48 " - others ?\n",
48 " - others ?\n",
49 " \n",
49 " \n",
50 "Those will be your best friends to debug and try different approach for your extensions."
50 "Those will be your best friends to debug and try different approach for your extensions."
51 ]
51 ]
52 },
52 },
53 {
53 {
54 "cell_type": "markdown",
54 "cell_type": "markdown",
55 "metadata": {},
55 "metadata": {},
56 "source": [
56 "source": [
57 "### Injecting JS"
57 "### Injecting JS"
58 ]
58 ]
59 },
59 },
60 {
60 {
61 "cell_type": "markdown",
61 "cell_type": "markdown",
62 "metadata": {},
62 "metadata": {},
63 "source": [
63 "source": [
64 "#### using magics"
64 "#### using magics"
65 ]
65 ]
66 },
66 },
67 {
67 {
68 "cell_type": "markdown",
68 "cell_type": "markdown",
69 "metadata": {},
69 "metadata": {},
70 "source": [
70 "source": [
71 "Above tools can be tedious to edit long javascipt files. Hopefully we provide the `%%javascript` magic. This allows you to quickly inject javascript into the notebook. Still the javascript injected this way will not survive reloading. Hence it is a good tool for testing an refinig a script.\n",
71 "Above tools can be tedious to edit long javascipt files. Hopefully we provide the `%%javascript` magic. This allows you to quickly inject javascript into the notebook. Still the javascript injected this way will not survive reloading. Hence it is a good tool for testing an refinig a script.\n",
72 "\n",
72 "\n",
73 "You might see here and there people modifying css and injecting js into notebook by reading file and publishing them into the notebook.\n",
73 "You might see here and there people modifying css and injecting js into notebook by reading file and publishing them into the notebook.\n",
74 "Not only this often break the flow of the notebook and make the re-execution of the notebook broken, but it also mean that you need to execute those cells on all the notebook every time you need to update the code.\n",
74 "Not only this often break the flow of the notebook and make the re-execution of the notebook broken, but it also mean that you need to execute those cells on all the notebook every time you need to update the code.\n",
75 "\n",
75 "\n",
76 "This can still be usefull in some cases, like the `%autosave` magic that allows to control the time between each save. But this can be replaced by a Javascript dropdown menu to select save interval."
76 "This can still be usefull in some cases, like the `%autosave` magic that allows to control the time between each save. But this can be replaced by a Javascript dropdown menu to select save interval."
77 ]
77 ]
78 },
78 },
79 {
79 {
80 "cell_type": "code",
80 "cell_type": "code",
81 "execution_count": null,
81 "execution_count": null,
82 "metadata": {
82 "metadata": {
83 "collapsed": false
83 "collapsed": false
84 },
84 },
85 "outputs": [],
85 "outputs": [],
86 "source": [
86 "source": [
87 "## you can inspect the autosave code to see what it does.\n",
87 "## you can inspect the autosave code to see what it does.\n",
88 "%autosave??"
88 "%autosave??"
89 ]
89 ]
90 },
90 },
91 {
91 {
92 "cell_type": "markdown",
92 "cell_type": "markdown",
93 "metadata": {},
93 "metadata": {},
94 "source": [
94 "source": [
95 "#### custom.js"
95 "#### custom.js"
96 ]
96 ]
97 },
97 },
98 {
98 {
99 "cell_type": "markdown",
99 "cell_type": "markdown",
100 "metadata": {},
100 "metadata": {},
101 "source": [
101 "source": [
102 "To inject Javascript we provide an entry point: `custom.js` that allow teh user to execute and load other resources into the notebook.\n",
102 "To inject Javascript we provide an entry point: `custom.js` that allow teh user to execute and load other resources into the notebook.\n",
103 "Javascript code in `custom.js` will be executed when the notebook app start and can then be used to customise almost anything in the UI and in the behavior of the notebook.\n",
103 "Javascript code in `custom.js` will be executed when the notebook app start and can then be used to customise almost anything in the UI and in the behavior of the notebook.\n",
104 "\n",
104 "\n",
105 "`custom.js` can be found in IPython profile dir, and so you can have different UI modification on a per profile basis, as well as share your modfication with others."
105 "`custom.js` can be found in IPython profile dir, and so you can have different UI modification on a per profile basis, as well as share your modfication with others."
106 ]
106 ]
107 },
107 },
108 {
108 {
109 "cell_type": "markdown",
109 "cell_type": "markdown",
110 "metadata": {},
110 "metadata": {},
111 "source": [
111 "source": [
112 "##### Because we like you...."
112 "##### Because we like you...."
113 ]
113 ]
114 },
114 },
115 {
115 {
116 "cell_type": "markdown",
116 "cell_type": "markdown",
117 "metadata": {},
117 "metadata": {},
118 "source": [
118 "source": [
119 "You have been provided with an already existing profile folder with this tutorial...\n",
119 "You have been provided with an already existing profile folder with this tutorial...\n",
120 "start the notebook from the root of the tutorial directory with :\n",
120 "start the notebook from the root of the tutorial directory with :\n",
121 "\n",
121 "\n",
122 "```bash\n",
122 "```bash\n",
123 "$ ipython notebook --ProfileDir.location=./profile_euroscipy\n",
123 "$ ipython notebook --ProfileDir.location=./profile_euroscipy\n",
124 "```"
124 "```"
125 ]
125 ]
126 },
126 },
127 {
127 {
128 "cell_type": "markdown",
128 "cell_type": "markdown",
129 "metadata": {},
129 "metadata": {},
130 "source": [
130 "source": [
131 "##### but back to theory"
131 "##### but back to theory"
132 ]
132 ]
133 },
133 },
134 {
134 {
135 "cell_type": "code",
135 "cell_type": "code",
136 "execution_count": null,
136 "execution_count": null,
137 "metadata": {
137 "metadata": {
138 "collapsed": false
138 "collapsed": false
139 },
139 },
140 "outputs": [
140 "outputs": [],
141 {
142 "data": {
143 "text/plain": [
144 "'/Users/bussonniermatthias/.ipython'"
145 ]
146 },
147 "execution_count": 1,
148 "metadata": {},
149 "output_type": "execute_result"
150 }
151 ],
152 "source": [
141 "source": [
153 "profile_dir = ! ipython locate\n",
142 "profile_dir = ! ipython locate\n",
154 "profile_dir = profile_dir[0]\n",
143 "profile_dir = profile_dir[0]\n",
155 "profile_dir"
144 "profile_dir"
156 ]
145 ]
157 },
146 },
158 {
147 {
159 "cell_type": "markdown",
148 "cell_type": "markdown",
160 "metadata": {},
149 "metadata": {},
161 "source": [
150 "source": [
162 "and custom js is in "
151 "and custom js is in "
163 ]
152 ]
164 },
153 },
165 {
154 {
166 "cell_type": "code",
155 "cell_type": "code",
167 "execution_count": null,
156 "execution_count": null,
168 "metadata": {
157 "metadata": {
169 "collapsed": false
158 "collapsed": false
170 },
159 },
171 "outputs": [],
160 "outputs": [],
172 "source": [
161 "source": [
173 "import os.path\n",
162 "import os.path\n",
174 "custom_js_path = os.path.join(profile_dir,'profile_default','static','custom','custom.js')"
163 "custom_js_path = os.path.join(profile_dir,'profile_default','static','custom','custom.js')"
175 ]
164 ]
176 },
165 },
177 {
166 {
178 "cell_type": "code",
167 "cell_type": "code",
179 "execution_count": null,
168 "execution_count": null,
180 "metadata": {
169 "metadata": {
181 "collapsed": false
170 "collapsed": false
182 },
171 },
183 "outputs": [
172 "outputs": [],
184 {
185 "name": "stdout",
186 "output_type": "stream",
187 "text": [
188 "// we want strict javascript that fails\n",
189 "// on ambiguous syntax\n",
190 "\"using strict\";\n",
191 "\n",
192 "// notebook loaded is not perfect as it is re-triggerd on\n",
193 "// revert to checkpoint but this allow extesnsion to be loaded\n",
194 "// late enough to work.\n",
195 "$([IPython.events]).on('notebook_loaded.Notebook', function(){\n",
196 "\n",
197 "\n",
198 " /** Use path to js file relative to /static/ dir without leading slash, or\n",
199 " * js extension.\n",
200 " * Link directly to file is js extension isa simple file\n",
201 " *\n",
202 " * first argument of require is a **list** that can contains several modules if needed.\n",
203 " **/\n",
204 "\n",
205 " //require(['custom/noscroll']);\n",
206 " // require(['custom/clean_start'])\n",
207 " // require(['custom/toggle_all_line_number'])\n",
208 " // require(['custom/gist_it']);\n",
209 " // require(['custom/autosavetime']);\n",
210 "\n",
211 " /**\n",
212 " * Link to entrypoint if extesnsion is a folder.\n",
213 " * to be consistent with commonjs module, the entrypoint is main.js\n",
214 " * here youcan also trigger a custom function on load that will do extra\n",
215 " * action with the module if needed\n",
216 " **/\n",
217 " require(['custom/slidemode/main'])\n",
218 "\n",
219 " // require(['custom/autoscroll']);\n",
220 "\n",
221 " //require(['custom/css_selector/main'])\n",
222 " require(['custom/pre_exec_strip']);\n",
223 " // require(['custom/no_exec_dunder']);\n",
224 " // load_ext('nbviewer_theme')\n",
225 "\n",
226 "\n",
227 " require(['custom/clippytip/main']);\n",
228 "\n",
229 " IPython.toolbar.add_buttons_group([\n",
230 " {\n",
231 " 'label' : 'run qtconsole',\n",
232 " 'icon' : 'icon-paper-clip', // select your icon from http://jqueryui.com/themeroller/\n",
233 " 'callback': function(){\n",
234 " IPython.tooltip.remove_and_cancel_tooltip(true)\n",
235 " $('#tooltip').empty() \n",
236 " $('#tooltip').attr('style','') \n",
237 " IPython.tooltip = new IPython.ClippyTip()\n",
238 " }\n",
239 " },\n",
240 " {\n",
241 " 'label' : 'run qtconsole',\n",
242 " 'icon' : 'icon-th-large', // select your icon from http://jqueryui.com/themeroller/\n",
243 " 'callback': function(){\n",
244 " IPython.tooltip.remove_and_cancel_tooltip(true)\n",
245 " $('#tooltip').empty() \n",
246 " $('#tooltip').attr('style','')\n",
247 " IPython.tooltip = new IPython.Tooltip()\n",
248 " }\n",
249 " }\n",
250 " // add more button here if needed.\n",
251 " ]);\n",
252 " //\n",
253 "\n",
254 "});\n",
255 "\n",
256 "/*\n",
257 "$([IPython.events]).on('notebook_loaded.Notebook', function(){\n",
258 " IPython.toolbar.add_buttons_group([\n",
259 " {\n",
260 " 'label' : 'run qtconsole',\n",
261 " 'icon' : 'ui-icon-calculator',\n",
262 " 'callback': function(){IPython.notebook.kernel.execute('%qtconsole')}\n",
263 " }\n",
264 " ]);\n",
265 "});\n",
266 "*/\n",
267 "\n",
268 "//$([IPython.events]).on('notebook_loaded.Notebook', function(){\n",
269 "// mobile_preset = []\n",
270 "// var edit = function(div, cell) {\n",
271 "// var button_container = $(div);\n",
272 "// var button = $('<div/>').button({icons:{primary:'ui-icon-pencil'}});\n",
273 "// button.click(function(){\n",
274 "// cell.edit()\n",
275 "// })\n",
276 "// button_container.append(button);\n",
277 "// }\n",
278 "//\n",
279 "// IPython.CellToolbar.register_callback('mobile.edit',edit);\n",
280 "// mobile_preset.push('mobile.edit');\n",
281 "//\n",
282 "// IPython.CellToolbar.register_preset('Mobile',mobile_preset);\n",
283 "//});\n"
284 ]
285 }
286 ],
287 "source": [
173 "source": [
288 "# my custom js\n",
174 "# my custom js\n",
289 "with open(custom_js_path) as f:\n",
175 "with open(custom_js_path) as f:\n",
290 " for l in f: \n",
176 " for l in f: \n",
291 " print l,"
177 " print l,"
292 ]
178 ]
293 },
179 },
294 {
180 {
295 "cell_type": "markdown",
181 "cell_type": "markdown",
296 "metadata": {},
182 "metadata": {},
297 "source": [
183 "source": [
298 "Note that `custom.js` is ment to be modified by user, when writing a script, you can define it in a separate file and add a line of configuration into `custom.js` that will fetch and execute the file."
184 "Note that `custom.js` is ment to be modified by user, when writing a script, you can define it in a separate file and add a line of configuration into `custom.js` that will fetch and execute the file."
299 ]
185 ]
300 },
186 },
301 {
187 {
302 "cell_type": "markdown",
188 "cell_type": "markdown",
303 "metadata": {},
189 "metadata": {},
304 "source": [
190 "source": [
305 "**Warning** : even if modification of `custom.js` take effect immediately after browser refresh (except if browser cache is aggressive), *creating* a file in `static/` directory need a **server restart**."
191 "**Warning** : even if modification of `custom.js` take effect immediately after browser refresh (except if browser cache is aggressive), *creating* a file in `static/` directory need a **server restart**."
306 ]
192 ]
307 },
193 },
308 {
194 {
309 "cell_type": "markdown",
195 "cell_type": "markdown",
310 "metadata": {},
196 "metadata": {},
311 "source": [
197 "source": [
312 "## Exercise :"
198 "## Exercise :"
313 ]
199 ]
314 },
200 },
315 {
201 {
316 "cell_type": "markdown",
202 "cell_type": "markdown",
317 "metadata": {},
203 "metadata": {},
318 "source": [
204 "source": [
319 " - Create a `custom.js` in the right location with the following content:\n",
205 " - Create a `custom.js` in the right location with the following content:\n",
320 "```javascript\n",
206 "```javascript\n",
321 "alert(\"hello world from custom.js\")\n",
207 "alert(\"hello world from custom.js\")\n",
322 "```\n",
208 "```\n",
323 "\n",
209 "\n",
324 " - Restart your server and open any notebook.\n",
210 " - Restart your server and open any notebook.\n",
325 " - Be greeted by custom.js"
211 " - Be greeted by custom.js"
326 ]
212 ]
327 },
213 },
328 {
214 {
329 "cell_type": "markdown",
215 "cell_type": "markdown",
330 "metadata": {},
216 "metadata": {},
331 "source": [
217 "source": [
332 "Have a look at [default custom.js](https://github.com/ipython/ipython/blob/1.x/IPython/html/static/custom/custom.js), to see it's content and some more explanation."
218 "Have a look at [default custom.js](https://github.com/ipython/ipython/blob/1.x/IPython/html/static/custom/custom.js), to see it's content and some more explanation."
333 ]
219 ]
334 },
220 },
335 {
221 {
336 "cell_type": "markdown",
222 "cell_type": "markdown",
337 "metadata": {},
223 "metadata": {},
338 "source": [
224 "source": [
339 "#### For the quick ones : "
225 "#### For the quick ones : "
340 ]
226 ]
341 },
227 },
342 {
228 {
343 "cell_type": "markdown",
229 "cell_type": "markdown",
344 "metadata": {},
230 "metadata": {},
345 "source": [
231 "source": [
346 "We've seen above that you can change the autosave rate by using a magic. This is typically something I don't want to type everytime, and that I don't like to embed into my workwlow and documents. (reader don't care what my autosave time is), let's build an extension that allow to do it. "
232 "We've seen above that you can change the autosave rate by using a magic. This is typically something I don't want to type everytime, and that I don't like to embed into my workwlow and documents. (reader don't care what my autosave time is), let's build an extension that allow to do it. "
347 ]
233 ]
348 },
234 },
349 {
235 {
350 "cell_type": "markdown",
236 "cell_type": "markdown",
351 "metadata": {
237 "metadata": {
352 "foo": true
238 "foo": true
353 },
239 },
354 "source": [
240 "source": [
355 "Create a dropdow elemement in the toolbar (DOM `IPython.toolbar.element`), you will need \n",
241 "Create a dropdow elemement in the toolbar (DOM `IPython.toolbar.element`), you will need \n",
356 "\n",
242 "\n",
357 "- `IPython.notebook.set_autosave_interval(miliseconds)`\n",
243 "- `IPython.notebook.set_autosave_interval(miliseconds)`\n",
358 "- know that 1min = 60 sec, and 1 sec = 1000 ms"
244 "- know that 1min = 60 sec, and 1 sec = 1000 ms"
359 ]
245 ]
360 },
246 },
361 {
247 {
362 "cell_type": "markdown",
248 "cell_type": "markdown",
363 "metadata": {},
249 "metadata": {},
364 "source": [
250 "source": [
365 "```javascript\n",
251 "```javascript\n",
366 "\n",
252 "\n",
367 "var label = jQuery('<label/>').text('AutoScroll Limit:');\n",
253 "var label = jQuery('<label/>').text('AutoScroll Limit:');\n",
368 "var select = jQuery('<select/>')\n",
254 "var select = jQuery('<select/>')\n",
369 " //.append(jQuery('<option/>').attr('value', '2').text('2min (default)'))\n",
255 " //.append(jQuery('<option/>').attr('value', '2').text('2min (default)'))\n",
370 " .append(jQuery('<option/>').attr('value', undefined).text('disabled'))\n",
256 " .append(jQuery('<option/>').attr('value', undefined).text('disabled'))\n",
371 "\n",
257 "\n",
372 " // TODO:\n",
258 " // TODO:\n",
373 " //the_toolbar_element.append(label)\n",
259 " //the_toolbar_element.append(label)\n",
374 " //the_toolbar_element.append(select);\n",
260 " //the_toolbar_element.append(select);\n",
375 " \n",
261 " \n",
376 "select.change(function() {\n",
262 "select.change(function() {\n",
377 " var val = jQuery(this).val() // val will be the value in [2]\n",
263 " var val = jQuery(this).val() // val will be the value in [2]\n",
378 " // TODO\n",
264 " // TODO\n",
379 " // this will be called when dropdown changes\n",
265 " // this will be called when dropdown changes\n",
380 "\n",
266 "\n",
381 "});\n",
267 "});\n",
382 "\n",
268 "\n",
383 "var time_m = [1,5,10,15,30];\n",
269 "var time_m = [1,5,10,15,30];\n",
384 "for (var i=0; i < time_m.length; i++) {\n",
270 "for (var i=0; i < time_m.length; i++) {\n",
385 " var ts = time_m[i];\n",
271 " var ts = time_m[i];\n",
386 " //[2] ____ this will be `val` on [1] \n",
272 " //[2] ____ this will be `val` on [1] \n",
387 " // | \n",
273 " // | \n",
388 " // v \n",
274 " // v \n",
389 " select.append($('<option/>').attr('value', ts).text(thr+'min'));\n",
275 " select.append($('<option/>').attr('value', ts).text(thr+'min'));\n",
390 " // this will fill up the dropdown `select` with\n",
276 " // this will fill up the dropdown `select` with\n",
391 " // 1 min\n",
277 " // 1 min\n",
392 " // 5 min\n",
278 " // 5 min\n",
393 " // 10 min\n",
279 " // 10 min\n",
394 " // 10 min\n",
280 " // 10 min\n",
395 " // ...\n",
281 " // ...\n",
396 "}\n",
282 "}\n",
397 "```"
283 "```"
398 ]
284 ]
399 },
285 },
400 {
286 {
401 "cell_type": "markdown",
287 "cell_type": "markdown",
402 "metadata": {},
288 "metadata": {},
403 "source": [
289 "source": [
404 "#### A non interactive example first"
290 "#### A non interactive example first"
405 ]
291 ]
406 },
292 },
407 {
293 {
408 "cell_type": "markdown",
294 "cell_type": "markdown",
409 "metadata": {},
295 "metadata": {},
410 "source": [
296 "source": [
411 "I like my cython to be nicely highlighted\n",
297 "I like my cython to be nicely highlighted\n",
412 "\n",
298 "\n",
413 "```javascript\n",
299 "```javascript\n",
414 "IPython.config.cell_magic_highlight['magic_text/x-cython'] = {}\n",
300 "IPython.config.cell_magic_highlight['magic_text/x-cython'] = {}\n",
415 "IPython.config.cell_magic_highlight['magic_text/x-cython'].reg = [/^%%cython/]\n",
301 "IPython.config.cell_magic_highlight['magic_text/x-cython'].reg = [/^%%cython/]\n",
416 "```\n",
302 "```\n",
417 "\n",
303 "\n",
418 "`text/x-cython` is the name of CodeMirror mode name, `magic_` prefix will just patch the mode so that the first line that contains a magic does not screw up the highlighting. `reg`is a list or regular expression that will trigger the change of mode."
304 "`text/x-cython` is the name of CodeMirror mode name, `magic_` prefix will just patch the mode so that the first line that contains a magic does not screw up the highlighting. `reg`is a list or regular expression that will trigger the change of mode."
419 ]
305 ]
420 },
306 },
421 {
307 {
422 "cell_type": "markdown",
308 "cell_type": "markdown",
423 "metadata": {},
309 "metadata": {},
424 "source": [
310 "source": [
425 "#### Get more docs"
311 "#### Get more docs"
426 ]
312 ]
427 },
313 },
428 {
314 {
429 "cell_type": "markdown",
315 "cell_type": "markdown",
430 "metadata": {},
316 "metadata": {},
431 "source": [
317 "source": [
432 "Sadly you will have to read the js source file (but there are lots of comments) an/or build the javascript documentation using yuidoc.\n",
318 "Sadly you will have to read the js source file (but there are lots of comments) an/or build the javascript documentation using yuidoc.\n",
433 "If you have `node` and `yui-doc` installed:"
319 "If you have `node` and `yui-doc` installed:"
434 ]
320 ]
435 },
321 },
436 {
322 {
437 "cell_type": "markdown",
323 "cell_type": "markdown",
438 "metadata": {},
324 "metadata": {},
439 "source": [
325 "source": [
440 "```bash\n",
326 "```bash\n",
441 "$ cd ~/ipython/IPython/html/static/notebook/js/\n",
327 "$ cd ~/ipython/IPython/html/static/notebook/js/\n",
442 "$ yuidoc . --server\n",
328 "$ yuidoc . --server\n",
443 "warn: (yuidoc): Failed to extract port, setting to the default :3000\n",
329 "warn: (yuidoc): Failed to extract port, setting to the default :3000\n",
444 "info: (yuidoc): Starting YUIDoc@0.3.45 using YUI@3.9.1 with NodeJS@0.10.15\n",
330 "info: (yuidoc): Starting YUIDoc@0.3.45 using YUI@3.9.1 with NodeJS@0.10.15\n",
445 "info: (yuidoc): Scanning for yuidoc.json file.\n",
331 "info: (yuidoc): Scanning for yuidoc.json file.\n",
446 "info: (yuidoc): Starting YUIDoc with the following options:\n",
332 "info: (yuidoc): Starting YUIDoc with the following options:\n",
447 "info: (yuidoc):\n",
333 "info: (yuidoc):\n",
448 "{ port: 3000,\n",
334 "{ port: 3000,\n",
449 " nocode: false,\n",
335 " nocode: false,\n",
450 " paths: [ '.' ],\n",
336 " paths: [ '.' ],\n",
451 " server: true,\n",
337 " server: true,\n",
452 " outdir: './out' }\n",
338 " outdir: './out' }\n",
453 "info: (yuidoc): Scanning for yuidoc.json file.\n",
339 "info: (yuidoc): Scanning for yuidoc.json file.\n",
454 "info: (server): Starting server: http://127.0.0.1:3000\n",
340 "info: (server): Starting server: http://127.0.0.1:3000\n",
455 "```\n",
341 "```\n",
456 "\n",
342 "\n",
457 "and browse http://127.0.0.1:3000 to get docs"
343 "and browse http://127.0.0.1:3000 to get docs"
458 ]
344 ]
459 },
345 },
460 {
346 {
461 "cell_type": "markdown",
347 "cell_type": "markdown",
462 "metadata": {
348 "metadata": {
463 "foo": true
349 "foo": true
464 },
350 },
465 "source": [
351 "source": [
466 "#### Some convenience methods"
352 "#### Some convenience methods"
467 ]
353 ]
468 },
354 },
469 {
355 {
470 "cell_type": "markdown",
356 "cell_type": "markdown",
471 "metadata": {},
357 "metadata": {},
472 "source": [
358 "source": [
473 "By browsing the doc you will see that we have soem convenience methods that avoid to re-invent the UI everytime :\n",
359 "By browsing the doc you will see that we have soem convenience methods that avoid to re-invent the UI everytime :\n",
474 "```javascript\n",
360 "```javascript\n",
475 "IPython.toolbar.add_buttons_group([\n",
361 "IPython.toolbar.add_buttons_group([\n",
476 " {\n",
362 " {\n",
477 " 'label' : 'run qtconsole',\n",
363 " 'label' : 'run qtconsole',\n",
478 " 'icon' : 'icon-terminal', // select your icon from \n",
364 " 'icon' : 'icon-terminal', // select your icon from \n",
479 " // http://fortawesome.github.io/Font-Awesome/icons/\n",
365 " // http://fortawesome.github.io/Font-Awesome/icons/\n",
480 " 'callback': function(){IPython.notebook.kernel.execute('%qtconsole')}\n",
366 " 'callback': function(){IPython.notebook.kernel.execute('%qtconsole')}\n",
481 " }\n",
367 " }\n",
482 " // add more button here if needed.\n",
368 " // add more button here if needed.\n",
483 " ]);\n",
369 " ]);\n",
484 "```\n",
370 "```\n",
485 "with a [lot of icons] you can select from. \n",
371 "with a [lot of icons] you can select from. \n",
486 "\n",
372 "\n",
487 "[lot of icons]: http://fortawesome.github.io/Font-Awesome/icons/"
373 "[lot of icons]: http://fortawesome.github.io/Font-Awesome/icons/"
488 ]
374 ]
489 },
375 },
490 {
376 {
491 "cell_type": "markdown",
377 "cell_type": "markdown",
492 "metadata": {
378 "metadata": {
493 "foo": true
379 "foo": true
494 },
380 },
495 "source": [
381 "source": [
496 "## Cell Metadata"
382 "## Cell Metadata"
497 ]
383 ]
498 },
384 },
499 {
385 {
500 "cell_type": "markdown",
386 "cell_type": "markdown",
501 "metadata": {
387 "metadata": {
502 "foo": true
388 "foo": true
503 },
389 },
504 "source": [
390 "source": [
505 "The most requested feature is generaly to be able to distinguish individual cell in th enotebook, or run specific action with them.\n",
391 "The most requested feature is generaly to be able to distinguish individual cell in th enotebook, or run specific action with them.\n",
506 "To do so, you can either use `IPython.notebook.get_selected_cell()`, or rely on `CellToolbar`. This allow you to register aset of action and graphical element that will be attached on individual cells."
392 "To do so, you can either use `IPython.notebook.get_selected_cell()`, or rely on `CellToolbar`. This allow you to register aset of action and graphical element that will be attached on individual cells."
507 ]
393 ]
508 },
394 },
509 {
395 {
510 "cell_type": "markdown",
396 "cell_type": "markdown",
511 "metadata": {},
397 "metadata": {},
512 "source": [
398 "source": [
513 "### Cell Toolbar"
399 "### Cell Toolbar"
514 ]
400 ]
515 },
401 },
516 {
402 {
517 "cell_type": "markdown",
403 "cell_type": "markdown",
518 "metadata": {},
404 "metadata": {},
519 "source": [
405 "source": [
520 "You can see some example of what can be done by toggling the `Cell Toolbar` selector in the toolbar on top of the notebook. It provide two default `presets` that are `Default` and `slideshow`. Default allow edit the metadata attached to each cell manually."
406 "You can see some example of what can be done by toggling the `Cell Toolbar` selector in the toolbar on top of the notebook. It provide two default `presets` that are `Default` and `slideshow`. Default allow edit the metadata attached to each cell manually."
521 ]
407 ]
522 },
408 },
523 {
409 {
524 "cell_type": "markdown",
410 "cell_type": "markdown",
525 "metadata": {},
411 "metadata": {},
526 "source": [
412 "source": [
527 "First we define a function that takes at first parameter an element on the DOM in which to inject UI element. Second element will be the cell this element will be registerd with. Then we will need to register that function ad give it a name.\n"
413 "First we define a function that takes at first parameter an element on the DOM in which to inject UI element. Second element will be the cell this element will be registerd with. Then we will need to register that function ad give it a name.\n"
528 ]
414 ]
529 },
415 },
530 {
416 {
531 "cell_type": "markdown",
417 "cell_type": "markdown",
532 "metadata": {},
418 "metadata": {},
533 "source": [
419 "source": [
534 "#### Register a callback"
420 "#### Register a callback"
535 ]
421 ]
536 },
422 },
537 {
423 {
538 "cell_type": "code",
424 "cell_type": "code",
539 "execution_count": 51,
425 "execution_count": null,
540 "metadata": {
426 "metadata": {
541 "collapsed": false
427 "collapsed": false
542 },
428 },
543 "outputs": [
429 "outputs": [],
544 {
545 "data": {
546 "application/javascript": [
547 "var CellToolbar = IPython.CellToolbar\n",
548 "var toggle = function(div, cell) {\n",
549 " var button_container = $(div)\n",
550 "\n",
551 " // let's create a button that show the current value of the metadata\n",
552 " var button = $('<button/>').addClass('btn btn-mini').text(String(cell.metadata.foo));\n",
553 "\n",
554 " // On click, change the metadata value and update the button label\n",
555 " button.click(function(){\n",
556 " var v = cell.metadata.foo;\n",
557 " cell.metadata.foo = !v;\n",
558 " button.text(String(!v));\n",
559 " })\n",
560 "\n",
561 " // add the button to the DOM div.\n",
562 " button_container.append(button);\n",
563 "}\n",
564 "\n",
565 " // now we register the callback under the name foo to give the\n",
566 " // user the ability to use it later\n",
567 " CellToolbar.register_callback('tuto.foo', toggle);"
568 ],
569 "text/plain": [
570 "<IPython.core.display.Javascript at 0x10c94a590>"
571 ]
572 },
573 "metadata": {},
574 "output_type": "display_data"
575 }
576 ],
577 "source": [
430 "source": [
578 "%%javascript\n",
431 "%%javascript\n",
579 "var CellToolbar = IPython.CellToolbar\n",
432 "var CellToolbar = IPython.CellToolbar\n",
580 "var toggle = function(div, cell) {\n",
433 "var toggle = function(div, cell) {\n",
581 " var button_container = $(div)\n",
434 " var button_container = $(div)\n",
582 "\n",
435 "\n",
583 " // let's create a button that show the current value of the metadata\n",
436 " // let's create a button that show the current value of the metadata\n",
584 " var button = $('<button/>').addClass('btn btn-mini').text(String(cell.metadata.foo));\n",
437 " var button = $('<button/>').addClass('btn btn-mini').text(String(cell.metadata.foo));\n",
585 "\n",
438 "\n",
586 " // On click, change the metadata value and update the button label\n",
439 " // On click, change the metadata value and update the button label\n",
587 " button.click(function(){\n",
440 " button.click(function(){\n",
588 " var v = cell.metadata.foo;\n",
441 " var v = cell.metadata.foo;\n",
589 " cell.metadata.foo = !v;\n",
442 " cell.metadata.foo = !v;\n",
590 " button.text(String(!v));\n",
443 " button.text(String(!v));\n",
591 " })\n",
444 " })\n",
592 "\n",
445 "\n",
593 " // add the button to the DOM div.\n",
446 " // add the button to the DOM div.\n",
594 " button_container.append(button);\n",
447 " button_container.append(button);\n",
595 "}\n",
448 "}\n",
596 "\n",
449 "\n",
597 " // now we register the callback under the name foo to give the\n",
450 " // now we register the callback under the name foo to give the\n",
598 " // user the ability to use it later\n",
451 " // user the ability to use it later\n",
599 " CellToolbar.register_callback('tuto.foo', toggle);"
452 " CellToolbar.register_callback('tuto.foo', toggle);"
600 ]
453 ]
601 },
454 },
602 {
455 {
603 "cell_type": "markdown",
456 "cell_type": "markdown",
604 "metadata": {},
457 "metadata": {},
605 "source": [
458 "source": [
606 "#### Registering a preset"
459 "#### Registering a preset"
607 ]
460 ]
608 },
461 },
609 {
462 {
610 "cell_type": "markdown",
463 "cell_type": "markdown",
611 "metadata": {},
464 "metadata": {},
612 "source": [
465 "source": [
613 "This function can now be part of many `preset` of the CellToolBar."
466 "This function can now be part of many `preset` of the CellToolBar."
614 ]
467 ]
615 },
468 },
616 {
469 {
617 "cell_type": "code",
470 "cell_type": "code",
618 "execution_count": 54,
471 "execution_count": null,
619 "metadata": {
472 "metadata": {
620 "collapsed": false,
473 "collapsed": false,
621 "foo": true,
474 "foo": true,
622 "slideshow": {
475 "slideshow": {
623 "slide_type": "subslide"
476 "slide_type": "subslide"
624 }
477 }
625 },
478 },
626 "outputs": [
479 "outputs": [],
627 {
628 "data": {
629 "application/javascript": [
630 "IPython.CellToolbar.register_preset('Tutorial 1',['tuto.foo','default.rawedit'])\n",
631 "IPython.CellToolbar.register_preset('Tutorial 2',['slideshow.select','tuto.foo'])"
632 ],
633 "text/plain": [
634 "<IPython.core.display.Javascript at 0x10c94a510>"
635 ]
636 },
637 "metadata": {},
638 "output_type": "display_data"
639 }
640 ],
641 "source": [
480 "source": [
642 "%%javascript\n",
481 "%%javascript\n",
643 "IPython.CellToolbar.register_preset('Tutorial 1',['tuto.foo','default.rawedit'])\n",
482 "IPython.CellToolbar.register_preset('Tutorial 1',['tuto.foo','default.rawedit'])\n",
644 "IPython.CellToolbar.register_preset('Tutorial 2',['slideshow.select','tuto.foo'])"
483 "IPython.CellToolbar.register_preset('Tutorial 2',['slideshow.select','tuto.foo'])"
645 ]
484 ]
646 },
485 },
647 {
486 {
648 "cell_type": "markdown",
487 "cell_type": "markdown",
649 "metadata": {},
488 "metadata": {},
650 "source": [
489 "source": [
651 "You should now have access to two presets :\n",
490 "You should now have access to two presets :\n",
652 "\n",
491 "\n",
653 " - Tutorial 1\n",
492 " - Tutorial 1\n",
654 " - Tutorial 2\n",
493 " - Tutorial 2\n",
655 " \n",
494 " \n",
656 "And check that the buttons you defin share state when you toggle preset. \n",
495 "And check that the buttons you defin share state when you toggle preset. \n",
657 "Check moreover that the metadata of the cell is modified when you clisk the button, and that when saved on reloaded the metadata is still availlable."
496 "Check moreover that the metadata of the cell is modified when you clisk the button, and that when saved on reloaded the metadata is still availlable."
658 ]
497 ]
659 },
498 },
660 {
499 {
661 "cell_type": "markdown",
500 "cell_type": "markdown",
662 "metadata": {},
501 "metadata": {},
663 "source": [
502 "source": [
664 "#### Exercise:"
503 "#### Exercise:"
665 ]
504 ]
666 },
505 },
667 {
506 {
668 "cell_type": "markdown",
507 "cell_type": "markdown",
669 "metadata": {},
508 "metadata": {},
670 "source": [
509 "source": [
671 "Try to wrap the all code in a file, put this file in `{profile}/static/custom/<a-name>.js`, and add \n",
510 "Try to wrap the all code in a file, put this file in `{profile}/static/custom/<a-name>.js`, and add \n",
672 "\n",
511 "\n",
673 "```\n",
512 "```\n",
674 "require(['custom/<a-name>']);\n",
513 "require(['custom/<a-name>']);\n",
675 "```\n",
514 "```\n",
676 "\n",
515 "\n",
677 "in `custom.js` to have this script automatically loaded in all your notebooks.\n",
516 "in `custom.js` to have this script automatically loaded in all your notebooks.\n",
678 "\n"
517 "\n"
679 ]
518 ]
680 },
519 },
681 {
520 {
682 "cell_type": "markdown",
521 "cell_type": "markdown",
683 "metadata": {},
522 "metadata": {},
684 "source": [
523 "source": [
685 "`require` is provided by a [javascript library](http://requirejs.org/) that allow to express dependency. For simple extension like the previous one we directly mute the global namespace, but for more complexe extension you could pass acallback to `require([...], <callback>)` call, to allow the user to pass configuration information to your plugin.\n",
524 "`require` is provided by a [javascript library](http://requirejs.org/) that allow to express dependency. For simple extension like the previous one we directly mute the global namespace, but for more complexe extension you could pass acallback to `require([...], <callback>)` call, to allow the user to pass configuration information to your plugin.\n",
686 "\n",
525 "\n",
687 "In Python lang, \n",
526 "In Python lang, \n",
688 "\n",
527 "\n",
689 "```javascript\n",
528 "```javascript\n",
690 "require(['a/b', 'c/d'], function( e, f){\n",
529 "require(['a/b', 'c/d'], function( e, f){\n",
691 " e.something()\n",
530 " e.something()\n",
692 " f.something()\n",
531 " f.something()\n",
693 "})\n",
532 "})\n",
694 "```\n",
533 "```\n",
695 "\n",
534 "\n",
696 "could be read as\n",
535 "could be read as\n",
697 "```python\n",
536 "```python\n",
698 "import a.b as e\n",
537 "import a.b as e\n",
699 "import c.d as f\n",
538 "import c.d as f\n",
700 "e.something()\n",
539 "e.something()\n",
701 "f.something()\n",
540 "f.something()\n",
702 "```\n",
541 "```\n",
703 "\n",
542 "\n",
704 "\n",
543 "\n",
705 "See for example @damianavila [\"ZenMode\" plugin](https://github.com/ipython-contrib/IPython-notebook-extensions/blob/master/custom.example.js#L34) :\n",
544 "See for example @damianavila [\"ZenMode\" plugin](https://github.com/ipython-contrib/IPython-notebook-extensions/blob/master/custom.example.js#L34) :\n",
706 "\n",
545 "\n",
707 "```javascript\n",
546 "```javascript\n",
708 "\n",
547 "\n",
709 "// read that as\n",
548 "// read that as\n",
710 "// import custom.zenmode.main as zenmode\n",
549 "// import custom.zenmode.main as zenmode\n",
711 "require(['custom/zenmode/main'],function(zenmode){\n",
550 "require(['custom/zenmode/main'],function(zenmode){\n",
712 " zenmode.background('images/back12.jpg');\n",
551 " zenmode.background('images/back12.jpg');\n",
713 "})\n",
552 "})\n",
714 "```\n"
553 "```\n"
715 ]
554 ]
716 },
555 },
717 {
556 {
718 "cell_type": "markdown",
557 "cell_type": "markdown",
719 "metadata": {},
558 "metadata": {},
720 "source": [
559 "source": [
721 "#### For the quickest"
560 "#### For the quickest"
722 ]
561 ]
723 },
562 },
724 {
563 {
725 "cell_type": "markdown",
564 "cell_type": "markdown",
726 "metadata": {},
565 "metadata": {},
727 "source": [
566 "source": [
728 "Try to use [the following](https://github.com/ipython/ipython/blob/1.x/IPython/html/static/notebook/js/celltoolbar.js#L367) to bind a dropdown list to `cell.metadata.difficulty.select`. \n",
567 "Try to use [the following](https://github.com/ipython/ipython/blob/1.x/IPython/html/static/notebook/js/celltoolbar.js#L367) to bind a dropdown list to `cell.metadata.difficulty.select`. \n",
729 "\n",
568 "\n",
730 "It should be able to take the 4 following values :\n",
569 "It should be able to take the 4 following values :\n",
731 "\n",
570 "\n",
732 " - `<None>`\n",
571 " - `<None>`\n",
733 " - `Easy`\n",
572 " - `Easy`\n",
734 " - `Medium`\n",
573 " - `Medium`\n",
735 " - `Hard`\n",
574 " - `Hard`\n",
736 " \n",
575 " \n",
737 "We will use it to customise the output of the converted notebook depending of the tag on each cell"
576 "We will use it to customise the output of the converted notebook depending of the tag on each cell"
738 ]
577 ]
739 },
578 },
740 {
579 {
741 "cell_type": "code",
580 "cell_type": "code",
742 "execution_count": null,
581 "execution_count": null,
743 "metadata": {
582 "metadata": {
744 "collapsed": false
583 "collapsed": false
745 },
584 },
746 "outputs": [],
585 "outputs": [],
747 "source": [
586 "source": [
748 "%load soln/celldiff.js"
587 "%load soln/celldiff.js"
749 ]
588 ]
750 }
589 }
751 ],
590 ],
752 "metadata": {
591 "metadata": {
753 "kernelspec": {
592 "kernelspec": {
754 "display_name": "Python 3",
593 "display_name": "Python 3",
755 "language": "python",
594 "language": "python",
756 "name": "python3"
595 "name": "python3"
757 },
596 },
758 "language_info": {
597 "language_info": {
759 "codemirror_mode": {
598 "codemirror_mode": {
760 "name": "ipython",
599 "name": "ipython",
761 "version": 3
600 "version": 3
762 },
601 },
763 "file_extension": ".py",
602 "file_extension": ".py",
764 "mimetype": "text/x-python",
603 "mimetype": "text/x-python",
765 "name": "python",
604 "name": "python",
766 "nbconvert_exporter": "python",
605 "nbconvert_exporter": "python",
767 "pygments_lexer": "ipython3",
606 "pygments_lexer": "ipython3",
768 "version": "3.4.2"
607 "version": "3.4.3"
769 }
608 }
770 },
609 },
771 "nbformat": 4,
610 "nbformat": 4,
772 "nbformat_minor": 0
611 "nbformat_minor": 0
773 }
612 }
@@ -1,256 +1,313 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "# Notebook Basics"
7 "# Notebook Basics"
8 ]
8 ]
9 },
9 },
10 {
10 {
11 "cell_type": "markdown",
11 "cell_type": "markdown",
12 "metadata": {},
12 "metadata": {},
13 "source": [
13 "source": [
14 "This notebook assumes that you already have IPython [installed](http://ipython.org/install.html) and are able to start the notebook server by running:\n",
14 "## Running the Notebook Server"
15 ]
16 },
17 {
18 "cell_type": "markdown",
19 "metadata": {},
20 "source": [
21 "The IPython notebook server is a custom web server that runs the notebook web application. Most of the time, users run the notebook server on their local computer using IPython's command line interface."
22 ]
23 },
24 {
25 "cell_type": "markdown",
26 "metadata": {},
27 "source": [
28 "### Starting the notebook server using the command line"
29 ]
30 },
31 {
32 "cell_type": "markdown",
33 "metadata": {},
34 "source": [
35 "You can start the notebook server from the command line (Terminal on Mac/Linux, CMD prompt on Windows) by running the following command: \n",
15 "\n",
36 "\n",
16 " ipython notebook\n",
37 " ipython notebook\n",
17 "\n",
38 "\n",
18 "For more details on how to run the notebook server, see [Running the Notebook Server](Running the Notebook Server.ipynb)."
39 "This will print some information about the notebook server in your terminal, including the URL of the web application (by default, `http://127.0.0.1:8888`). It will then open your default web browser to this URL.\n",
40 "\n",
41 "When the notebook opens, you will see the **notebook dashboard**, which will show a list of the notebooks and subdirectories in the directory where the notebook server was started (as seen in the next section, below). Most of the time, you will want to start a notebook server in the highest directory in your filesystem where notebooks can be found. Often this will be your home directory."
19 ]
42 ]
20 },
43 },
21 {
44 {
22 "cell_type": "markdown",
45 "cell_type": "markdown",
23 "metadata": {},
46 "metadata": {},
24 "source": [
47 "source": [
25 "## The Notebook dashboard"
48 "### Additional options"
26 ]
49 ]
27 },
50 },
28 {
51 {
29 "cell_type": "markdown",
52 "cell_type": "markdown",
30 "metadata": {},
53 "metadata": {},
31 "source": [
54 "source": [
32 "When you first start the notebook server, your browser will open to the notebook dashboard. The dashboard serves as a home page for the notebook. Its main purpose is to display the notebooks in the current directory. For example, here is a screenshot of the dashboard page for the `examples` directory in the IPython repository:\n",
55 "You can start more than one notebook server at the same time. By default, the first notebook server starts on port 8888 and later notebook servers search for open ports near that one.\n",
33 "\n",
56 "\n",
34 "<img src=\"images/dashboard_notebooks_tab.png\" />\n",
57 "You can also specify the port manually:\n",
35 "\n",
58 "\n",
36 "The top of the notebook list displays clickable breadcrumbs of the current directory. By clicking on these breadcrumbs or on sub-directories in the notebook list, you can navigate your file system.\n",
59 " ipython notebook --port 9999\n",
37 "\n",
60 "\n",
38 "To create a new notebook, click on the \"New Notebook\" button at the top of the list.\n",
61 "Or start notebook server without opening a web browser.\n",
39 "\n",
62 "\n",
40 "Notebooks can be uploaded to the current directory by dragging a notebook file onto the notebook list or by the \"click here\" text above the list.\n",
63 " ipython notebook --no-browser\n",
41 "\n",
64 "\n",
42 "The notebook list shows a red \"Shutdown\" button for running notebooks and a \"Delete\" button for stopped notebooks. Notebook remain running until you explicitly click the \"Shutdown\" button; closing the notebook's page is not sufficient.\n",
65 "The notebook server has a number of other command line arguments that can be displayed with the `--help` flag: \n",
43 "\n",
66 "\n",
44 "To see all of your running notebooks along with their directories, click on the \"Running\" tab:\n",
67 " ipython notebook --help"
68 ]
69 },
70 {
71 "cell_type": "markdown",
72 "metadata": {},
73 "source": [
74 "## The Notebook dashboard"
75 ]
76 },
77 {
78 "cell_type": "markdown",
79 "metadata": {},
80 "source": [
81 "When you first start the notebook server, your browser will open to the notebook dashboard. The dashboard serves as a home page for the notebook. Its main purpose is to display the notebooks and files in the current directory. For example, here is a screenshot of the dashboard page for the `examples` directory in the IPython repository:\n",
82 "\n",
83 "<img src=\"images/dashboard_files_tab.png\" width=\"791px\"/>"
84 ]
85 },
86 {
87 "cell_type": "markdown",
88 "metadata": {},
89 "source": [
90 "The top of the notebook list displays clickable breadcrumbs of the current directory. By clicking on these breadcrumbs or on sub-directories in the notebook list, you can navigate your file system.\n",
45 "\n",
91 "\n",
46 "<img src=\"images/dashboard_running_tab.png\" />\n",
92 "To create a new notebook, click on the \"New\" button at the top of the list and select a kernel from the dropdown (as seen below). Which kernels are listed depend on what's installed on the server. Some of the kernels in the screenshot below may not exist as an option to you.\n",
47 "\n",
93 "\n",
48 "This view provides a convenient way to track notebooks that you start as you navigate the file system in a long running notebook server."
94 "<img src=\"images/dashboard_files_tab_new.png\" width=\"202px\" />"
49 ]
95 ]
50 },
96 },
51 {
97 {
52 "cell_type": "markdown",
98 "cell_type": "markdown",
53 "metadata": {},
99 "metadata": {},
54 "source": [
100 "source": [
55 "## Overview of the Notebook UI"
101 "Notebooks and files can be uploaded to the current directory by dragging a notebook file onto the notebook list or by the \"click here\" text above the list.\n",
102 "\n",
103 "The notebook list shows green \"Running\" text and a green notebook icon next to running notebooks (as seen below). Notebooks remain running until you explicitly shut them down; closing the notebook's page is not sufficient.\n",
104 "\n",
105 "<img src=\"images/dashboard_files_tab_run.png\" width=\"777px\"/>"
56 ]
106 ]
57 },
107 },
58 {
108 {
59 "cell_type": "markdown",
109 "cell_type": "markdown",
60 "metadata": {},
110 "metadata": {},
61 "source": [
111 "source": [
62 "<div class=\"alert\">\n",
112 "To shutdown, delete, duplicate, or rename a notebook check the checkbox next to it and an array of controls will appear at the top of the notebook list (as seen below). You can also use the same operations on directories and files when applicable.\n",
63 "As of IPython 2.0, the user interface has changed significantly. Because of this we highly recommend existing users to review this information after upgrading to IPython 2.0. All new users of IPython should review this information as well.\n",
113 "\n",
64 "</div>"
114 "<img src=\"images/dashboard_files_tab_btns.png\" width=\"301px\" />"
115 ]
116 },
117 {
118 "cell_type": "markdown",
119 "metadata": {},
120 "source": [
121 "To see all of your running notebooks along with their directories, click on the \"Running\" tab:\n",
122 "\n",
123 "<img src=\"images/dashboard_running_tab.png\" width=\"786px\" />\n",
124 "\n",
125 "This view provides a convenient way to track notebooks that you start as you navigate the file system in a long running notebook server."
126 ]
127 },
128 {
129 "cell_type": "markdown",
130 "metadata": {},
131 "source": [
132 "## Overview of the Notebook UI"
65 ]
133 ]
66 },
134 },
67 {
135 {
68 "cell_type": "markdown",
136 "cell_type": "markdown",
69 "metadata": {},
137 "metadata": {},
70 "source": [
138 "source": [
71 "If you create a new notebook or open an existing one, you will be taken to the notebook user interface (UI). This UI allows you to run code and author notebook documents interactively. The notebook UI has the following main areas:\n",
139 "If you create a new notebook or open an existing one, you will be taken to the notebook user interface (UI). This UI allows you to run code and author notebook documents interactively. The notebook UI has the following main areas:\n",
72 "\n",
140 "\n",
73 "* Menu\n",
141 "* Menu\n",
74 "* Toolbar\n",
142 "* Toolbar\n",
75 "* Notebook area and cells\n",
143 "* Notebook area and cells\n",
76 "\n",
144 "\n",
77 "IPython 2.0 has an interactive tour of these elements that can be started in the \"Help:User Interface Tour\" menu item."
145 "The notebook has an interactive tour of these elements that can be started in the \"Help:User Interface Tour\" menu item."
78 ]
146 ]
79 },
147 },
80 {
148 {
81 "cell_type": "markdown",
149 "cell_type": "markdown",
82 "metadata": {},
150 "metadata": {},
83 "source": [
151 "source": [
84 "## Modal editor"
152 "## Modal editor"
85 ]
153 ]
86 },
154 },
87 {
155 {
88 "cell_type": "markdown",
156 "cell_type": "markdown",
89 "metadata": {},
157 "metadata": {},
90 "source": [
158 "source": [
91 "Starting with IPython 2.0, the IPython Notebook has a modal user interface. This means that the keyboard does different things depending on which mode the Notebook is in. There are two modes: edit mode and command mode."
159 "Starting with IPython 2.0, the IPython Notebook has a modal user interface. This means that the keyboard does different things depending on which mode the Notebook is in. There are two modes: edit mode and command mode."
92 ]
160 ]
93 },
161 },
94 {
162 {
95 "cell_type": "markdown",
163 "cell_type": "markdown",
96 "metadata": {},
164 "metadata": {},
97 "source": [
165 "source": [
98 "### Edit mode"
166 "### Edit mode"
99 ]
167 ]
100 },
168 },
101 {
169 {
102 "cell_type": "markdown",
170 "cell_type": "markdown",
103 "metadata": {},
171 "metadata": {},
104 "source": [
172 "source": [
105 "Edit mode is indicated by a green cell border and a prompt showing in the editor area:\n",
173 "Edit mode is indicated by a green cell border and a prompt showing in the editor area:\n",
106 "\n",
174 "\n",
107 "<img src=\"images/edit_mode.png\">\n",
175 "<img src=\"images/edit_mode.png\">\n",
108 "\n",
176 "\n",
109 "When a cell is in edit mode, you can type into the cell, like a normal text editor."
177 "When a cell is in edit mode, you can type into the cell, like a normal text editor."
110 ]
178 ]
111 },
179 },
112 {
180 {
113 "cell_type": "markdown",
181 "cell_type": "markdown",
114 "metadata": {},
182 "metadata": {},
115 "source": [
183 "source": [
116 "<div class=\"alert alert-success\">\n",
184 "<div class=\"alert alert-success\">\n",
117 "Enter edit mode by pressing `Enter` or using the mouse to click on a cell's editor area.\n",
185 "Enter edit mode by pressing `Enter` or using the mouse to click on a cell's editor area.\n",
118 "</div>"
186 "</div>"
119 ]
187 ]
120 },
188 },
121 {
189 {
122 "cell_type": "markdown",
190 "cell_type": "markdown",
123 "metadata": {},
191 "metadata": {},
124 "source": [
192 "source": [
125 "### Command mode"
193 "### Command mode"
126 ]
194 ]
127 },
195 },
128 {
196 {
129 "cell_type": "markdown",
197 "cell_type": "markdown",
130 "metadata": {},
198 "metadata": {},
131 "source": [
199 "source": [
132 "Command mode is indicated by a grey cell border:\n",
200 "Command mode is indicated by a grey cell border:\n",
133 "\n",
201 "\n",
134 "<img src=\"images/command_mode.png\">\n",
202 "<img src=\"images/command_mode.png\">\n",
135 "\n",
203 "\n",
136 "When you are in command mode, you are able to edit the notebook as a whole, but not type into individual cells. Most importantly, in command mode, the keyboard is mapped to a set of shortcuts that let you perform notebook and cell actions efficiently. For example, if you are in command mode and you press `c`, you will copy the current cell - no modifier is needed."
204 "When you are in command mode, you are able to edit the notebook as a whole, but not type into individual cells. Most importantly, in command mode, the keyboard is mapped to a set of shortcuts that let you perform notebook and cell actions efficiently. For example, if you are in command mode and you press `c`, you will copy the current cell - no modifier is needed."
137 ]
205 ]
138 },
206 },
139 {
207 {
140 "cell_type": "markdown",
208 "cell_type": "markdown",
141 "metadata": {},
209 "metadata": {},
142 "source": [
210 "source": [
143 "<div class=\"alert alert-error\">\n",
211 "<div class=\"alert alert-error\">\n",
144 "Don't try to type into a cell in command mode; unexpected things will happen!\n",
212 "Don't try to type into a cell in command mode; unexpected things will happen!\n",
145 "</div>"
213 "</div>"
146 ]
214 ]
147 },
215 },
148 {
216 {
149 "cell_type": "markdown",
217 "cell_type": "markdown",
150 "metadata": {},
218 "metadata": {},
151 "source": [
219 "source": [
152 "<div class=\"alert alert-success\">\n",
220 "<div class=\"alert alert-success\">\n",
153 "Enter command mode by pressing `Esc` or using the mouse to click *outside* a cell's editor area.\n",
221 "Enter command mode by pressing `Esc` or using the mouse to click *outside* a cell's editor area.\n",
154 "</div>"
222 "</div>"
155 ]
223 ]
156 },
224 },
157 {
225 {
158 "cell_type": "markdown",
226 "cell_type": "markdown",
159 "metadata": {},
227 "metadata": {},
160 "source": [
228 "source": [
161 "## Mouse navigation"
229 "## Mouse navigation"
162 ]
230 ]
163 },
231 },
164 {
232 {
165 "cell_type": "markdown",
233 "cell_type": "markdown",
166 "metadata": {},
234 "metadata": {},
167 "source": [
235 "source": [
168 "All navigation and actions in the Notebook are available using the mouse through the menubar and toolbar, which are both above the main Notebook area:\n",
236 "All navigation and actions in the Notebook are available using the mouse through the menubar and toolbar, which are both above the main Notebook area:\n",
169 "\n",
237 "\n",
170 "<img src=\"images/menubar_toolbar.png\">"
238 "<img src=\"images/menubar_toolbar.png\" width=\"786px\" />"
171 ]
239 ]
172 },
240 },
173 {
241 {
174 "cell_type": "markdown",
242 "cell_type": "markdown",
175 "metadata": {},
243 "metadata": {},
176 "source": [
244 "source": [
177 "The first idea of mouse based navigation is that **cells can be selected by clicking on them.** The currently selected cell gets a grey or green border depending on whether the notebook is in edit or command mode. If you click inside a cell's editor area, you will enter edit mode. If you click on the prompt or output area of a cell you will enter command mode.\n",
245 "The first idea of mouse based navigation is that **cells can be selected by clicking on them.** The currently selected cell gets a grey or green border depending on whether the notebook is in edit or command mode. If you click inside a cell's editor area, you will enter edit mode. If you click on the prompt or output area of a cell you will enter command mode.\n",
178 "\n",
246 "\n",
179 "If you are running this notebook in a live session (not on http://nbviewer.ipython.org) try selecting different cells and going between edit and command mode. Try typing into a cell."
247 "If you are running this notebook in a live session (not on http://nbviewer.ipython.org) try selecting different cells and going between edit and command mode. Try typing into a cell."
180 ]
248 ]
181 },
249 },
182 {
250 {
183 "cell_type": "markdown",
251 "cell_type": "markdown",
184 "metadata": {},
252 "metadata": {},
185 "source": [
253 "source": [
186 "The second idea of mouse based navigation is that **cell actions usually apply to the currently selected cell**. Thus if you want to run the code in a cell, you would select it and click the <button class='btn btn-default btn-xs'><i class=\"fa fa-play icon-play\"></i></button> button in the toolbar or the \"Cell:Run\" menu item. Similarly, to copy a cell you would select it and click the <button class='btn btn-default btn-xs'><i class=\"fa fa-copy icon-copy\"></i></button> button in the toolbar or the \"Edit:Copy\" menu item. With this simple pattern, you should be able to do most everything you need with the mouse.\n",
254 "The second idea of mouse based navigation is that **cell actions usually apply to the currently selected cell**. Thus if you want to run the code in a cell, you would select it and click the <button class='btn btn-default btn-xs'><i class=\"fa fa-play icon-play\"></i></button> button in the toolbar or the \"Cell:Run\" menu item. Similarly, to copy a cell you would select it and click the <button class='btn btn-default btn-xs'><i class=\"fa fa-copy icon-copy\"></i></button> button in the toolbar or the \"Edit:Copy\" menu item. With this simple pattern, you should be able to do most everything you need with the mouse.\n",
187 "\n",
255 "\n",
188 "Markdown and heading cells have one other state that can be modified with the mouse. These cells can either be rendered or unrendered. When they are rendered, you will see a nice formatted representation of the cell's contents. When they are unrendered, you will see the raw text source of the cell. To render the selected cell with the mouse, click the <button class='btn btn-default btn-xs'><i class=\"fa fa-play icon-play\"></i></button> button in the toolbar or the \"Cell:Run\" menu item. To unrender the selected cell, double click on the cell."
256 "Markdown and heading cells have one other state that can be modified with the mouse. These cells can either be rendered or unrendered. When they are rendered, you will see a nice formatted representation of the cell's contents. When they are unrendered, you will see the raw text source of the cell. To render the selected cell with the mouse, click the <button class='btn btn-default btn-xs'><i class=\"fa fa-play icon-play\"></i></button> button in the toolbar or the \"Cell:Run\" menu item. To unrender the selected cell, double click on the cell."
189 ]
257 ]
190 },
258 },
191 {
259 {
192 "cell_type": "markdown",
260 "cell_type": "markdown",
193 "metadata": {},
261 "metadata": {},
194 "source": [
262 "source": [
195 "## Keyboard Navigation"
263 "## Keyboard Navigation"
196 ]
264 ]
197 },
265 },
198 {
266 {
199 "cell_type": "markdown",
267 "cell_type": "markdown",
200 "metadata": {},
268 "metadata": {},
201 "source": [
269 "source": [
202 "The modal user interface of the IPython Notebook has been optimized for efficient keyboard usage. This is made possible by having two different sets of keyboard shortcuts: one set that is active in edit mode and another in command mode.\n",
270 "The modal user interface of the IPython Notebook has been optimized for efficient keyboard usage. This is made possible by having two different sets of keyboard shortcuts: one set that is active in edit mode and another in command mode.\n",
203 "\n",
271 "\n",
204 "The most important keyboard shortcuts are `Enter`, which enters edit mode, and `Esc`, which enters command mode.\n",
272 "The most important keyboard shortcuts are `Enter`, which enters edit mode, and `Esc`, which enters command mode.\n",
205 "\n",
273 "\n",
206 "In edit mode, most of the keyboard is dedicated to typing into the cell's editor. Thus, in edit mode there are relatively few shortcuts:\n",
274 "In edit mode, most of the keyboard is dedicated to typing into the cell's editor. Thus, in edit mode there are relatively few shortcuts. In command mode, the entire keyboard is available for shortcuts, so there are many more. The `Help`->`Keyboard Shortcuts` dialog lists the available shortcuts."
207 "\n",
208 "<img src=\"images/edit_shortcuts.png\">"
209 ]
210 },
211 {
212 "cell_type": "markdown",
213 "metadata": {},
214 "source": [
215 "In command mode, the entire keyboard is available for shortcuts, so there are many more:\n",
216 "\n",
217 "<img src=\"images/command_shortcuts.png\">"
218 ]
275 ]
219 },
276 },
220 {
277 {
221 "cell_type": "markdown",
278 "cell_type": "markdown",
222 "metadata": {},
279 "metadata": {},
223 "source": [
280 "source": [
224 "We recommend learning the command mode shortcuts in the following rough order:\n",
281 "We recommend learning the command mode shortcuts in the following rough order:\n",
225 "\n",
282 "\n",
226 "1. Basic navigation: `enter`, `shift-enter`, `up/k`, `down/j`\n",
283 "1. Basic navigation: `enter`, `shift-enter`, `up/k`, `down/j`\n",
227 "2. Saving the notebook: `s`\n",
284 "2. Saving the notebook: `s`\n",
228 "2. Cell types: `y`, `m`, `1-6`, `t`\n",
285 "2. Cell types: `y`, `m`, `1-6`, `t`\n",
229 "3. Cell creation: `a`, `b`\n",
286 "3. Cell creation: `a`, `b`\n",
230 "4. Cell editing: `x`, `c`, `v`, `d`, `z`, `shift+=`\n",
287 "4. Cell editing: `x`, `c`, `v`, `d`, `z`, `shift+=`\n",
231 "5. Kernel operations: `i`, `.`"
288 "5. Kernel operations: `i`, `.`"
232 ]
289 ]
233 }
290 }
234 ],
291 ],
235 "metadata": {
292 "metadata": {
236 "kernelspec": {
293 "kernelspec": {
237 "display_name": "Python 3",
294 "display_name": "Python 3",
238 "language": "python",
295 "language": "python",
239 "name": "python3"
296 "name": "python3"
240 },
297 },
241 "language_info": {
298 "language_info": {
242 "codemirror_mode": {
299 "codemirror_mode": {
243 "name": "ipython",
300 "name": "ipython",
244 "version": 3
301 "version": 3
245 },
302 },
246 "file_extension": ".py",
303 "file_extension": ".py",
247 "mimetype": "text/x-python",
304 "mimetype": "text/x-python",
248 "name": "python",
305 "name": "python",
249 "nbconvert_exporter": "python",
306 "nbconvert_exporter": "python",
250 "pygments_lexer": "ipython3",
307 "pygments_lexer": "ipython3",
251 "version": "3.4.2"
308 "version": "3.4.3"
252 }
309 }
253 },
310 },
254 "nbformat": 4,
311 "nbformat": 4,
255 "nbformat_minor": 0
312 "nbformat_minor": 0
256 }
313 }
This diff has been collapsed as it changes many lines, (631 lines changed) Show them Hide them
@@ -1,892 +1,289 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "# Running Code"
7 "# Running Code"
8 ]
8 ]
9 },
9 },
10 {
10 {
11 "cell_type": "markdown",
11 "cell_type": "markdown",
12 "metadata": {},
12 "metadata": {},
13 "source": [
13 "source": [
14 "First and foremost, the IPython Notebook is an interactive environment for writing and running code. IPython is capable of running code in a wide range of languages. However, this notebook, and the default kernel in IPython 2.0, runs Python code."
14 "First and foremost, the IPython Notebook is an interactive environment for writing and running code. IPython is capable of running code in a wide range of languages. However, this notebook, and the default kernel in IPython 2.0, runs Python code."
15 ]
15 ]
16 },
16 },
17 {
17 {
18 "cell_type": "markdown",
18 "cell_type": "markdown",
19 "metadata": {},
19 "metadata": {},
20 "source": [
20 "source": [
21 "## Code cells allow you to enter and run Python code"
21 "## Code cells allow you to enter and run Python code"
22 ]
22 ]
23 },
23 },
24 {
24 {
25 "cell_type": "markdown",
25 "cell_type": "markdown",
26 "metadata": {},
26 "metadata": {},
27 "source": [
27 "source": [
28 "Run a code cell using `Shift-Enter` or pressing the <button class='btn btn-default btn-xs'><i class=\"icon-play fa fa-play\"></i></button> button in the toolbar above:"
28 "Run a code cell using `Shift-Enter` or pressing the <button class='btn btn-default btn-xs'><i class=\"icon-play fa fa-play\"></i></button> button in the toolbar above:"
29 ]
29 ]
30 },
30 },
31 {
31 {
32 "cell_type": "code",
32 "cell_type": "code",
33 "execution_count": 1,
33 "execution_count": null,
34 "metadata": {
34 "metadata": {
35 "collapsed": false
35 "collapsed": false
36 },
36 },
37 "outputs": [],
37 "outputs": [],
38 "source": [
38 "source": [
39 "a = 10"
39 "a = 10"
40 ]
40 ]
41 },
41 },
42 {
42 {
43 "cell_type": "code",
43 "cell_type": "code",
44 "execution_count": 2,
44 "execution_count": null,
45 "metadata": {
45 "metadata": {
46 "collapsed": false
46 "collapsed": false
47 },
47 },
48 "outputs": [
48 "outputs": [],
49 {
50 "name": "stdout",
51 "output_type": "stream",
52 "text": [
53 "10\n"
54 ]
55 }
56 ],
57 "source": [
49 "source": [
58 "print(a)"
50 "print(a)"
59 ]
51 ]
60 },
52 },
61 {
53 {
62 "cell_type": "markdown",
54 "cell_type": "markdown",
63 "metadata": {},
55 "metadata": {},
64 "source": [
56 "source": [
65 "There are two other keyboard shortcuts for running code:\n",
57 "There are two other keyboard shortcuts for running code:\n",
66 "\n",
58 "\n",
67 "* `Alt-Enter` runs the current cell and inserts a new one below.\n",
59 "* `Alt-Enter` runs the current cell and inserts a new one below.\n",
68 "* `Ctrl-Enter` run the current cell and enters command mode."
60 "* `Ctrl-Enter` run the current cell and enters command mode."
69 ]
61 ]
70 },
62 },
71 {
63 {
72 "cell_type": "markdown",
64 "cell_type": "markdown",
73 "metadata": {},
65 "metadata": {},
74 "source": [
66 "source": [
75 "## Managing the IPython Kernel"
67 "## Managing the IPython Kernel"
76 ]
68 ]
77 },
69 },
78 {
70 {
79 "cell_type": "markdown",
71 "cell_type": "markdown",
80 "metadata": {},
72 "metadata": {},
81 "source": [
73 "source": [
82 "Code is run in a separate process called the IPython Kernel. The Kernel can be interrupted or restarted. Try running the following cell and then hit the <button class='btn btn-default btn-xs'><i class='icon-stop fa fa-stop'></i></button> button in the toolbar above."
74 "Code is run in a separate process called the IPython Kernel. The Kernel can be interrupted or restarted. Try running the following cell and then hit the <button class='btn btn-default btn-xs'><i class='icon-stop fa fa-stop'></i></button> button in the toolbar above."
83 ]
75 ]
84 },
76 },
85 {
77 {
86 "cell_type": "code",
78 "cell_type": "code",
87 "execution_count": null,
79 "execution_count": null,
88 "metadata": {
80 "metadata": {
89 "collapsed": false
81 "collapsed": false
90 },
82 },
91 "outputs": [],
83 "outputs": [],
92 "source": [
84 "source": [
93 "import time\n",
85 "import time\n",
94 "time.sleep(10)"
86 "time.sleep(10)"
95 ]
87 ]
96 },
88 },
97 {
89 {
98 "cell_type": "markdown",
90 "cell_type": "markdown",
99 "metadata": {},
91 "metadata": {},
100 "source": [
92 "source": [
101 "If the Kernel dies you will be prompted to restart it. Here we call the low-level system libc.time routine with the wrong argument via\n",
93 "If the Kernel dies you will be prompted to restart it. Here we call the low-level system libc.time routine with the wrong argument via\n",
102 "ctypes to segfault the Python interpreter:"
94 "ctypes to segfault the Python interpreter:"
103 ]
95 ]
104 },
96 },
105 {
97 {
106 "cell_type": "code",
98 "cell_type": "code",
107 "execution_count": null,
99 "execution_count": null,
108 "metadata": {
100 "metadata": {
109 "collapsed": false
101 "collapsed": false
110 },
102 },
111 "outputs": [],
103 "outputs": [],
112 "source": [
104 "source": [
113 "import sys\n",
105 "import sys\n",
114 "from ctypes import CDLL\n",
106 "from ctypes import CDLL\n",
115 "# This will crash a Linux or Mac system\n",
107 "# This will crash a Linux or Mac system\n",
116 "# equivalent calls can be made on Windows\n",
108 "# equivalent calls can be made on Windows\n",
117 "dll = 'dylib' if sys.platform == 'darwin' else 'so.6'\n",
109 "dll = 'dylib' if sys.platform == 'darwin' else 'so.6'\n",
118 "libc = CDLL(\"libc.%s\" % dll) \n",
110 "libc = CDLL(\"libc.%s\" % dll) \n",
119 "libc.time(-1) # BOOM!!"
111 "libc.time(-1) # BOOM!!"
120 ]
112 ]
121 },
113 },
122 {
114 {
123 "cell_type": "markdown",
115 "cell_type": "markdown",
124 "metadata": {},
116 "metadata": {},
125 "source": [
117 "source": [
126 "## Cell menu"
118 "## Cell menu"
127 ]
119 ]
128 },
120 },
129 {
121 {
130 "cell_type": "markdown",
122 "cell_type": "markdown",
131 "metadata": {},
123 "metadata": {},
132 "source": [
124 "source": [
133 "The \"Cell\" menu has a number of menu items for running code in different ways. These includes:\n",
125 "The \"Cell\" menu has a number of menu items for running code in different ways. These includes:\n",
134 "\n",
126 "\n",
135 "* Run and Select Below\n",
127 "* Run and Select Below\n",
136 "* Run and Insert Below\n",
128 "* Run and Insert Below\n",
137 "* Run All\n",
129 "* Run All\n",
138 "* Run All Above\n",
130 "* Run All Above\n",
139 "* Run All Below"
131 "* Run All Below"
140 ]
132 ]
141 },
133 },
142 {
134 {
143 "cell_type": "markdown",
135 "cell_type": "markdown",
144 "metadata": {},
136 "metadata": {},
145 "source": [
137 "source": [
146 "## Restarting the kernels"
138 "## Restarting the kernels"
147 ]
139 ]
148 },
140 },
149 {
141 {
150 "cell_type": "markdown",
142 "cell_type": "markdown",
151 "metadata": {},
143 "metadata": {},
152 "source": [
144 "source": [
153 "The kernel maintains the state of a notebook's computations. You can reset this state by restarting the kernel. This is done by clicking on the <button class='btn btn-default btn-xs'><i class='fa fa-repeat icon-repeat'></i></button> in the toolbar above."
145 "The kernel maintains the state of a notebook's computations. You can reset this state by restarting the kernel. This is done by clicking on the <button class='btn btn-default btn-xs'><i class='fa fa-repeat icon-repeat'></i></button> in the toolbar above."
154 ]
146 ]
155 },
147 },
156 {
148 {
157 "cell_type": "markdown",
149 "cell_type": "markdown",
158 "metadata": {},
150 "metadata": {},
159 "source": [
151 "source": [
160 "## sys.stdout and sys.stderr"
152 "## sys.stdout and sys.stderr"
161 ]
153 ]
162 },
154 },
163 {
155 {
164 "cell_type": "markdown",
156 "cell_type": "markdown",
165 "metadata": {},
157 "metadata": {},
166 "source": [
158 "source": [
167 "The stdout and stderr streams are displayed as text in the output area."
159 "The stdout and stderr streams are displayed as text in the output area."
168 ]
160 ]
169 },
161 },
170 {
162 {
171 "cell_type": "code",
163 "cell_type": "code",
172 "execution_count": 2,
164 "execution_count": null,
173 "metadata": {
165 "metadata": {
174 "collapsed": false
166 "collapsed": false
175 },
167 },
176 "outputs": [
168 "outputs": [],
177 {
178 "name": "stdout",
179 "output_type": "stream",
180 "text": [
181 "hi, stdout\n"
182 ]
183 }
184 ],
185 "source": [
169 "source": [
186 "print(\"hi, stdout\")"
170 "print(\"hi, stdout\")"
187 ]
171 ]
188 },
172 },
189 {
173 {
190 "cell_type": "code",
174 "cell_type": "code",
191 "execution_count": 3,
175 "execution_count": null,
192 "metadata": {
176 "metadata": {
193 "collapsed": false
177 "collapsed": false
194 },
178 },
195 "outputs": [
179 "outputs": [],
196 {
197 "name": "stderr",
198 "output_type": "stream",
199 "text": [
200 "hi, stderr\n"
201 ]
202 }
203 ],
204 "source": [
180 "source": [
205 "from __future__ import print_function\n",
181 "from __future__ import print_function\n",
206 "print('hi, stderr', file=sys.stderr)"
182 "print('hi, stderr', file=sys.stderr)"
207 ]
183 ]
208 },
184 },
209 {
185 {
210 "cell_type": "markdown",
186 "cell_type": "markdown",
211 "metadata": {},
187 "metadata": {},
212 "source": [
188 "source": [
213 "## Output is asynchronous"
189 "## Output is asynchronous"
214 ]
190 ]
215 },
191 },
216 {
192 {
217 "cell_type": "markdown",
193 "cell_type": "markdown",
218 "metadata": {},
194 "metadata": {},
219 "source": [
195 "source": [
220 "All output is displayed asynchronously as it is generated in the Kernel. If you execute the next cell, you will see the output one piece at a time, not all at the end."
196 "All output is displayed asynchronously as it is generated in the Kernel. If you execute the next cell, you will see the output one piece at a time, not all at the end."
221 ]
197 ]
222 },
198 },
223 {
199 {
224 "cell_type": "code",
200 "cell_type": "code",
225 "execution_count": 4,
201 "execution_count": null,
226 "metadata": {
202 "metadata": {
227 "collapsed": false
203 "collapsed": false
228 },
204 },
229 "outputs": [
205 "outputs": [],
230 {
231 "name": "stdout",
232 "output_type": "stream",
233 "text": [
234 "0\n",
235 "1\n",
236 "2\n",
237 "3\n",
238 "4\n",
239 "5\n",
240 "6\n",
241 "7\n"
242 ]
243 }
244 ],
245 "source": [
206 "source": [
246 "import time, sys\n",
207 "import time, sys\n",
247 "for i in range(8):\n",
208 "for i in range(8):\n",
248 " print(i)\n",
209 " print(i)\n",
249 " time.sleep(0.5)"
210 " time.sleep(0.5)"
250 ]
211 ]
251 },
212 },
252 {
213 {
253 "cell_type": "markdown",
214 "cell_type": "markdown",
254 "metadata": {},
215 "metadata": {},
255 "source": [
216 "source": [
256 "## Large outputs"
217 "## Large outputs"
257 ]
218 ]
258 },
219 },
259 {
220 {
260 "cell_type": "markdown",
221 "cell_type": "markdown",
261 "metadata": {},
222 "metadata": {},
262 "source": [
223 "source": [
263 "To better handle large outputs, the output area can be collapsed. Run the following cell and then single- or double- click on the active area to the left of the output:"
224 "To better handle large outputs, the output area can be collapsed. Run the following cell and then single- or double- click on the active area to the left of the output:"
264 ]
225 ]
265 },
226 },
266 {
227 {
267 "cell_type": "code",
228 "cell_type": "code",
268 "execution_count": 5,
229 "execution_count": null,
269 "metadata": {
230 "metadata": {
270 "collapsed": false
231 "collapsed": false
271 },
232 },
272 "outputs": [
233 "outputs": [],
273 {
274 "name": "stdout",
275 "output_type": "stream",
276 "text": [
277 "0\n",
278 "1\n",
279 "2\n",
280 "3\n",
281 "4\n",
282 "5\n",
283 "6\n",
284 "7\n",
285 "8\n",
286 "9\n",
287 "10\n",
288 "11\n",
289 "12\n",
290 "13\n",
291 "14\n",
292 "15\n",
293 "16\n",
294 "17\n",
295 "18\n",
296 "19\n",
297 "20\n",
298 "21\n",
299 "22\n",
300 "23\n",
301 "24\n",
302 "25\n",
303 "26\n",
304 "27\n",
305 "28\n",
306 "29\n",
307 "30\n",
308 "31\n",
309 "32\n",
310 "33\n",
311 "34\n",
312 "35\n",
313 "36\n",
314 "37\n",
315 "38\n",
316 "39\n",
317 "40\n",
318 "41\n",
319 "42\n",
320 "43\n",
321 "44\n",
322 "45\n",
323 "46\n",
324 "47\n",
325 "48\n",
326 "49\n"
327 ]
328 }
329 ],
330 "source": [
234 "source": [
331 "for i in range(50):\n",
235 "for i in range(50):\n",
332 " print(i)"
236 " print(i)"
333 ]
237 ]
334 },
238 },
335 {
239 {
336 "cell_type": "markdown",
240 "cell_type": "markdown",
337 "metadata": {},
241 "metadata": {},
338 "source": [
242 "source": [
339 "Beyond a certain point, output will scroll automatically:"
243 "Beyond a certain point, output will scroll automatically:"
340 ]
244 ]
341 },
245 },
342 {
246 {
343 "cell_type": "code",
247 "cell_type": "code",
344 "execution_count": 6,
248 "execution_count": null,
345 "metadata": {
249 "metadata": {
346 "collapsed": false
250 "collapsed": false
347 },
251 },
348 "outputs": [
252 "outputs": [],
349 {
350 "name": "stdout",
351 "output_type": "stream",
352 "text": [
353 "0\n",
354 "1\n",
355 "3\n",
356 "7\n",
357 "15\n",
358 "31\n",
359 "63\n",
360 "127\n",
361 "255\n",
362 "511\n",
363 "1023\n",
364 "2047\n",
365 "4095\n",
366 "8191\n",
367 "16383\n",
368 "32767\n",
369 "65535\n",
370 "131071\n",
371 "262143\n",
372 "524287\n",
373 "1048575\n",
374 "2097151\n",
375 "4194303\n",
376 "8388607\n",
377 "16777215\n",
378 "33554431\n",
379 "67108863\n",
380 "134217727\n",
381 "268435455\n",
382 "536870911\n",
383 "1073741823\n",
384 "2147483647\n",
385 "4294967295\n",
386 "8589934591\n",
387 "17179869183\n",
388 "34359738367\n",
389 "68719476735\n",
390 "137438953471\n",
391 "274877906943\n",
392 "549755813887\n",
393 "1099511627775\n",
394 "2199023255551\n",
395 "4398046511103\n",
396 "8796093022207\n",
397 "17592186044415\n",
398 "35184372088831\n",
399 "70368744177663\n",
400 "140737488355327\n",
401 "281474976710655\n",
402 "562949953421311\n",
403 "1125899906842623\n",
404 "2251799813685247\n",
405 "4503599627370495\n",
406 "9007199254740991\n",
407 "18014398509481983\n",
408 "36028797018963967\n",
409 "72057594037927935\n",
410 "144115188075855871\n",
411 "288230376151711743\n",
412 "576460752303423487\n",
413 "1152921504606846975\n",
414 "2305843009213693951\n",
415 "4611686018427387903\n",
416 "9223372036854775807\n",
417 "18446744073709551615\n",
418 "36893488147419103231\n",
419 "73786976294838206463\n",
420 "147573952589676412927\n",
421 "295147905179352825855\n",
422 "590295810358705651711\n",
423 "1180591620717411303423\n",
424 "2361183241434822606847\n",
425 "4722366482869645213695\n",
426 "9444732965739290427391\n",
427 "18889465931478580854783\n",
428 "37778931862957161709567\n",
429 "75557863725914323419135\n",
430 "151115727451828646838271\n",
431 "302231454903657293676543\n",
432 "604462909807314587353087\n",
433 "1208925819614629174706175\n",
434 "2417851639229258349412351\n",
435 "4835703278458516698824703\n",
436 "9671406556917033397649407\n",
437 "19342813113834066795298815\n",
438 "38685626227668133590597631\n",
439 "77371252455336267181195263\n",
440 "154742504910672534362390527\n",
441 "309485009821345068724781055\n",
442 "618970019642690137449562111\n",
443 "1237940039285380274899124223\n",
444 "2475880078570760549798248447\n",
445 "4951760157141521099596496895\n",
446 "9903520314283042199192993791\n",
447 "19807040628566084398385987583\n",
448 "39614081257132168796771975167\n",
449 "79228162514264337593543950335\n",
450 "158456325028528675187087900671\n",
451 "316912650057057350374175801343\n",
452 "633825300114114700748351602687\n",
453 "1267650600228229401496703205375\n",
454 "2535301200456458802993406410751\n",
455 "5070602400912917605986812821503\n",
456 "10141204801825835211973625643007\n",
457 "20282409603651670423947251286015\n",
458 "40564819207303340847894502572031\n",
459 "81129638414606681695789005144063\n",
460 "162259276829213363391578010288127\n",
461 "324518553658426726783156020576255\n",
462 "649037107316853453566312041152511\n",
463 "1298074214633706907132624082305023\n",
464 "2596148429267413814265248164610047\n",
465 "5192296858534827628530496329220095\n",
466 "10384593717069655257060992658440191\n",
467 "20769187434139310514121985316880383\n",
468 "41538374868278621028243970633760767\n",
469 "83076749736557242056487941267521535\n",
470 "166153499473114484112975882535043071\n",
471 "332306998946228968225951765070086143\n",
472 "664613997892457936451903530140172287\n",
473 "1329227995784915872903807060280344575\n",
474 "2658455991569831745807614120560689151\n",
475 "5316911983139663491615228241121378303\n",
476 "10633823966279326983230456482242756607\n",
477 "21267647932558653966460912964485513215\n",
478 "42535295865117307932921825928971026431\n",
479 "85070591730234615865843651857942052863\n",
480 "170141183460469231731687303715884105727\n",
481 "340282366920938463463374607431768211455\n",
482 "680564733841876926926749214863536422911\n",
483 "1361129467683753853853498429727072845823\n",
484 "2722258935367507707706996859454145691647\n",
485 "5444517870735015415413993718908291383295\n",
486 "10889035741470030830827987437816582766591\n",
487 "21778071482940061661655974875633165533183\n",
488 "43556142965880123323311949751266331066367\n",
489 "87112285931760246646623899502532662132735\n",
490 "174224571863520493293247799005065324265471\n",
491 "348449143727040986586495598010130648530943\n",
492 "696898287454081973172991196020261297061887\n",
493 "1393796574908163946345982392040522594123775\n",
494 "2787593149816327892691964784081045188247551\n",
495 "5575186299632655785383929568162090376495103\n",
496 "11150372599265311570767859136324180752990207\n",
497 "22300745198530623141535718272648361505980415\n",
498 "44601490397061246283071436545296723011960831\n",
499 "89202980794122492566142873090593446023921663\n",
500 "178405961588244985132285746181186892047843327\n",
501 "356811923176489970264571492362373784095686655\n",
502 "713623846352979940529142984724747568191373311\n",
503 "1427247692705959881058285969449495136382746623\n",
504 "2854495385411919762116571938898990272765493247\n",
505 "5708990770823839524233143877797980545530986495\n",
506 "11417981541647679048466287755595961091061972991\n",
507 "22835963083295358096932575511191922182123945983\n",
508 "45671926166590716193865151022383844364247891967\n",
509 "91343852333181432387730302044767688728495783935\n",
510 "182687704666362864775460604089535377456991567871\n",
511 "365375409332725729550921208179070754913983135743\n",
512 "730750818665451459101842416358141509827966271487\n",
513 "1461501637330902918203684832716283019655932542975\n",
514 "2923003274661805836407369665432566039311865085951\n",
515 "5846006549323611672814739330865132078623730171903\n",
516 "11692013098647223345629478661730264157247460343807\n",
517 "23384026197294446691258957323460528314494920687615\n",
518 "46768052394588893382517914646921056628989841375231\n",
519 "93536104789177786765035829293842113257979682750463\n",
520 "187072209578355573530071658587684226515959365500927\n",
521 "374144419156711147060143317175368453031918731001855\n",
522 "748288838313422294120286634350736906063837462003711\n",
523 "1496577676626844588240573268701473812127674924007423\n",
524 "2993155353253689176481146537402947624255349848014847\n",
525 "5986310706507378352962293074805895248510699696029695\n",
526 "11972621413014756705924586149611790497021399392059391\n",
527 "23945242826029513411849172299223580994042798784118783\n",
528 "47890485652059026823698344598447161988085597568237567\n",
529 "95780971304118053647396689196894323976171195136475135\n",
530 "191561942608236107294793378393788647952342390272950271\n",
531 "383123885216472214589586756787577295904684780545900543\n",
532 "766247770432944429179173513575154591809369561091801087\n",
533 "1532495540865888858358347027150309183618739122183602175\n",
534 "3064991081731777716716694054300618367237478244367204351\n",
535 "6129982163463555433433388108601236734474956488734408703\n",
536 "12259964326927110866866776217202473468949912977468817407\n",
537 "24519928653854221733733552434404946937899825954937634815\n",
538 "49039857307708443467467104868809893875799651909875269631\n",
539 "98079714615416886934934209737619787751599303819750539263\n",
540 "196159429230833773869868419475239575503198607639501078527\n",
541 "392318858461667547739736838950479151006397215279002157055\n",
542 "784637716923335095479473677900958302012794430558004314111\n",
543 "1569275433846670190958947355801916604025588861116008628223\n",
544 "3138550867693340381917894711603833208051177722232017256447\n",
545 "6277101735386680763835789423207666416102355444464034512895\n",
546 "12554203470773361527671578846415332832204710888928069025791\n",
547 "25108406941546723055343157692830665664409421777856138051583\n",
548 "50216813883093446110686315385661331328818843555712276103167\n",
549 "100433627766186892221372630771322662657637687111424552206335\n",
550 "200867255532373784442745261542645325315275374222849104412671\n",
551 "401734511064747568885490523085290650630550748445698208825343\n",
552 "803469022129495137770981046170581301261101496891396417650687\n",
553 "1606938044258990275541962092341162602522202993782792835301375\n",
554 "3213876088517980551083924184682325205044405987565585670602751\n",
555 "6427752177035961102167848369364650410088811975131171341205503\n",
556 "12855504354071922204335696738729300820177623950262342682411007\n",
557 "25711008708143844408671393477458601640355247900524685364822015\n",
558 "51422017416287688817342786954917203280710495801049370729644031\n",
559 "102844034832575377634685573909834406561420991602098741459288063\n",
560 "205688069665150755269371147819668813122841983204197482918576127\n",
561 "411376139330301510538742295639337626245683966408394965837152255\n",
562 "822752278660603021077484591278675252491367932816789931674304511\n",
563 "1645504557321206042154969182557350504982735865633579863348609023\n",
564 "3291009114642412084309938365114701009965471731267159726697218047\n",
565 "6582018229284824168619876730229402019930943462534319453394436095\n",
566 "13164036458569648337239753460458804039861886925068638906788872191\n",
567 "26328072917139296674479506920917608079723773850137277813577744383\n",
568 "52656145834278593348959013841835216159447547700274555627155488767\n",
569 "105312291668557186697918027683670432318895095400549111254310977535\n",
570 "210624583337114373395836055367340864637790190801098222508621955071\n",
571 "421249166674228746791672110734681729275580381602196445017243910143\n",
572 "842498333348457493583344221469363458551160763204392890034487820287\n",
573 "1684996666696914987166688442938726917102321526408785780068975640575\n",
574 "3369993333393829974333376885877453834204643052817571560137951281151\n",
575 "6739986666787659948666753771754907668409286105635143120275902562303\n",
576 "13479973333575319897333507543509815336818572211270286240551805124607\n",
577 "26959946667150639794667015087019630673637144422540572481103610249215\n",
578 "53919893334301279589334030174039261347274288845081144962207220498431\n",
579 "107839786668602559178668060348078522694548577690162289924414440996863\n",
580 "215679573337205118357336120696157045389097155380324579848828881993727\n",
581 "431359146674410236714672241392314090778194310760649159697657763987455\n",
582 "862718293348820473429344482784628181556388621521298319395315527974911\n",
583 "1725436586697640946858688965569256363112777243042596638790631055949823\n",
584 "3450873173395281893717377931138512726225554486085193277581262111899647\n",
585 "6901746346790563787434755862277025452451108972170386555162524223799295\n",
586 "13803492693581127574869511724554050904902217944340773110325048447598591\n",
587 "27606985387162255149739023449108101809804435888681546220650096895197183\n",
588 "55213970774324510299478046898216203619608871777363092441300193790394367\n",
589 "110427941548649020598956093796432407239217743554726184882600387580788735\n",
590 "220855883097298041197912187592864814478435487109452369765200775161577471\n",
591 "441711766194596082395824375185729628956870974218904739530401550323154943\n",
592 "883423532389192164791648750371459257913741948437809479060803100646309887\n",
593 "1766847064778384329583297500742918515827483896875618958121606201292619775\n",
594 "3533694129556768659166595001485837031654967793751237916243212402585239551\n",
595 "7067388259113537318333190002971674063309935587502475832486424805170479103\n",
596 "14134776518227074636666380005943348126619871175004951664972849610340958207\n",
597 "28269553036454149273332760011886696253239742350009903329945699220681916415\n",
598 "56539106072908298546665520023773392506479484700019806659891398441363832831\n",
599 "113078212145816597093331040047546785012958969400039613319782796882727665663\n",
600 "226156424291633194186662080095093570025917938800079226639565593765455331327\n",
601 "452312848583266388373324160190187140051835877600158453279131187530910662655\n",
602 "904625697166532776746648320380374280103671755200316906558262375061821325311\n",
603 "1809251394333065553493296640760748560207343510400633813116524750123642650623\n",
604 "3618502788666131106986593281521497120414687020801267626233049500247285301247\n",
605 "7237005577332262213973186563042994240829374041602535252466099000494570602495\n",
606 "14474011154664524427946373126085988481658748083205070504932198000989141204991\n",
607 "28948022309329048855892746252171976963317496166410141009864396001978282409983\n",
608 "57896044618658097711785492504343953926634992332820282019728792003956564819967\n",
609 "115792089237316195423570985008687907853269984665640564039457584007913129639935\n",
610 "231584178474632390847141970017375815706539969331281128078915168015826259279871\n",
611 "463168356949264781694283940034751631413079938662562256157830336031652518559743\n",
612 "926336713898529563388567880069503262826159877325124512315660672063305037119487\n",
613 "1852673427797059126777135760139006525652319754650249024631321344126610074238975\n",
614 "3705346855594118253554271520278013051304639509300498049262642688253220148477951\n",
615 "7410693711188236507108543040556026102609279018600996098525285376506440296955903\n",
616 "14821387422376473014217086081112052205218558037201992197050570753012880593911807\n",
617 "29642774844752946028434172162224104410437116074403984394101141506025761187823615\n",
618 "59285549689505892056868344324448208820874232148807968788202283012051522375647231\n",
619 "118571099379011784113736688648896417641748464297615937576404566024103044751294463\n",
620 "237142198758023568227473377297792835283496928595231875152809132048206089502588927\n",
621 "474284397516047136454946754595585670566993857190463750305618264096412179005177855\n",
622 "948568795032094272909893509191171341133987714380927500611236528192824358010355711\n",
623 "1897137590064188545819787018382342682267975428761855001222473056385648716020711423\n",
624 "3794275180128377091639574036764685364535950857523710002444946112771297432041422847\n",
625 "7588550360256754183279148073529370729071901715047420004889892225542594864082845695\n",
626 "15177100720513508366558296147058741458143803430094840009779784451085189728165691391\n",
627 "30354201441027016733116592294117482916287606860189680019559568902170379456331382783\n",
628 "60708402882054033466233184588234965832575213720379360039119137804340758912662765567\n",
629 "121416805764108066932466369176469931665150427440758720078238275608681517825325531135\n",
630 "242833611528216133864932738352939863330300854881517440156476551217363035650651062271\n",
631 "485667223056432267729865476705879726660601709763034880312953102434726071301302124543\n",
632 "971334446112864535459730953411759453321203419526069760625906204869452142602604249087\n",
633 "1942668892225729070919461906823518906642406839052139521251812409738904285205208498175\n",
634 "3885337784451458141838923813647037813284813678104279042503624819477808570410416996351\n",
635 "7770675568902916283677847627294075626569627356208558085007249638955617140820833992703\n",
636 "15541351137805832567355695254588151253139254712417116170014499277911234281641667985407\n",
637 "31082702275611665134711390509176302506278509424834232340028998555822468563283335970815\n",
638 "62165404551223330269422781018352605012557018849668464680057997111644937126566671941631\n",
639 "124330809102446660538845562036705210025114037699336929360115994223289874253133343883263\n",
640 "248661618204893321077691124073410420050228075398673858720231988446579748506266687766527\n",
641 "497323236409786642155382248146820840100456150797347717440463976893159497012533375533055\n",
642 "994646472819573284310764496293641680200912301594695434880927953786318994025066751066111\n",
643 "1989292945639146568621528992587283360401824603189390869761855907572637988050133502132223\n",
644 "3978585891278293137243057985174566720803649206378781739523711815145275976100267004264447\n",
645 "7957171782556586274486115970349133441607298412757563479047423630290551952200534008528895\n",
646 "15914343565113172548972231940698266883214596825515126958094847260581103904401068017057791\n",
647 "31828687130226345097944463881396533766429193651030253916189694521162207808802136034115583\n",
648 "63657374260452690195888927762793067532858387302060507832379389042324415617604272068231167\n",
649 "127314748520905380391777855525586135065716774604121015664758778084648831235208544136462335\n",
650 "254629497041810760783555711051172270131433549208242031329517556169297662470417088272924671\n",
651 "509258994083621521567111422102344540262867098416484062659035112338595324940834176545849343\n",
652 "1018517988167243043134222844204689080525734196832968125318070224677190649881668353091698687\n",
653 "2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397375\n",
654 "4074071952668972172536891376818756322102936787331872501272280898708762599526673412366794751\n",
655 "8148143905337944345073782753637512644205873574663745002544561797417525199053346824733589503\n",
656 "16296287810675888690147565507275025288411747149327490005089123594835050398106693649467179007\n",
657 "32592575621351777380295131014550050576823494298654980010178247189670100796213387298934358015\n",
658 "65185151242703554760590262029100101153646988597309960020356494379340201592426774597868716031\n",
659 "130370302485407109521180524058200202307293977194619920040712988758680403184853549195737432063\n",
660 "260740604970814219042361048116400404614587954389239840081425977517360806369707098391474864127\n",
661 "521481209941628438084722096232800809229175908778479680162851955034721612739414196782949728255\n",
662 "1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456511\n",
663 "2085924839766513752338888384931203236916703635113918720651407820138886450957656787131798913023\n",
664 "4171849679533027504677776769862406473833407270227837441302815640277772901915313574263597826047\n",
665 "8343699359066055009355553539724812947666814540455674882605631280555545803830627148527195652095\n",
666 "16687398718132110018711107079449625895333629080911349765211262561111091607661254297054391304191\n",
667 "33374797436264220037422214158899251790667258161822699530422525122222183215322508594108782608383\n",
668 "66749594872528440074844428317798503581334516323645399060845050244444366430645017188217565216767\n",
669 "133499189745056880149688856635597007162669032647290798121690100488888732861290034376435130433535\n",
670 "266998379490113760299377713271194014325338065294581596243380200977777465722580068752870260867071\n",
671 "533996758980227520598755426542388028650676130589163192486760401955554931445160137505740521734143\n",
672 "1067993517960455041197510853084776057301352261178326384973520803911109862890320275011481043468287\n",
673 "2135987035920910082395021706169552114602704522356652769947041607822219725780640550022962086936575\n",
674 "4271974071841820164790043412339104229205409044713305539894083215644439451561281100045924173873151\n",
675 "8543948143683640329580086824678208458410818089426611079788166431288878903122562200091848347746303\n",
676 "17087896287367280659160173649356416916821636178853222159576332862577757806245124400183696695492607\n",
677 "34175792574734561318320347298712833833643272357706444319152665725155515612490248800367393390985215\n",
678 "68351585149469122636640694597425667667286544715412888638305331450311031224980497600734786781970431\n",
679 "136703170298938245273281389194851335334573089430825777276610662900622062449960995201469573563940863\n",
680 "273406340597876490546562778389702670669146178861651554553221325801244124899921990402939147127881727\n",
681 "546812681195752981093125556779405341338292357723303109106442651602488249799843980805878294255763455\n",
682 "1093625362391505962186251113558810682676584715446606218212885303204976499599687961611756588511526911\n",
683 "2187250724783011924372502227117621365353169430893212436425770606409952999199375923223513177023053823\n",
684 "4374501449566023848745004454235242730706338861786424872851541212819905998398751846447026354046107647\n",
685 "8749002899132047697490008908470485461412677723572849745703082425639811996797503692894052708092215295\n",
686 "17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430591\n",
687 "34996011596528190789960035633881941845650710894291398982812329702559247987190014771576210832368861183\n",
688 "69992023193056381579920071267763883691301421788582797965624659405118495974380029543152421664737722367\n",
689 "139984046386112763159840142535527767382602843577165595931249318810236991948760059086304843329475444735\n",
690 "279968092772225526319680285071055534765205687154331191862498637620473983897520118172609686658950889471\n",
691 "559936185544451052639360570142111069530411374308662383724997275240947967795040236345219373317901778943\n",
692 "1119872371088902105278721140284222139060822748617324767449994550481895935590080472690438746635803557887\n",
693 "2239744742177804210557442280568444278121645497234649534899989100963791871180160945380877493271607115775\n",
694 "4479489484355608421114884561136888556243290994469299069799978201927583742360321890761754986543214231551\n",
695 "8958978968711216842229769122273777112486581988938598139599956403855167484720643781523509973086428463103\n",
696 "17917957937422433684459538244547554224973163977877196279199912807710334969441287563047019946172856926207\n",
697 "35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852415\n",
698 "71671831749689734737838152978190216899892655911508785116799651230841339877765150252188079784691427704831\n",
699 "143343663499379469475676305956380433799785311823017570233599302461682679755530300504376159569382855409663\n",
700 "286687326998758938951352611912760867599570623646035140467198604923365359511060601008752319138765710819327\n",
701 "573374653997517877902705223825521735199141247292070280934397209846730719022121202017504638277531421638655\n",
702 "1146749307995035755805410447651043470398282494584140561868794419693461438044242404035009276555062843277311\n",
703 "2293498615990071511610820895302086940796564989168281123737588839386922876088484808070018553110125686554623\n",
704 "4586997231980143023221641790604173881593129978336562247475177678773845752176969616140037106220251373109247\n",
705 "9173994463960286046443283581208347763186259956673124494950355357547691504353939232280074212440502746218495\n",
706 "18347988927920572092886567162416695526372519913346248989900710715095383008707878464560148424881005492436991\n",
707 "36695977855841144185773134324833391052745039826692497979801421430190766017415756929120296849762010984873983\n",
708 "73391955711682288371546268649666782105490079653384995959602842860381532034831513858240593699524021969747967\n",
709 "146783911423364576743092537299333564210980159306769991919205685720763064069663027716481187399048043939495935\n",
710 "293567822846729153486185074598667128421960318613539983838411371441526128139326055432962374798096087878991871\n",
711 "587135645693458306972370149197334256843920637227079967676822742883052256278652110865924749596192175757983743\n",
712 "1174271291386916613944740298394668513687841274454159935353645485766104512557304221731849499192384351515967487\n",
713 "2348542582773833227889480596789337027375682548908319870707290971532209025114608443463698998384768703031934975\n",
714 "4697085165547666455778961193578674054751365097816639741414581943064418050229216886927397996769537406063869951\n",
715 "9394170331095332911557922387157348109502730195633279482829163886128836100458433773854795993539074812127739903\n",
716 "18788340662190665823115844774314696219005460391266558965658327772257672200916867547709591987078149624255479807\n",
717 "37576681324381331646231689548629392438010920782533117931316655544515344401833735095419183974156299248510959615\n",
718 "75153362648762663292463379097258784876021841565066235862633311089030688803667470190838367948312598497021919231\n",
719 "150306725297525326584926758194517569752043683130132471725266622178061377607334940381676735896625196994043838463\n",
720 "300613450595050653169853516389035139504087366260264943450533244356122755214669880763353471793250393988087676927\n",
721 "601226901190101306339707032778070279008174732520529886901066488712245510429339761526706943586500787976175353855\n",
722 "1202453802380202612679414065556140558016349465041059773802132977424491020858679523053413887173001575952350707711\n",
723 "2404907604760405225358828131112281116032698930082119547604265954848982041717359046106827774346003151904701415423\n",
724 "4809815209520810450717656262224562232065397860164239095208531909697964083434718092213655548692006303809402830847\n",
725 "9619630419041620901435312524449124464130795720328478190417063819395928166869436184427311097384012607618805661695\n",
726 "19239260838083241802870625048898248928261591440656956380834127638791856333738872368854622194768025215237611323391\n",
727 "38478521676166483605741250097796497856523182881313912761668255277583712667477744737709244389536050430475222646783\n",
728 "76957043352332967211482500195592995713046365762627825523336510555167425334955489475418488779072100860950445293567\n",
729 "153914086704665934422965000391185991426092731525255651046673021110334850669910978950836977558144201721900890587135\n",
730 "307828173409331868845930000782371982852185463050511302093346042220669701339821957901673955116288403443801781174271\n",
731 "615656346818663737691860001564743965704370926101022604186692084441339402679643915803347910232576806887603562348543\n",
732 "1231312693637327475383720003129487931408741852202045208373384168882678805359287831606695820465153613775207124697087\n",
733 "2462625387274654950767440006258975862817483704404090416746768337765357610718575663213391640930307227550414249394175\n",
734 "4925250774549309901534880012517951725634967408808180833493536675530715221437151326426783281860614455100828498788351\n",
735 "9850501549098619803069760025035903451269934817616361666987073351061430442874302652853566563721228910201656997576703\n",
736 "19701003098197239606139520050071806902539869635232723333974146702122860885748605305707133127442457820403313995153407\n",
737 "39402006196394479212279040100143613805079739270465446667948293404245721771497210611414266254884915640806627990306815\n",
738 "78804012392788958424558080200287227610159478540930893335896586808491443542994421222828532509769831281613255980613631\n",
739 "157608024785577916849116160400574455220318957081861786671793173616982887085988842445657065019539662563226511961227263\n",
740 "315216049571155833698232320801148910440637914163723573343586347233965774171977684891314130039079325126453023922454527\n",
741 "630432099142311667396464641602297820881275828327447146687172694467931548343955369782628260078158650252906047844909055\n",
742 "1260864198284623334792929283204595641762551656654894293374345388935863096687910739565256520156317300505812095689818111\n",
743 "2521728396569246669585858566409191283525103313309788586748690777871726193375821479130513040312634601011624191379636223\n",
744 "5043456793138493339171717132818382567050206626619577173497381555743452386751642958261026080625269202023248382759272447\n",
745 "10086913586276986678343434265636765134100413253239154346994763111486904773503285916522052161250538404046496765518544895\n",
746 "20173827172553973356686868531273530268200826506478308693989526222973809547006571833044104322501076808092993531037089791\n",
747 "40347654345107946713373737062547060536401653012956617387979052445947619094013143666088208645002153616185987062074179583\n",
748 "80695308690215893426747474125094121072803306025913234775958104891895238188026287332176417290004307232371974124148359167\n",
749 "161390617380431786853494948250188242145606612051826469551916209783790476376052574664352834580008614464743948248296718335\n",
750 "322781234760863573706989896500376484291213224103652939103832419567580952752105149328705669160017228929487896496593436671\n",
751 "645562469521727147413979793000752968582426448207305878207664839135161905504210298657411338320034457858975792993186873343\n",
752 "1291124939043454294827959586001505937164852896414611756415329678270323811008420597314822676640068915717951585986373746687\n",
753 "2582249878086908589655919172003011874329705792829223512830659356540647622016841194629645353280137831435903171972747493375\n",
754 "5164499756173817179311838344006023748659411585658447025661318713081295244033682389259290706560275662871806343945494986751\n",
755 "10328999512347634358623676688012047497318823171316894051322637426162590488067364778518581413120551325743612687890989973503\n",
756 "20657999024695268717247353376024094994637646342633788102645274852325180976134729557037162826241102651487225375781979947007\n",
757 "41315998049390537434494706752048189989275292685267576205290549704650361952269459114074325652482205302974450751563959894015\n",
758 "82631996098781074868989413504096379978550585370535152410581099409300723904538918228148651304964410605948901503127919788031\n",
759 "165263992197562149737978827008192759957101170741070304821162198818601447809077836456297302609928821211897803006255839576063\n",
760 "330527984395124299475957654016385519914202341482140609642324397637202895618155672912594605219857642423795606012511679152127\n",
761 "661055968790248598951915308032771039828404682964281219284648795274405791236311345825189210439715284847591212025023358304255\n",
762 "1322111937580497197903830616065542079656809365928562438569297590548811582472622691650378420879430569695182424050046716608511\n",
763 "2644223875160994395807661232131084159313618731857124877138595181097623164945245383300756841758861139390364848100093433217023\n",
764 "5288447750321988791615322464262168318627237463714249754277190362195246329890490766601513683517722278780729696200186866434047\n",
765 "10576895500643977583230644928524336637254474927428499508554380724390492659780981533203027367035444557561459392400373732868095\n",
766 "21153791001287955166461289857048673274508949854856999017108761448780985319561963066406054734070889115122918784800747465736191\n",
767 "42307582002575910332922579714097346549017899709713998034217522897561970639123926132812109468141778230245837569601494931472383\n",
768 "84615164005151820665845159428194693098035799419427996068435045795123941278247852265624218936283556460491675139202989862944767\n",
769 "169230328010303641331690318856389386196071598838855992136870091590247882556495704531248437872567112920983350278405979725889535\n",
770 "338460656020607282663380637712778772392143197677711984273740183180495765112991409062496875745134225841966700556811959451779071\n",
771 "676921312041214565326761275425557544784286395355423968547480366360991530225982818124993751490268451683933401113623918903558143\n",
772 "1353842624082429130653522550851115089568572790710847937094960732721983060451965636249987502980536903367866802227247837807116287\n",
773 "2707685248164858261307045101702230179137145581421695874189921465443966120903931272499975005961073806735733604454495675614232575\n",
774 "5415370496329716522614090203404460358274291162843391748379842930887932241807862544999950011922147613471467208908991351228465151\n",
775 "10830740992659433045228180406808920716548582325686783496759685861775864483615725089999900023844295226942934417817982702456930303\n",
776 "21661481985318866090456360813617841433097164651373566993519371723551728967231450179999800047688590453885868835635965404913860607\n",
777 "43322963970637732180912721627235682866194329302747133987038743447103457934462900359999600095377180907771737671271930809827721215\n",
778 "86645927941275464361825443254471365732388658605494267974077486894206915868925800719999200190754361815543475342543861619655442431\n",
779 "173291855882550928723650886508942731464777317210988535948154973788413831737851601439998400381508723631086950685087723239310884863\n",
780 "346583711765101857447301773017885462929554634421977071896309947576827663475703202879996800763017447262173901370175446478621769727\n",
781 "693167423530203714894603546035770925859109268843954143792619895153655326951406405759993601526034894524347802740350892957243539455\n",
782 "1386334847060407429789207092071541851718218537687908287585239790307310653902812811519987203052069789048695605480701785914487078911\n",
783 "2772669694120814859578414184143083703436437075375816575170479580614621307805625623039974406104139578097391210961403571828974157823\n",
784 "5545339388241629719156828368286167406872874150751633150340959161229242615611251246079948812208279156194782421922807143657948315647\n",
785 "11090678776483259438313656736572334813745748301503266300681918322458485231222502492159897624416558312389564843845614287315896631295\n",
786 "22181357552966518876627313473144669627491496603006532601363836644916970462445004984319795248833116624779129687691228574631793262591\n",
787 "44362715105933037753254626946289339254982993206013065202727673289833940924890009968639590497666233249558259375382457149263586525183\n",
788 "88725430211866075506509253892578678509965986412026130405455346579667881849780019937279180995332466499116518750764914298527173050367\n",
789 "177450860423732151013018507785157357019931972824052260810910693159335763699560039874558361990664932998233037501529828597054346100735\n",
790 "354901720847464302026037015570314714039863945648104521621821386318671527399120079749116723981329865996466075003059657194108692201471\n",
791 "709803441694928604052074031140629428079727891296209043243642772637343054798240159498233447962659731992932150006119314388217384402943\n",
792 "1419606883389857208104148062281258856159455782592418086487285545274686109596480318996466895925319463985864300012238628776434768805887\n",
793 "2839213766779714416208296124562517712318911565184836172974571090549372219192960637992933791850638927971728600024477257552869537611775\n",
794 "5678427533559428832416592249125035424637823130369672345949142181098744438385921275985867583701277855943457200048954515105739075223551\n",
795 "11356855067118857664833184498250070849275646260739344691898284362197488876771842551971735167402555711886914400097909030211478150447103\n",
796 "22713710134237715329666368996500141698551292521478689383796568724394977753543685103943470334805111423773828800195818060422956300894207\n",
797 "45427420268475430659332737993000283397102585042957378767593137448789955507087370207886940669610222847547657600391636120845912601788415\n",
798 "90854840536950861318665475986000566794205170085914757535186274897579911014174740415773881339220445695095315200783272241691825203576831\n",
799 "181709681073901722637330951972001133588410340171829515070372549795159822028349480831547762678440891390190630401566544483383650407153663\n",
800 "363419362147803445274661903944002267176820680343659030140745099590319644056698961663095525356881782780381260803133088966767300814307327\n",
801 "726838724295606890549323807888004534353641360687318060281490199180639288113397923326191050713763565560762521606266177933534601628614655\n",
802 "1453677448591213781098647615776009068707282721374636120562980398361278576226795846652382101427527131121525043212532355867069203257229311\n",
803 "2907354897182427562197295231552018137414565442749272241125960796722557152453591693304764202855054262243050086425064711734138406514458623\n",
804 "5814709794364855124394590463104036274829130885498544482251921593445114304907183386609528405710108524486100172850129423468276813028917247\n",
805 "11629419588729710248789180926208072549658261770997088964503843186890228609814366773219056811420217048972200345700258846936553626057834495\n",
806 "23258839177459420497578361852416145099316523541994177929007686373780457219628733546438113622840434097944400691400517693873107252115668991\n",
807 "46517678354918840995156723704832290198633047083988355858015372747560914439257467092876227245680868195888801382801035387746214504231337983\n",
808 "93035356709837681990313447409664580397266094167976711716030745495121828878514934185752454491361736391777602765602070775492429008462675967\n",
809 "186070713419675363980626894819329160794532188335953423432061490990243657757029868371504908982723472783555205531204141550984858016925351935\n",
810 "372141426839350727961253789638658321589064376671906846864122981980487315514059736743009817965446945567110411062408283101969716033850703871\n",
811 "744282853678701455922507579277316643178128753343813693728245963960974631028119473486019635930893891134220822124816566203939432067701407743\n",
812 "1488565707357402911845015158554633286356257506687627387456491927921949262056238946972039271861787782268441644249633132407878864135402815487\n",
813 "2977131414714805823690030317109266572712515013375254774912983855843898524112477893944078543723575564536883288499266264815757728270805630975\n",
814 "5954262829429611647380060634218533145425030026750509549825967711687797048224955787888157087447151129073766576998532529631515456541611261951\n",
815 "11908525658859223294760121268437066290850060053501019099651935423375594096449911575776314174894302258147533153997065059263030913083222523903\n",
816 "23817051317718446589520242536874132581700120107002038199303870846751188192899823151552628349788604516295066307994130118526061826166445047807\n",
817 "47634102635436893179040485073748265163400240214004076398607741693502376385799646303105256699577209032590132615988260237052123652332890095615\n",
818 "95268205270873786358080970147496530326800480428008152797215483387004752771599292606210513399154418065180265231976520474104247304665780191231\n",
819 "190536410541747572716161940294993060653600960856016305594430966774009505543198585212421026798308836130360530463953040948208494609331560382463\n",
820 "381072821083495145432323880589986121307201921712032611188861933548019011086397170424842053596617672260721060927906081896416989218663120764927\n",
821 "762145642166990290864647761179972242614403843424065222377723867096038022172794340849684107193235344521442121855812163792833978437326241529855\n",
822 "1524291284333980581729295522359944485228807686848130444755447734192076044345588681699368214386470689042884243711624327585667956874652483059711\n",
823 "3048582568667961163458591044719888970457615373696260889510895468384152088691177363398736428772941378085768487423248655171335913749304966119423\n",
824 "6097165137335922326917182089439777940915230747392521779021790936768304177382354726797472857545882756171536974846497310342671827498609932238847\n",
825 "12194330274671844653834364178879555881830461494785043558043581873536608354764709453594945715091765512343073949692994620685343654997219864477695\n",
826 "24388660549343689307668728357759111763660922989570087116087163747073216709529418907189891430183531024686147899385989241370687309994439728955391\n",
827 "48777321098687378615337456715518223527321845979140174232174327494146433419058837814379782860367062049372295798771978482741374619988879457910783\n",
828 "97554642197374757230674913431036447054643691958280348464348654988292866838117675628759565720734124098744591597543956965482749239977758915821567\n",
829 "195109284394749514461349826862072894109287383916560696928697309976585733676235351257519131441468248197489183195087913930965498479955517831643135\n",
830 "390218568789499028922699653724145788218574767833121393857394619953171467352470702515038262882936496394978366390175827861930996959911035663286271\n",
831 "780437137578998057845399307448291576437149535666242787714789239906342934704941405030076525765872992789956732780351655723861993919822071326572543\n",
832 "1560874275157996115690798614896583152874299071332485575429578479812685869409882810060153051531745985579913465560703311447723987839644142653145087\n",
833 "3121748550315992231381597229793166305748598142664971150859156959625371738819765620120306103063491971159826931121406622895447975679288285306290175\n",
834 "6243497100631984462763194459586332611497196285329942301718313919250743477639531240240612206126983942319653862242813245790895951358576570612580351\n",
835 "12486994201263968925526388919172665222994392570659884603436627838501486955279062480481224412253967884639307724485626491581791902717153141225160703\n",
836 "24973988402527937851052777838345330445988785141319769206873255677002973910558124960962448824507935769278615448971252983163583805434306282450321407\n",
837 "49947976805055875702105555676690660891977570282639538413746511354005947821116249921924897649015871538557230897942505966327167610868612564900642815\n",
838 "99895953610111751404211111353381321783955140565279076827493022708011895642232499843849795298031743077114461795885011932654335221737225129801285631\n",
839 "199791907220223502808422222706762643567910281130558153654986045416023791284464999687699590596063486154228923591770023865308670443474450259602571263\n",
840 "399583814440447005616844445413525287135820562261116307309972090832047582568929999375399181192126972308457847183540047730617340886948900519205142527\n",
841 "799167628880894011233688890827050574271641124522232614619944181664095165137859998750798362384253944616915694367080095461234681773897801038410285055\n",
842 "1598335257761788022467377781654101148543282249044465229239888363328190330275719997501596724768507889233831388734160190922469363547795602076820570111\n",
843 "3196670515523576044934755563308202297086564498088930458479776726656380660551439995003193449537015778467662777468320381844938727095591204153641140223\n",
844 "6393341031047152089869511126616404594173128996177860916959553453312761321102879990006386899074031556935325554936640763689877454191182408307282280447\n",
845 "12786682062094304179739022253232809188346257992355721833919106906625522642205759980012773798148063113870651109873281527379754908382364816614564560895\n",
846 "25573364124188608359478044506465618376692515984711443667838213813251045284411519960025547596296126227741302219746563054759509816764729633229129121791\n",
847 "51146728248377216718956089012931236753385031969422887335676427626502090568823039920051095192592252455482604439493126109519019633529459266458258243583\n",
848 "102293456496754433437912178025862473506770063938845774671352855253004181137646079840102190385184504910965208878986252219038039267058918532916516487167\n",
849 "204586912993508866875824356051724947013540127877691549342705710506008362275292159680204380770369009821930417757972504438076078534117837065833032974335\n",
850 "409173825987017733751648712103449894027080255755383098685411421012016724550584319360408761540738019643860835515945008876152157068235674131666065948671\n",
851 "818347651974035467503297424206899788054160511510766197370822842024033449101168638720817523081476039287721671031890017752304314136471348263332131897343\n",
852 "1636695303948070935006594848413799576108321023021532394741645684048066898202337277441635046162952078575443342063780035504608628272942696526664263794687\n"
853 ]
854 }
855 ],
856 "source": [
253 "source": [
857 "for i in range(500):\n",
254 "for i in range(500):\n",
858 " print(2**i - 1)"
255 " print(2**i - 1)"
859 ]
256 ]
860 },
257 },
861 {
258 {
862 "cell_type": "code",
259 "cell_type": "code",
863 "execution_count": null,
260 "execution_count": null,
864 "metadata": {
261 "metadata": {
865 "collapsed": false
262 "collapsed": false
866 },
263 },
867 "outputs": [],
264 "outputs": [],
868 "source": []
265 "source": []
869 }
266 }
870 ],
267 ],
871 "metadata": {
268 "metadata": {
872 "kernelspec": {
269 "kernelspec": {
873 "display_name": "Python 3",
270 "display_name": "Python 3",
874 "language": "python",
271 "language": "python",
875 "name": "python3"
272 "name": "python3"
876 },
273 },
877 "language_info": {
274 "language_info": {
878 "codemirror_mode": {
275 "codemirror_mode": {
879 "name": "ipython",
276 "name": "ipython",
880 "version": 3
277 "version": 3
881 },
278 },
882 "file_extension": ".py",
279 "file_extension": ".py",
883 "mimetype": "text/x-python",
280 "mimetype": "text/x-python",
884 "name": "python",
281 "name": "python",
885 "nbconvert_exporter": "python",
282 "nbconvert_exporter": "python",
886 "pygments_lexer": "ipython3",
283 "pygments_lexer": "ipython3",
887 "version": "3.4.2"
284 "version": "3.4.3"
888 }
285 }
889 },
286 },
890 "nbformat": 4,
287 "nbformat": 4,
891 "nbformat_minor": 0
288 "nbformat_minor": 0
892 }
289 }
@@ -1,271 +1,271 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "The Markdown parser included in IPython is MathJax-aware. This means that you can freely mix in mathematical expressions using the [MathJax subset of Tex and LaTeX](http://docs.mathjax.org/en/latest/tex.html#tex-support). [Some examples from the MathJax site](http://www.mathjax.org/demos/tex-samples/) are reproduced below, as well as the Markdown+TeX source."
7 "The Markdown parser included in IPython is MathJax-aware. This means that you can freely mix in mathematical expressions using the [MathJax subset of Tex and LaTeX](http://docs.mathjax.org/en/latest/tex.html#tex-support). [Some examples from the MathJax site](http://www.mathjax.org/demos/tex-samples/) are reproduced below, as well as the Markdown+TeX source."
8 ]
8 ]
9 },
9 },
10 {
10 {
11 "cell_type": "markdown",
11 "cell_type": "markdown",
12 "metadata": {},
12 "metadata": {},
13 "source": [
13 "source": [
14 "# Motivating Examples\n",
14 "# Motivating Examples\n",
15 "\n",
15 "\n",
16 "---\n",
16 "---\n",
17 "\n",
17 "\n",
18 "## The Lorenz Equations\n",
18 "## The Lorenz Equations\n",
19 "### Source\n",
19 "### Source\n",
20 "```\\begin{align}\n",
20 "```\\begin{align}\n",
21 "\\dot{x} & = \\sigma(y-x) \\\\\n",
21 "\\dot{x} & = \\sigma(y-x) \\\\\n",
22 "\\dot{y} & = \\rho x - y - xz \\\\\n",
22 "\\dot{y} & = \\rho x - y - xz \\\\\n",
23 "\\dot{z} & = -\\beta z + xy\n",
23 "\\dot{z} & = -\\beta z + xy\n",
24 "\\end{align}\n",
24 "\\end{align}\n",
25 "```\n",
25 "```\n",
26 "### Display\n",
26 "### Display\n",
27 "\\begin{align}\n",
27 "\\begin{align}\n",
28 "\\dot{x} & = \\sigma(y-x) \\\\\n",
28 "\\dot{x} & = \\sigma(y-x) \\\\\n",
29 "\\dot{y} & = \\rho x - y - xz \\\\\n",
29 "\\dot{y} & = \\rho x - y - xz \\\\\n",
30 "\\dot{z} & = -\\beta z + xy\n",
30 "\\dot{z} & = -\\beta z + xy\n",
31 "\\end{align}"
31 "\\end{align}"
32 ]
32 ]
33 },
33 },
34 {
34 {
35 "cell_type": "markdown",
35 "cell_type": "markdown",
36 "metadata": {},
36 "metadata": {},
37 "source": [
37 "source": [
38 "## The Cauchy-Schwarz Inequality\n",
38 "## The Cauchy-Schwarz Inequality\n",
39 "### Source\n",
39 "### Source\n",
40 "```\\begin{equation*}\n",
40 "```\\begin{equation*}\n",
41 "\\left( \\sum_{k=1}^n a_k b_k \\right)^2 \\leq \\left( \\sum_{k=1}^n a_k^2 \\right) \\left( \\sum_{k=1}^n b_k^2 \\right)\n",
41 "\\left( \\sum_{k=1}^n a_k b_k \\right)^2 \\leq \\left( \\sum_{k=1}^n a_k^2 \\right) \\left( \\sum_{k=1}^n b_k^2 \\right)\n",
42 "\\end{equation*}\n",
42 "\\end{equation*}\n",
43 "```\n",
43 "```\n",
44 "### Display\n",
44 "### Display\n",
45 "\\begin{equation*}\n",
45 "\\begin{equation*}\n",
46 "\\left( \\sum_{k=1}^n a_k b_k \\right)^2 \\leq \\left( \\sum_{k=1}^n a_k^2 \\right) \\left( \\sum_{k=1}^n b_k^2 \\right)\n",
46 "\\left( \\sum_{k=1}^n a_k b_k \\right)^2 \\leq \\left( \\sum_{k=1}^n a_k^2 \\right) \\left( \\sum_{k=1}^n b_k^2 \\right)\n",
47 "\\end{equation*}"
47 "\\end{equation*}"
48 ]
48 ]
49 },
49 },
50 {
50 {
51 "cell_type": "markdown",
51 "cell_type": "markdown",
52 "metadata": {},
52 "metadata": {},
53 "source": [
53 "source": [
54 "## A Cross Product Formula\n",
54 "## A Cross Product Formula\n",
55 "### Source\n",
55 "### Source\n",
56 "```\\begin{equation*}\n",
56 "```\\begin{equation*}\n",
57 "\\mathbf{V}_1 \\times \\mathbf{V}_2 = \\begin{vmatrix}\n",
57 "\\mathbf{V}_1 \\times \\mathbf{V}_2 = \\begin{vmatrix}\n",
58 "\\mathbf{i} & \\mathbf{j} & \\mathbf{k} \\\\\n",
58 "\\mathbf{i} & \\mathbf{j} & \\mathbf{k} \\\\\n",
59 "\\frac{\\partial X}{\\partial u} & \\frac{\\partial Y}{\\partial u} & 0 \\\\\n",
59 "\\frac{\\partial X}{\\partial u} & \\frac{\\partial Y}{\\partial u} & 0 \\\\\n",
60 "\\frac{\\partial X}{\\partial v} & \\frac{\\partial Y}{\\partial v} & 0\n",
60 "\\frac{\\partial X}{\\partial v} & \\frac{\\partial Y}{\\partial v} & 0\n",
61 "\\end{vmatrix} \n",
61 "\\end{vmatrix} \n",
62 "\\end{equation*}\n",
62 "\\end{equation*}\n",
63 "```\n",
63 "```\n",
64 "### Display\n",
64 "### Display\n",
65 "\\begin{equation*}\n",
65 "\\begin{equation*}\n",
66 "\\mathbf{V}_1 \\times \\mathbf{V}_2 = \\begin{vmatrix}\n",
66 "\\mathbf{V}_1 \\times \\mathbf{V}_2 = \\begin{vmatrix}\n",
67 "\\mathbf{i} & \\mathbf{j} & \\mathbf{k} \\\\\n",
67 "\\mathbf{i} & \\mathbf{j} & \\mathbf{k} \\\\\n",
68 "\\frac{\\partial X}{\\partial u} & \\frac{\\partial Y}{\\partial u} & 0 \\\\\n",
68 "\\frac{\\partial X}{\\partial u} & \\frac{\\partial Y}{\\partial u} & 0 \\\\\n",
69 "\\frac{\\partial X}{\\partial v} & \\frac{\\partial Y}{\\partial v} & 0\n",
69 "\\frac{\\partial X}{\\partial v} & \\frac{\\partial Y}{\\partial v} & 0\n",
70 "\\end{vmatrix} \n",
70 "\\end{vmatrix} \n",
71 "\\end{equation*}"
71 "\\end{equation*}"
72 ]
72 ]
73 },
73 },
74 {
74 {
75 "cell_type": "markdown",
75 "cell_type": "markdown",
76 "metadata": {},
76 "metadata": {},
77 "source": [
77 "source": [
78 "## The probability of getting \\(k\\) heads when flipping \\(n\\) coins is\n",
78 "## The probability of getting \\(k\\) heads when flipping \\(n\\) coins is\n",
79 "### Source\n",
79 "### Source\n",
80 "```\\begin{equation*}\n",
80 "```\\begin{equation*}\n",
81 "P(E) = {n \\choose k} p^k (1-p)^{ n-k} \n",
81 "P(E) = {n \\choose k} p^k (1-p)^{ n-k} \n",
82 "\\end{equation*}\n",
82 "\\end{equation*}\n",
83 "```\n",
83 "```\n",
84 "### Display\n",
84 "### Display\n",
85 "\\begin{equation*}\n",
85 "\\begin{equation*}\n",
86 "P(E) = {n \\choose k} p^k (1-p)^{ n-k} \n",
86 "P(E) = {n \\choose k} p^k (1-p)^{ n-k} \n",
87 "\\end{equation*}"
87 "\\end{equation*}"
88 ]
88 ]
89 },
89 },
90 {
90 {
91 "cell_type": "markdown",
91 "cell_type": "markdown",
92 "metadata": {},
92 "metadata": {},
93 "source": [
93 "source": [
94 "## An Identity of Ramanujan\n",
94 "## An Identity of Ramanujan\n",
95 "### Source\n",
95 "### Source\n",
96 "```\\begin{equation*}\n",
96 "```\\begin{equation*}\n",
97 "\\frac{1}{\\Bigl(\\sqrt{\\phi \\sqrt{5}}-\\phi\\Bigr) e^{\\frac25 \\pi}} =\n",
97 "\\frac{1}{\\Bigl(\\sqrt{\\phi \\sqrt{5}}-\\phi\\Bigr) e^{\\frac25 \\pi}} =\n",
98 "1+\\frac{e^{-2\\pi}} {1+\\frac{e^{-4\\pi}} {1+\\frac{e^{-6\\pi}}\n",
98 "1+\\frac{e^{-2\\pi}} {1+\\frac{e^{-4\\pi}} {1+\\frac{e^{-6\\pi}}\n",
99 "{1+\\frac{e^{-8\\pi}} {1+\\ldots} } } } \n",
99 "{1+\\frac{e^{-8\\pi}} {1+\\ldots} } } } \n",
100 "\\end{equation*}\n",
100 "\\end{equation*}\n",
101 "```\n",
101 "```\n",
102 "### Display\n",
102 "### Display\n",
103 "\\begin{equation*}\n",
103 "\\begin{equation*}\n",
104 "\\frac{1}{\\Bigl(\\sqrt{\\phi \\sqrt{5}}-\\phi\\Bigr) e^{\\frac25 \\pi}} =\n",
104 "\\frac{1}{\\Bigl(\\sqrt{\\phi \\sqrt{5}}-\\phi\\Bigr) e^{\\frac25 \\pi}} =\n",
105 "1+\\frac{e^{-2\\pi}} {1+\\frac{e^{-4\\pi}} {1+\\frac{e^{-6\\pi}}\n",
105 "1+\\frac{e^{-2\\pi}} {1+\\frac{e^{-4\\pi}} {1+\\frac{e^{-6\\pi}}\n",
106 "{1+\\frac{e^{-8\\pi}} {1+\\ldots} } } } \n",
106 "{1+\\frac{e^{-8\\pi}} {1+\\ldots} } } } \n",
107 "\\end{equation*}"
107 "\\end{equation*}"
108 ]
108 ]
109 },
109 },
110 {
110 {
111 "cell_type": "markdown",
111 "cell_type": "markdown",
112 "metadata": {},
112 "metadata": {},
113 "source": [
113 "source": [
114 "## A Rogers-Ramanujan Identity\n",
114 "## A Rogers-Ramanujan Identity\n",
115 "### Source\n",
115 "### Source\n",
116 "```\\begin{equation*}\n",
116 "```\\begin{equation*}\n",
117 "1 + \\frac{q^2}{(1-q)}+\\frac{q^6}{(1-q)(1-q^2)}+\\cdots =\n",
117 "1 + \\frac{q^2}{(1-q)}+\\frac{q^6}{(1-q)(1-q^2)}+\\cdots =\n",
118 "\\prod_{j=0}^{\\infty}\\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},\n",
118 "\\prod_{j=0}^{\\infty}\\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},\n",
119 "\\quad\\quad \\text{for $|q|<1$}. \n",
119 "\\quad\\quad \\text{for $|q|<1$}. \n",
120 "\\end{equation*}\n",
120 "\\end{equation*}\n",
121 "```\n",
121 "```\n",
122 "### Display\n",
122 "### Display\n",
123 "\\begin{equation*}\n",
123 "\\begin{equation*}\n",
124 "1 + \\frac{q^2}{(1-q)}+\\frac{q^6}{(1-q)(1-q^2)}+\\cdots =\n",
124 "1 + \\frac{q^2}{(1-q)}+\\frac{q^6}{(1-q)(1-q^2)}+\\cdots =\n",
125 "\\prod_{j=0}^{\\infty}\\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},\n",
125 "\\prod_{j=0}^{\\infty}\\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},\n",
126 "\\quad\\quad \\text{for $|q|<1$}. \n",
126 "\\quad\\quad \\text{for $|q|<1$}. \n",
127 "\\end{equation*}"
127 "\\end{equation*}"
128 ]
128 ]
129 },
129 },
130 {
130 {
131 "cell_type": "markdown",
131 "cell_type": "markdown",
132 "metadata": {},
132 "metadata": {},
133 "source": [
133 "source": [
134 "## Maxwell's Equations\n",
134 "## Maxwell's Equations\n",
135 "### Source\n",
135 "### Source\n",
136 "```\\begin{align}\n",
136 "```\\begin{align}\n",
137 "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
137 "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
138 "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
138 "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
139 "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n",
139 "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n",
140 "\\end{align}\n",
140 "\\end{align}\n",
141 "```\n",
141 "```\n",
142 "### Display\n",
142 "### Display\n",
143 "\\begin{align}\n",
143 "\\begin{align}\n",
144 "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
144 "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
145 "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
145 "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
146 "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n",
146 "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n",
147 "\\end{align}"
147 "\\end{align}"
148 ]
148 ]
149 },
149 },
150 {
150 {
151 "cell_type": "markdown",
151 "cell_type": "markdown",
152 "metadata": {},
152 "metadata": {},
153 "source": [
153 "source": [
154 "# Equation Numbering and References\n",
154 "# Equation Numbering and References\n",
155 "\n",
155 "\n",
156 "---\n",
156 "---\n",
157 "\n",
157 "\n",
158 "Equation numbering and referencing will be available in a future version of IPython."
158 "Equation numbering and referencing will be available in a future version of IPython."
159 ]
159 ]
160 },
160 },
161 {
161 {
162 "cell_type": "markdown",
162 "cell_type": "markdown",
163 "metadata": {},
163 "metadata": {},
164 "source": [
164 "source": [
165 "# Inline Typesetting (Mixing Markdown and TeX)\n",
165 "# Inline Typesetting (Mixing Markdown and TeX)\n",
166 "\n",
166 "\n",
167 "---\n",
167 "---\n",
168 "\n",
168 "\n",
169 "While display equations look good for a page of samples, the ability to mix math and *formatted* **text** in a paragraph is also important.\n",
169 "While display equations look good for a page of samples, the ability to mix math and *formatted* **text** in a paragraph is also important.\n",
170 "\n",
170 "\n",
171 "## Source\n",
171 "## Source\n",
172 "``` This expression $\\sqrt{3x-1}+(1+x)^2$ is an example of a TeX inline equation in a **[Markdown-formatted](http://daringfireball.net/projects/markdown/)** sentence. \n",
172 "``` This expression $\\sqrt{3x-1}+(1+x)^2$ is an example of a TeX inline equation in a **[Markdown-formatted](http://daringfireball.net/projects/markdown/)** sentence. \n",
173 "```\n",
173 "```\n",
174 "## Display\n",
174 "## Display\n",
175 "This expression $\\sqrt{3x-1}+(1+x)^2$ is an example of a TeX inline equation in a **[Markdown-formatted](http://daringfireball.net/projects/markdown/)** sentence. "
175 "This expression $\\sqrt{3x-1}+(1+x)^2$ is an example of a TeX inline equation in a **[Markdown-formatted](http://daringfireball.net/projects/markdown/)** sentence. "
176 ]
176 ]
177 },
177 },
178 {
178 {
179 "cell_type": "markdown",
179 "cell_type": "markdown",
180 "metadata": {},
180 "metadata": {},
181 "source": [
181 "source": [
182 "# Other Syntax\n",
182 "# Other Syntax\n",
183 "\n",
183 "\n",
184 "---\n",
184 "---\n",
185 "\n",
185 "\n",
186 "You will notice in other places on the web that `$$` are needed explicitly to begin and end MathJax typesetting. This is **not** required if you will be using TeX environments, but the IPython notebook will accept this syntax on legacy notebooks. \n",
186 "You will notice in other places on the web that `$$` are needed explicitly to begin and end MathJax typesetting. This is **not** required if you will be using TeX environments, but the IPython notebook will accept this syntax on legacy notebooks. \n",
187 "\n",
187 "\n",
188 "### Source\n",
188 "### Source\n",
189 "```\n",
189 "```\n",
190 "$$\n",
190 "$$\n",
191 "\\begin{array}{c}\n",
191 "\\begin{array}{c}\n",
192 "y_1 \\\\\\\n",
192 "y_1 \\\\\\\n",
193 "y_2 \\mathtt{t}_i \\\\\\\n",
193 "y_2 \\mathtt{t}_i \\\\\\\n",
194 "z_{3,4}\n",
194 "z_{3,4}\n",
195 "\\end{array}\n",
195 "\\end{array}\n",
196 "$$\n",
196 "$$\n",
197 "```\n",
197 "```\n",
198 "\n",
198 "\n",
199 "```\n",
199 "```\n",
200 "$$\n",
200 "$$\n",
201 "\\begin{array}{c}\n",
201 "\\begin{array}{c}\n",
202 "y_1 \\cr\n",
202 "y_1 \\cr\n",
203 "y_2 \\mathtt{t}_i \\cr\n",
203 "y_2 \\mathtt{t}_i \\cr\n",
204 "y_{3}\n",
204 "y_{3}\n",
205 "\\end{array}\n",
205 "\\end{array}\n",
206 "$$\n",
206 "$$\n",
207 "```\n",
207 "```\n",
208 "\n",
208 "\n",
209 "```\n",
209 "```\n",
210 "$$\\begin{eqnarray} \n",
210 "$$\\begin{eqnarray} \n",
211 "x' &=& &x \\sin\\phi &+& z \\cos\\phi \\\\\n",
211 "x' &=& &x \\sin\\phi &+& z \\cos\\phi \\\\\n",
212 "z' &=& - &x \\cos\\phi &+& z \\sin\\phi \\\\\n",
212 "z' &=& - &x \\cos\\phi &+& z \\sin\\phi \\\\\n",
213 "\\end{eqnarray}$$\n",
213 "\\end{eqnarray}$$\n",
214 "```\n",
214 "```\n",
215 "\n",
215 "\n",
216 "```\n",
216 "```\n",
217 "$$\n",
217 "$$\n",
218 "x=4\n",
218 "x=4\n",
219 "$$\n",
219 "$$\n",
220 "```\n",
220 "```\n",
221 "\n",
221 "\n",
222 "### Display\n",
222 "### Display\n",
223 "$$\n",
223 "$$\n",
224 "\\begin{array}{c}\n",
224 "\\begin{array}{c}\n",
225 "y_1 \\\\\\\n",
225 "y_1 \\\\\\\n",
226 "y_2 \\mathtt{t}_i \\\\\\\n",
226 "y_2 \\mathtt{t}_i \\\\\\\n",
227 "z_{3,4}\n",
227 "z_{3,4}\n",
228 "\\end{array}\n",
228 "\\end{array}\n",
229 "$$\n",
229 "$$\n",
230 "\n",
230 "\n",
231 "$$\n",
231 "$$\n",
232 "\\begin{array}{c}\n",
232 "\\begin{array}{c}\n",
233 "y_1 \\cr\n",
233 "y_1 \\cr\n",
234 "y_2 \\mathtt{t}_i \\cr\n",
234 "y_2 \\mathtt{t}_i \\cr\n",
235 "y_{3}\n",
235 "y_{3}\n",
236 "\\end{array}\n",
236 "\\end{array}\n",
237 "$$\n",
237 "$$\n",
238 "\n",
238 "\n",
239 "$$\\begin{eqnarray} \n",
239 "$$\\begin{eqnarray} \n",
240 "x' &=& &x \\sin\\phi &+& z \\cos\\phi \\\\\n",
240 "x' &=& &x \\sin\\phi &+& z \\cos\\phi \\\\\n",
241 "z' &=& - &x \\cos\\phi &+& z \\sin\\phi \\\\\n",
241 "z' &=& - &x \\cos\\phi &+& z \\sin\\phi \\\\\n",
242 "\\end{eqnarray}$$\n",
242 "\\end{eqnarray}$$\n",
243 "\n",
243 "\n",
244 "$$\n",
244 "$$\n",
245 "x=4\n",
245 "x=4\n",
246 "$$"
246 "$$"
247 ]
247 ]
248 }
248 }
249 ],
249 ],
250 "metadata": {
250 "metadata": {
251 "kernelspec": {
251 "kernelspec": {
252 "display_name": "Python 3",
252 "display_name": "Python 3",
253 "language": "python",
253 "language": "python",
254 "name": "python3"
254 "name": "python3"
255 },
255 },
256 "language_info": {
256 "language_info": {
257 "codemirror_mode": {
257 "codemirror_mode": {
258 "name": "ipython",
258 "name": "ipython",
259 "version": 3
259 "version": 3
260 },
260 },
261 "file_extension": ".py",
261 "file_extension": ".py",
262 "mimetype": "text/x-python",
262 "mimetype": "text/x-python",
263 "name": "python",
263 "name": "python",
264 "nbconvert_exporter": "python",
264 "nbconvert_exporter": "python",
265 "pygments_lexer": "ipython3",
265 "pygments_lexer": "ipython3",
266 "version": "3.4.2"
266 "version": "3.4.3"
267 }
267 }
268 },
268 },
269 "nbformat": 4,
269 "nbformat": 4,
270 "nbformat_minor": 0
270 "nbformat_minor": 0
271 }
271 }
This diff has been collapsed as it changes many lines, (1004 lines changed) Show them Hide them
@@ -1,1449 +1,619 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "# NbConvert, Python library"
7 "# Using nbconvert as a Library"
8 ]
8 ]
9 },
9 },
10 {
10 {
11 "cell_type": "markdown",
11 "cell_type": "markdown",
12 "metadata": {},
12 "metadata": {},
13 "source": [
13 "source": [
14 "In this Notebook, I will introduce you to the programatic API of nbconvert to show you how to use it in various context. \n",
14 "In this Notebook, you will be introduced to the programatic API of nbconvert and how it can be used in various contexts. \n",
15 "\n",
15 "\n",
16 "For this I will use one of [@jakevdp](https://github.com/jakevdp) great [blog post](http://jakevdp.github.io/blog/2013/04/15/code-golf-in-python-sudoku/).\n",
16 "One of [@jakevdp](https://github.com/jakevdp)'s great [blog posts](http://jakevdp.github.io/blog/2013/04/15/code-golf-in-python-sudoku/) will be used to demonstrate. This notebook will not focus on using the command line tool. The attentive reader will point-out that no data is read from or written to disk during the conversion process. Nbconvert has been designed to work in memory so that it works well in a database or web-based environement too."
17 "I've explicitely chosen a post with no javascript tricks as Jake seem to be found of right now, for the reason that the becommings of embeding javascript in nbviewer, which is based on nbconvert is not fully decided yet. \n",
18 "\n",
19 "\n",
20 "This will not focus on using the command line tool to convert file. The attentive reader will point-out that no data are read from, or written to disk during the conversion process. Indeed, nbconvert as been though as much as\n",
21 "possible to avoid IO operation and work as well in a database, or web-based environement."
22 ]
17 ]
23 },
18 },
24 {
19 {
25 "cell_type": "markdown",
20 "cell_type": "markdown",
26 "metadata": {},
21 "metadata": {},
27 "source": [
22 "source": [
28 "#### Quick overview"
23 "## Quick overview"
29 ]
24 ]
30 },
25 },
31 {
26 {
32 "cell_type": "markdown",
27 "cell_type": "markdown",
33 "metadata": {},
28 "metadata": {},
34 "source": [
29 "source": [
35 "Credit, Jonathan Freder (@jdfreder on github)\n",
30 "Credit, Jonathan Frederic (@jdfreder on github)\n",
36 "\n",
31 "\n",
37 "<center>\n",
32 "<center>\n",
38 " ![nbca](images/nbconvert_arch.png)\n",
33 " ![nbca](images/nbconvert_arch.png)\n",
39 "</center>"
34 "</center>"
40 ]
35 ]
41 },
36 },
42 {
37 {
43 "cell_type": "markdown",
38 "cell_type": "markdown",
44 "metadata": {},
39 "metadata": {},
45 "source": [
40 "source": [
46 "The main principle of nbconvert is to instanciate a `Exporter` that controle\n",
41 "The main principle of nbconvert is to instantiate an `Exporter` that controls\n",
47 "a pipeline through which each notebook you want to export with go through."
42 "the pipeline through which notebooks are converted."
48 ]
43 ]
49 },
44 },
50 {
45 {
51 "cell_type": "markdown",
46 "cell_type": "markdown",
52 "metadata": {},
47 "metadata": {},
53 "source": [
48 "source": [
54 "Let's start by importing what we need from the API, and download @jakevdp's notebook."
49 "First, download @jakevdp's notebook."
55 ]
50 ]
56 },
51 },
57 {
52 {
58 "cell_type": "code",
53 "cell_type": "code",
59 "execution_count": 1,
54 "execution_count": null,
60 "metadata": {
55 "metadata": {
61 "collapsed": false
56 "collapsed": false
62 },
57 },
63 "outputs": [
58 "outputs": [],
64 {
65 "data": {
66 "text/plain": [
67 "'{\\n \"metadata\": {\\n \"name\": \"XKCD_plots\"\\n },\\n \"nbformat\": 3,\\n...'"
68 ]
69 },
70 "execution_count": 1,
71 "metadata": {},
72 "output_type": "execute_result"
73 }
74 ],
75 "source": [
59 "source": [
76 "import requests\n",
60 "import requests\n",
77 "response = requests.get('http://jakevdp.github.com/downloads/notebooks/XKCD_plots.ipynb')\n",
61 "response = requests.get('http://jakevdp.github.com/downloads/notebooks/XKCD_plots.ipynb')\n",
78 "response.text[0:60]+'...'"
62 "response.text[0:60]+'...'"
79 ]
63 ]
80 },
64 },
81 {
65 {
82 "cell_type": "markdown",
66 "cell_type": "markdown",
83 "metadata": {},
67 "metadata": {},
84 "source": [
68 "source": [
85 "If you do not have request install downlad by hand, and read the file as usual."
69 "If you do not have `requests`, install it by running `pip install requests` (or if you don't have pip installed, you can find it on PYPI)."
86 ]
70 ]
87 },
71 },
88 {
72 {
89 "cell_type": "markdown",
73 "cell_type": "markdown",
90 "metadata": {},
74 "metadata": {},
91 "source": [
75 "source": [
92 "We read the response into a slightly more convenient format which represent IPython notebook. \n",
76 "The response is a JSON string which represents an IPython notebook. Next, read the response using nbformat.\n",
93 "There are not real advantages for now, except some convenient methods, but with time this structure should be able to\n",
77 "\n",
94 "guarantee that the notebook structure is valid. Note also that the in-memory format and on disk format can be slightly different. In particual, on disk, multiline strings might be spitted into list of string to be more version control friendly."
78 "Doing this will guarantee that the notebook structure is valid. Note that the in-memory format and on disk format are slightly different. In particual, on disk, multiline strings might be splitted into a list of strings."
95 ]
79 ]
96 },
80 },
97 {
81 {
98 "cell_type": "code",
82 "cell_type": "code",
99 "execution_count": 2,
83 "execution_count": null,
100 "metadata": {
84 "metadata": {
101 "collapsed": false
85 "collapsed": false
102 },
86 },
103 "outputs": [
87 "outputs": [],
104 {
105 "data": {
106 "text/plain": [
107 "{'cell_type': 'markdown',\n",
108 " 'metadata': {},\n",
109 " 'source': '# XKCD plots in Matplotlib'}"
110 ]
111 },
112 "execution_count": 2,
113 "metadata": {},
114 "output_type": "execute_result"
115 }
116 ],
117 "source": [
88 "source": [
118 "from IPython import nbformat\n",
89 "from IPython import nbformat\n",
119 "jake_notebook = nbformat.reads(response.text, as_version=4)\n",
90 "jake_notebook = nbformat.reads(response.text, as_version=4)\n",
120 "jake_notebook.cells[0]"
91 "jake_notebook.cells[0]"
121 ]
92 ]
122 },
93 },
123 {
94 {
124 "cell_type": "markdown",
95 "cell_type": "markdown",
125 "metadata": {},
96 "metadata": {},
126 "source": [
97 "source": [
127 "So we have here Jake's notebook in a convenient form, which is mainly a Super-Powered dict and list nested.\n",
98 "The nbformat API returns a special dict. You don't need to worry about the details of the structure."
128 "You don't need to worry about the exact structure."
129 ]
99 ]
130 },
100 },
131 {
101 {
132 "cell_type": "markdown",
102 "cell_type": "markdown",
133 "metadata": {},
103 "metadata": {},
134 "source": [
104 "source": [
135 "The nbconvert API exposes some basic exporter for common format and default options. We will start\n",
105 "The nbconvert API exposes some basic exporters for common formats and defaults. You will start\n",
136 "by using one of them. First we import it, instanciate an instance with most of the default parameters and fed it\n",
106 "by using one of them. First you will import it, then instantiate it using most of the defaults, and finally you will process notebook downloaded early."
137 "the downloaded notebook. "
138 ]
107 ]
139 },
108 },
140 {
109 {
141 "cell_type": "code",
110 "cell_type": "code",
142 "execution_count": 3,
111 "execution_count": null,
143 "metadata": {
112 "metadata": {
144 "collapsed": false
113 "collapsed": false
145 },
114 },
146 "outputs": [],
115 "outputs": [],
147 "source": [
116 "source": [
148 "from IPython.config import Config\n",
117 "from IPython.config import Config\n",
149 "from IPython.nbconvert import HTMLExporter\n",
118 "from IPython.nbconvert import HTMLExporter\n",
150 "\n",
119 "\n",
151 "## I use `basic` here to have less boilerplate and headers in the HTML.\n",
120 "# The `basic` template is used here.\n",
152 "## we'll see later how to pass config to exporters.\n",
121 "# Later you'll learn how to configure the exporter.\n",
153 "html_exporter = HTMLExporter(config=Config({'HTMLExporter':{'default_template':'basic'}}))"
122 "html_exporter = HTMLExporter(config=Config({'HTMLExporter':{'default_template':'basic'}}))"
154 ]
123 ]
155 },
124 },
156 {
125 {
157 "cell_type": "code",
126 "cell_type": "code",
158 "execution_count": 4,
127 "execution_count": null,
159 "metadata": {
128 "metadata": {
160 "collapsed": false
129 "collapsed": false
161 },
130 },
162 "outputs": [],
131 "outputs": [],
163 "source": [
132 "source": [
164 "(body, resources) = html_exporter.from_notebook_node(jake_notebook)"
133 "(body, resources) = html_exporter.from_notebook_node(jake_notebook)"
165 ]
134 ]
166 },
135 },
167 {
136 {
168 "cell_type": "markdown",
137 "cell_type": "markdown",
169 "metadata": {},
138 "metadata": {},
170 "source": [
139 "source": [
171 "The exporter returns a tuple containing the body of the converted notebook, here raw HTML, as well as a resources dict.\n",
140 "The exporter returns a tuple containing the body of the converted notebook, raw HTML in this case, as well as a resources dict. The resource dict contains (among many things) the extracted PNG, JPG [...etc] from the notebook when applicable. The basic HTML exporter leaves the figures as embeded base64, but you can configure it to extract the figures. So for now, the resource dict **should** be mostly empty, except for a key containing CSS and a few others whose content will be obvious.\n",
172 "The resource dict contains (among many things) the extracted PNG, JPG [...etc] from the notebook when applicable.\n",
173 "The basic HTML exporter does keep them as embeded base64 into the notebook, but one can do ask the figures to be extracted. Cf advance use. So for now the resource dict **should** be mostly empty, except for 1 key containing some css, and 2 others whose content will be obvious.\n",
174 "\n",
141 "\n",
175 "Exporter are stateless, you won't be able to extract any usefull information (except their configuration) from them.\n",
142 "`Exporter`s are stateless, so you won't be able to extract any usefull information beyond their configuration from them. You can re-use an exporter instance to convert another notebook. Each exporter exposes, for convenience, a `from_file` and `from_filename` method."
176 "You can directly re-use the instance to convert another notebook. Each exporter expose for convenience a `from_file` and `from_filename` methods if you need."
177 ]
143 ]
178 },
144 },
179 {
145 {
180 "cell_type": "code",
146 "cell_type": "code",
181 "execution_count": 5,
147 "execution_count": null,
182 "metadata": {
148 "metadata": {
183 "collapsed": false
149 "collapsed": false
184 },
150 },
185 "outputs": [
151 "outputs": [],
186 {
187 "name": "stdout",
188 "output_type": "stream",
189 "text": [
190 "['raw_mimetypes', 'inlining', 'metadata', 'output_extension']\n",
191 "defaultdict(None, {'name': 'Notebook'})\n",
192 ".html\n"
193 ]
194 }
195 ],
196 "source": [
152 "source": [
197 "print([key for key in resources ])\n",
153 "print([key for key in resources ])\n",
198 "print(resources['metadata'])\n",
154 "print(resources['metadata'])\n",
199 "print(resources['output_extension'])\n",
155 "print(resources['output_extension'])\n",
200 "# print resources['inlining'] # too lng to be shown"
156 "# print resources['inlining'] # Too long to be shown"
201 ]
157 ]
202 },
158 },
203 {
159 {
204 "cell_type": "code",
160 "cell_type": "code",
205 "execution_count": 6,
161 "execution_count": null,
206 "metadata": {
162 "metadata": {
207 "collapsed": false
163 "collapsed": false
208 },
164 },
209 "outputs": [
165 "outputs": [],
210 {
211 "name": "stdout",
212 "output_type": "stream",
213 "text": [
214 "<!DOCTYPE html>\n",
215 "<html>\n",
216 "<head>\n",
217 "\n",
218 "<meta charset=\"utf-8\" />\n",
219 "<title>Notebook</title>\n",
220 "\n",
221 "<script src=\"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js\"></script>\n",
222 "<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js\"></script>\n",
223 "\n",
224 "<style type=\"text/css\">\n",
225 " /*!\n",
226 "*\n",
227 "* Twitter Bootstrap\n",
228 "*\n",
229 "*/\n",
230 "/*! normalize.css v3.0.2 | MIT License | git.io/normalize */\n",
231 "html {\n",
232 " fon...\n"
233 ]
234 }
235 ],
236 "source": [
166 "source": [
237 "# Part of the body, here the first Heading\n",
167 "# Part of the body, here the first Heading\n",
238 "start = body.index('<h1 id', )\n",
168 "start = body.index('<h1 id', )\n",
239 "print(body[:400]+'...')"
169 "print(body[:400]+'...')"
240 ]
170 ]
241 },
171 },
242 {
172 {
243 "cell_type": "markdown",
173 "cell_type": "markdown",
244 "metadata": {},
174 "metadata": {},
245 "source": [
175 "source": [
246 "You can directly write the body into an HTML file if you wish, as you see it does not contains any body tag, or style declaration, but thoses are included in the default HtmlExporter if you do not pass it a config object as I did."
176 "If you understand HTML, you'll notice that some common tags are ommited, like the `body` tag. Those tags are included in the default `HtmlExporter`, which is what would have been constructed if no Config object was passed into it."
247 ]
177 ]
248 },
178 },
249 {
179 {
250 "cell_type": "markdown",
180 "cell_type": "markdown",
251 "metadata": {},
181 "metadata": {},
252 "source": [
182 "source": [
253 "#### Extracting Figures"
183 "#### Extracting Figures"
254 ]
184 ]
255 },
185 },
256 {
186 {
257 "cell_type": "markdown",
187 "cell_type": "markdown",
258 "metadata": {},
188 "metadata": {},
259 "source": [
189 "source": [
260 "When exporting one might want to extract the base64 encoded figures to separate files, this is by default what does the RstExporter does, let see how to use it. "
190 "When exporting you may want to extract the base64 encoded figures as files, this is by default what the `RstExporter` does (as seen below)."
261 ]
191 ]
262 },
192 },
263 {
193 {
264 "cell_type": "code",
194 "cell_type": "code",
265 "execution_count": 7,
195 "execution_count": null,
266 "metadata": {
196 "metadata": {
267 "collapsed": false
197 "collapsed": false
268 },
198 },
269 "outputs": [],
199 "outputs": [],
270 "source": [
200 "source": [
271 "from IPython.nbconvert import RSTExporter\n",
201 "from IPython.nbconvert import RSTExporter\n",
272 "\n",
202 "\n",
273 "rst_exporter = RSTExporter()\n",
203 "rst_exporter = RSTExporter()\n",
274 "\n",
204 "\n",
275 "(body,resources) = rst_exporter.from_notebook_node(jake_notebook)"
205 "(body,resources) = rst_exporter.from_notebook_node(jake_notebook)"
276 ]
206 ]
277 },
207 },
278 {
208 {
279 "cell_type": "code",
209 "cell_type": "code",
280 "execution_count": 8,
210 "execution_count": null,
281 "metadata": {
211 "metadata": {
282 "collapsed": false
212 "collapsed": false
283 },
213 },
284 "outputs": [
214 "outputs": [],
285 {
286 "name": "stdout",
287 "output_type": "stream",
288 "text": [
289 "\n",
290 "XKCD plots in Matplotlib\n",
291 "========================\n",
292 "\n",
293 "This notebook originally appeared as a blog post at `Pythonic\n",
294 "Perambulations <http://jakevdp.github.com/blog/2012/10/07/xkcd-style-plots-in-matplotlib/>`__\n",
295 "by Jake Vanderplas.\n",
296 "\n",
297 ".. raw:: html\n",
298 "\n",
299 " <!-- PELICAN_BEGIN_SUMMARY -->\n",
300 "\n",
301 "*Update: the matplotlib pull request has been merged! See* `*This\n",
302 "post* <http://jakevdp.github.io/blog/2013/07/10/XKCD-plots-in-matplotlib/>`__\n",
303 "*for a description of the XKCD functionality now built-in to\n",
304 "matplotlib!*\n",
305 "\n",
306 "One of the problems I've had with typical matplotlib figures is that\n",
307 "everything in them is so precise, so perfect. For an example of what I\n",
308 "mean, take a look at this figure:\n",
309 "\n",
310 ".. code:: python\n",
311 "\n",
312 " from IPython.display import Image\n",
313 " Image('http://jakevdp.github.com/figures/xkcd_version.png')\n",
314 "\n",
315 "\n",
316 "\n",
317 ".. image:: output_3_0.png\n",
318 "\n",
319 "\n",
320 "\n",
321 "Sometimes when showing schematic plots, this is the type of figure I\n",
322 "want to display. But drawing it by hand is a pain: I'd rather just use\n",
323 "matpl...\n",
324 "[.....]\n",
325 "mage:: output_3_0.png\n",
326 "\n",
327 "\n",
328 "\n",
329 "Sometimes when showing schematic plots, this is the type of figure I\n",
330 "want to display. But drawing it by hand is a pain: I'd rather just use\n",
331 "matplotlib. The problem is, matplotlib is a bit too precise. Attempting\n",
332 "to duplicate this figure in matplotlib leads to something like this:\n",
333 "\n",
334 ".. code:: python\n",
335 "\n",
336 " Image('http://jakevdp.github.com/figures/mpl_version.png')\n",
337 "\n",
338 "\n",
339 "\n",
340 ".. image:...\n"
341 ]
342 }
343 ],
344 "source": [
215 "source": [
345 "print(body[:970]+'...')\n",
216 "print(body[:970]+'...')\n",
346 "print('[.....]')\n",
217 "print('[.....]')\n",
347 "print(body[800:1200]+'...')"
218 "print(body[800:1200]+'...')"
348 ]
219 ]
349 },
220 },
350 {
221 {
351 "cell_type": "markdown",
222 "cell_type": "markdown",
352 "metadata": {},
223 "metadata": {},
353 "source": [
224 "source": [
354 "Here we see that base64 images are not embeded, but we get what look like file name. Actually those are (Configurable) keys to get back the binary data from the resources dict we havent inspected earlier.\n"
225 "Notice that base64 images are not embeded, but instead there are file name like strings. The strings actually are (configurable) keys that map to the binary data in the resources dict.\n"
355 ]
226 ]
356 },
227 },
357 {
228 {
358 "cell_type": "markdown",
229 "cell_type": "markdown",
359 "metadata": {},
230 "metadata": {},
360 "source": [
231 "source": [
361 "So when writing a Rst Plugin for any blogengine, Sphinx or anything else, you will be responsible for writing all those data to disk, in the right place. \n",
232 "Note, if you write an RST Plugin, you are responsible for writing all the files to the disk (or uploading, etc...) in the right location. Of course, the naming scheme is configurable."
362 "Of course to help you in this task all those naming are configurable in the right place."
363 ]
233 ]
364 },
234 },
365 {
235 {
366 "cell_type": "markdown",
236 "cell_type": "markdown",
367 "metadata": {},
237 "metadata": {},
368 "source": [
238 "source": [
369 "let's try to see how to get one of these images"
239 "As an exercise, this notebook will show you how to get one of those images."
370 ]
240 ]
371 },
241 },
372 {
242 {
373 "cell_type": "code",
243 "cell_type": "code",
374 "execution_count": 9,
244 "execution_count": null,
375 "metadata": {
245 "metadata": {
376 "collapsed": false
246 "collapsed": false
377 },
247 },
378 "outputs": [
248 "outputs": [],
379 {
380 "data": {
381 "text/plain": [
382 "['output_5_0.png',\n",
383 " 'output_16_0.png',\n",
384 " 'output_13_1.png',\n",
385 " 'output_18_1.png',\n",
386 " 'output_3_0.png']"
387 ]
388 },
389 "execution_count": 9,
390 "metadata": {},
391 "output_type": "execute_result"
392 }
393 ],
394 "source": [
249 "source": [
395 "list(resources['outputs'])"
250 "list(resources['outputs'])"
396 ]
251 ]
397 },
252 },
398 {
253 {
399 "cell_type": "markdown",
254 "cell_type": "markdown",
400 "metadata": {},
255 "metadata": {},
401 "source": [
256 "source": [
402 "We have extracted 5 binary figures, here `png`s, but they could have been svg, and then wouldn't appear in the binary sub dict.\n",
257 "There are 5 extracted binary figures, all `png`s, but they could have been `svg`s which then wouldn't appear in the binary sub dict. Keep in mind that objects with multiple reprs will have every repr stored in the notebook avaliable for conversion. \n",
403 "keep in mind that a object having multiple _repr_ will store all it's repr in the notebook. \n",
404 "\n",
258 "\n",
405 "Hence if you provide `_repr_javascript_`,`_repr_latex_` and `_repr_png_`to an object, you will be able to determine at conversion time which representaition is the more appropriate. You could even decide to show all the representaition of an object, it's up to you. But this will require beeing a little more involve and write a few line of Jinja template. This will probably be the subject of another tutorial.\n",
259 "Hence if the object provides `_repr_javascript_`, `_repr_latex_`, and `_repr_png_`, you will be able to determine, at conversion time, which representaition is most appropriate. You could even show all of the representaitions of an object in a single export, it's up to you. Doing so would require a little more involvement on your part and a custom Jinja template.\n",
406 "\n",
260 "\n",
407 "Back to our images,\n",
261 "Back to the task of extracting an image, the Image display object can be used to display one of the images (as seen below)."
408 "\n"
409 ]
262 ]
410 },
263 },
411 {
264 {
412 "cell_type": "code",
265 "cell_type": "code",
413 "execution_count": 10,
266 "execution_count": null,
414 "metadata": {
267 "metadata": {
415 "collapsed": false
268 "collapsed": false
416 },
269 },
417 "outputs": [
270 "outputs": [],
418 {
419 "data": {
420 "image/png": [
421 "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEgCAYAAADVKCZpAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n",
422 "AAALEgAACxIB0t1+/AAAIABJREFUeJzsnXd4FGXXxu/ZTYP0RkvoJKH3IvAivQsiINIEgUAsgPIJ\n",
423 "Cq8IAgroqxRRUJpSpCO9ifQSpEgNvYYSCJDek93z/XEyuwkkIWV3Zjd5fte11yxbZu5ZsnvPc57z\n",
424 "nAMSCCyApUuXUqlSpUiSJKpfvz4dPnzY8Fy1atUoLCwsy/edPXuWiIjS0tLo008/JVtbW5Ik6aVb\n",
425 "mTJlKDEx0fA++fX29vak1Wqpe/fu9ODBAyIiWrFiBbm5udHx48fzfT6ffPIJOTo60u3bt/O9j5zY\n",
426 "vn07VaxY0XB+JUuWpBs3brzyfSdOnCAfHx+Kjo7O8zHv379PDg4O5OTkRFFRUfmRLRCYFBsIBCoz\n",
427 "e/ZsfPrppyhZsiSmTp2K5ORkrFmzBi1atAAAJCYmIiUlJcv3NmnSBMnJydi4cSNmzZoFLy8vTJky\n",
428 "Bfb29ple16hRIzg4OAAAUlNT0b9/f2zcuBG1atVCUFAQjhw5giNHjqBv3764efMmoqOjsWnTJjRt\n",
429 "2hSjR4/G77//jlu3bsHb2ztX57R//34kJibi/v378PT0REJCQo6v9/DwgJ2dXa72/ejRI/Tq1Qup\n",
430 "qamYNWsWrl69it9++w0dO3bE8ePHUbJkScNrY2Nj4ezsbPi3JEl49OgRlixZgjFjxgAAYmJicqXP\n",
431 "19cX77zzDpYvX47z58/j9ddfz5VegcBsqO2ggqLNypUrSZIk8vPzo9DQ0Jeef/78Obm6umb5HBGR\n",
432 "JElERBQeHk6SJNHSpUtfeczAwECSJIm6d+9OKSkpLz0/efJkkiSJ/vrrL7py5QppNBoqX758lq/N\n",
433 "js8++4wkSaKDBw9Sv379SJIk0mg0ZG9vn+UI8fvvv8/1vtu2bUtubm40d+5cw2ObNm0iOzs7atGi\n",
434 "heGxzZs3k1arpdOnT2d6f5MmTahcuXKG8+nbt2+u9cmfzaFDh3KtVyAwF8LABKrx6NEjcnNzI3d3\n",
435 "d3r8+HGWrzlw4ABVq1aN9Hp9ls/LBpaYmEiSJNHYsWMpLCzMcHsxVLZjxw6SJIlatGhBaWlpWe5T\n",
436 "/pGeMWMG1alTh3x8fOjWrVt5Ojd/f/9MP/SnTp2iq1ev0v3790mSJOrRowft2bOH9uzZQydOnMj1\n",
437 "fo8dO0aSJNG2bdteek6+GDh//jwREU2ZMiXL1x46dIgkSaL58+cbHsutvh9++IE0Go0hdCsQqIkw\n",
438 "MIFqTJ8+nSRJom+//Tbb1xw4cCDTqCI2NpbCwsLozp07NGbMGJIkiR48eEDR0dEkSRLZ29uTg4MD\n",
439 "SZJEtra21Llz50zm16FDB9JoNPTPP/9ke0zZwOTb4MGD83xu5cuXz/aHXpIkWrZsWZ73SUTUvn17\n",
440 "GjhwYJbP6fV6qly5Mk2ePJmIiJo2bUqurq4UHx+f6XUpKSnk5eVFNjY2dPfu3TzpS0lJoa1bt+ZL\n",
441 "u0BgasQcmEA1kpOTodFoMHjw4Bxfd+7cOVy+fBlubm5o06YNrl+/bnhOkiT4+Phg5cqVAIC///4b\n",
442 "tWrVwsmTJ1GzZk2ULl36pWNWrVoVjRs3zrXOVatWoWzZspg2bVoezg4oW7Ys6tatm6f35MSDBw+w\n",
443 "f/9+XLlyJcvnJUmCk5MTQkJCEB0djQsXLqBXr14oXrx4ptfZ2tqiTZs2WL9+PaKjo/OkwdbWFt26\n",
444 "dcv3OQgEpkSjtgBB0aVChQrQ6/XYu3dvjq+Li4tDzZo14evri+vXr6Nt27bYvXs3Bg4caHhNWloa\n",
445 "AOA///kPXF1d0b59+5fMSz7mtWvXcO/evVfqGz9+PHbs2AF7e3t88803GDduXK7OKyUlBbGxsdBo\n",
446 "TPv1WrduHd544w34+fll+fyWLVtw5coVjBo1CpGRkUhISIBWq83ytRcvXkSJEiVQuXJlk2oUCJRE\n",
447 "GJhANfr374/y5ctj1KhRePLkSabnTp06halTp0KSJGi1Wnz88cfYvXs3du/ejRUrVqBDhw5o3bo1\n",
448 "iAgAcOPGDQBAREQEEhMT8fjxY8MtJibGsN/x48eDiDBw4EDodLpMx1y6dCk2bdqEevXqAeDRWufO\n",
449 "nbF79244Ozvjhx9+wKZNm155XpcvX0ZkZGSBPpus2LFjB9zd3V96PCkpCd9//z369OmDb7755pXZ\n",
450 "gRcuXMC1a9cwd+5cODo65kkDEeH69esvfXYCgRoIAxOohp2dHdavXw+NRoMGDRpgxowZCAkJwcyZ\n",
451 "M9G8eXNDWnmzZs0we/ZsdOjQAR06dECpUqUAcMhMJiQkBABQpUoVlC1bFmXKlDHc3n//fcPrqlat\n",
452 "il9//RXHjx9H48aNsWjRIly9ehWDBw9GYGAgSpcuje7du2PkyJEoX748AKB58+ZYtGgRAGDjxo2v\n",
453 "PK/jx48D4HCbKfH398fmzZsxbtw4LF68GIsXL8b06dNRqVIlzJw5E7Nnz8bYsWMBwDDy0uv1L+0n\n",
454 "KCgI9erVwzvvvJNnDXPmzEHVqlXh7++PO3fuFOyEBIICIubABKrSsGFDnDp1CtOnT8eXX36JL774\n",
455 "Ara2thg5ciQ+++wzHD58ONtQXKNGjVCnTh0AgJ+fHypUqIBWrVoB4B/wLl26wNnZ+aURSWBgIKpW\n",
456 "rYovv/wSQUFBAAAvLy8sWrQIr732GgDgxx9/zPSePn36IDk5GQEBAa88p/DwcAC8Ru1F7t+//8r3\n",
457 "Z8fMmTPh7e2NX3/9FU+fPoWtrS2CgoIwf/589OjRI9Nry5Yti5o1a2Lbtm1ITExEsWLFALABnTp1\n",
458 "CpcuXcryGK/S5+7uDkmSYGdnBycnp3yfi0BgElROIilSJCcnZ5sOLsiaI0eO0Mcff6y2jDwhZzEO\n",
459 "HTr0peeOHTtGTk5OdOfOHbPrWL58OUmSREFBQbRo0SKaNGkS2djY0PLly7N9j5L6BIKCIhGlTyII\n",
460 "zMr9+/fRsGFDhIeHY968eRg5cqTakgRmYubMmZg5cyZ27tyJZs2aqarlrbfewpYtWwBwKHb69Omi\n",
461 "goag0CAMzMzo9XosWLAA48ePR1xcHAAOw5w+fRqVKlVSWZ1AIBBYLyKJw0Q8ffoUqampmR67fPky\n",
462 "WrRogZEjRyIuLg5ubm4AgMjISHTq1AnPnj1TQ6pAIBAUCoSBmYCIiAh8/PHHOHfuHABeBzR16lTU\n",
463 "q1cPx48fR+nSpbFx40aUL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ICx9WrV2FrawsXFxcAwN27d9G1a1dDCPHff/81tL3PDcLABAKBwHSI\n",
477 "JI5siIiIgK+vL37//Xc4OTkhOjoaKSkpaNeuHQBOs9fpdChevHiuW6t7eXnBxsYGkZGRSEpKgoOD\n",
478 "gzlPQSAQCAo1YgSWDW5ubhgzZgy8vLxw4MAB/PXXX0hJSUFgYCD++usv/P7774iIiECjRo0y1UfM\n",
479 "CY1Gg1KlSgEAHj9+bE75AoFAUOgRI7Bs0Gg0GDlypKEZ5ZUrV7BlyxasXLkS69atA8CjsOTkZADG\n",
480 "1PpXUapUKTx48ABhYWGoUKGCOU9BIBAICjViBJYFcpLGhQsXMGPGDKSlpaFRo0b4+uuvcffuXZw7\n",
481 "dw6ff/453njjDTRo0CBP+/b29gYAPH/+3OS6BQKBoCghRmDZsG7dOowaNQpPnz5Fq1at0LRpU9y+\n",
482 "fRvR0dGoW7cuvvrqK8TExBh6feVm9AXAkPSRmppqNu0CgUBQFBAGlgVnzpxBYGAgunbtioCAACxc\n",
483 "uBAxMTGYMGEC7t69Cy8vL+zevRuVKlXK875tbW0BGJtbCgQCgSB/iBBiBvR6PQBgx44d8Pb2xs8/\n",
484 "/4y33noLmzdvxldffYXmzZvj9u3baN26NYKCggAg14uYZWQDEyMwgUAgKBjCwLJg3759aNiwIezt\n",
485 "7VGnTh1UrFgRvr6++N///gc3Nzf4+flh37592LVrV65DhzKJiYkAIFLoBQKBoIAIA8uAvIC5ePHi\n",
486 "uHLlisFsEhISUL16dYNZyYkYcgWOvIzCIiMjAYhuzAKBQFBQhIFlwYgRI2BrawsvLy8QEVasWIHB\n",
487 "gwcb1nvJC5ebNm0KIPcJHIDRwF7VvVkgEAgEOSOSODIgN7GsUqUK/P39ER0dDVdX15e6J1+9ejVT\n",
488 "lfq8IEZgAoFAYBqEgWVAHkmFhYUhODgYHh4esLW1hZ+fH1q2bIlu3bohICAAly5dQq1atQAAOp3O\n",
489 "0CcsN4gRmEAgEJgGifKaRlcECA8PR1JSEsqV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ddvn2bateurZygoCAW0qaNald2PXuyhC++UOXwpiMujuNHkkT05InaasxC\n",
607 "vXr8f7Vtm9pKTEhCAo9uZPMy0RzwF1/wLosV48SXAhERQfT118b5BoAoIIBo6dLMV7+ClxAGZiIS\n",
608 "EowhM0kimjcv8/NpaWlUpkwZcnZ2VkbQqVPGxI2QEGWOmQXHjvFn4u7OHmDVdOrEJ/P772orMTl3\n",
609 "7vCpOTkRJSaqrcZEpKURdetmNC8Tfg/0eqKhQ40h16tXTbDT+Hiin34iKl/eaGS+vkSzZike/rcW\n",
610 "hIGZgNBQovr1jT8Amza9/JrY2FgCQI6OjuYXpNNxKALgbCeVee01lvLTT2orKSDz5vGJ9O6tthKT\n",
611 "M3s2n9rbb6utxISMHs0n5eHBE3wmJiWFqEsXPkT58kQPH5pwxytWZE7D9/AgmjxZpTU4loswsALy\n",
612 "9998cQcQVapEdPFi1q+Lj48nAFSsWDHzi1q0iAWVKaNS6mNmNmwwfj5paWqrKQC3b/OJuLgUutDO\n",
613 "66/zqa1apbYSEzF3Lp+QnR3R4cNmO0xcnPFasU4dEy/x0uk4ntusmdHIihfntHyrT+01DcLA8klq\n",
614 "KtHEicaMpLZtOWciOxITEwkA2dvbm1fY8+cc0wCIVq8277FySVoaUcWKLKlAk96WQPXqfCL79qmt\n",
615 "xGQ8eWJMtslDVrnlsnu38Yu5cqXZD/f0KZG/v3G6OSnJDAc5fNg43JNT8N97T7F1nZaKKOabD0JD\n",
616 "uSDv119zZZivvuIqQ56e2b9HSi8hQ+au3PXf/3LZqNatuT+6BaDVcglGgPtoWjVdu/J21y51dZiQ\n",
617 "rVv5V7FtW+4IbtXcvw8MGMAnNHky3zczXl7c/LNUKWD/fmDw4JxLJeaLFi2AHTuAc+e4NJVeD/z+\n",
618 "O1C9OnfEPXy4aLaRVttBrQm9nuiXX3ghvVyYIbcLPlNSUggA2djYmE/ggQMszNbWLDH/ghAezrI0\n",
619 "GiuPfvz9N3/GSmaTmpmOHfmUFi5UW0kBSU42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eO89/pOaPFltJfkgJsZYZHDHDrXVKEJiItHmzUQffkhUpUpm\n",
672 "M3vx9vPPL79fp9ORPocrlevXr9OSJUtowIAB5OfnR5Ik0S/pIZFx48aRJEn0VXpxcJNWEDIRqi9k\n",
673 "LiqkpqYCAGxfzJXNirg4znDYvJlrnK1YYZioLkx4ePBasD17OCMxQzKZdWBnx8kEV67wrUEDtRXl\n",
674 "SFISL6QFOPvW6pg9G3j2DGjeHOjcWW01iuDgwAue5UXPDx4A589zW7DLl/nfciJsyZIvvz+rJKVn\n",
675 "z55h8uTJWLRoEdLS0uDq6oqAgAC0bNkSkydPRq9evQBwkgbASxOy25faCANTiFwb2PXrQO/ewMWL\n",
676 "nKa9bh2QnplXGOnd25jIZ3UGBvAC8itXgJAQizewnTuBmBiWGRCgtpo88uwZr/oFgBkzrKLqjDnw\n",
677 "9eWb3FdVhghIS9NDr2ejSUlJQXBwMPbt24eIiAgMGDAATZs2BcBFGRYsWICAgADMnj0b3t7eKFmy\n",
678 "JNzc3ODo6GjIbKxSpQoAGFLkLdHALE+RudHpuG1quqEoRVpaGgBe25ElRLyuq149Nq+AAOCffwq1\n",
679 "eQFAjx6cxr1vHzeStjrSK6AgJERdHbkgvWCIpTTqzhszZwKxsbx0oUULtdWoAqWveHr48CEOHjyI\n",
680 "x48fA0B65RLA1lYDjUaD06dPo1KlSmjbti02bNiAvXv34u2338aoUaOQnJwMR0dHAMDnn3+OTp06\n",
681 "oUGDBvBNX8eYMS1froYSGhqKiIiITBosBrVjmIpz7JhxNvSdd4j++IMoIsLsh719+zZt2bKFkrOq\n",
682 "ln3jhjElD+DOj1FRZtdkKXTowKe9eLHaSvLB+vVk6ABswSQmGhst3r6ttpo8cv++sfPwmTNqq1EF\n",
683 "OUPwxo0bZG9vT5Ik0bvvvpvp+X///ZfWr19P1atXpxo1atC2bdsoOjqaIiMjqV27dqTVaunIkSNE\n",
684 "ROTh4UFBQUH077//0ooVK2jQoEHUsWNHunbtmmGfu3fvJh8fH6pfvz7dvHmTiHgZQE5zakpT9Axs\n",
685 "925eP5Jx9lOrJWrVijOc0v+jFOHJE6Lx44ns7FiHiwvR8uVWmh6WfxYv5tPv0EFtJfng+nUWn5fs\n",
686 "UhXYutWYkm11jBjB4t9+W20lqtOnTx9ycXGhLl26kCRJ9NFHHxmSKz799FNq06YN7d27N9N7li9f\n",
687 "Tj169KD9+/cbHnvjjTdIkiRyc3OjUqVKUevWrWnNmjWUnJxsyFA8fPgwOTs7U8eOHenZCx2uIyMj\n",
688 "KSQkRHUzK3oGJnPrFtGcOURt2rCBZTQ0Pz/+0qxebfpVtno9X0UGBRE5OBiPOXiwQq1bLY9nz6w4\n",
689 "GzEtjRtqAaq1sc8NgwezxG++UVtJHrlxg/8wNBrOFy+k3Lhxg4YNG2YY6WTFtWvXyNHR0ZAlOGLE\n",
690 "CJIkiZYvX05ERMePH6dWrVrRsWPHiIgzDL/88kuSJIlGjBhBqampBsPp27cv1a1blxITEykhIYFi\n",
691 "s8jDv3TpEjk7O5OzszMFBQXRhg0b6L333qPq1auTJEnk7OxMoaGhpv4o8kTRNbCMRERwpYu+fV9e\n",
692 "eAEQVa1KNGgQ0dy5REeOcEOfvFx5PHzIubCffkpUsWLmfXfvrnoLdEugUyf+OBYuVFtJPmjShMVn\n",
693 "uMK1JFJTidzdWaLVeUC/fix86FC1lZiVQYMGGVLYXxzVyP/eu3cveXt70x9//EFERCEhIdSoUSOq\n",
694 "X78+XU4v2TFy5EiaPn06ERF988035O7uTm+++Sa1bduW6tatSxcvXiSdTkdDhw4lPz+/l3To9Xp6\n",
695 "mn4VmZSURE2aNCFJkgw3T09PevPNN2n16tX0559/UpTKUx0iCxHgnhL9+vEtNZV7bB04wLejR7ny\n",
696 "+NWrwPLlxve4ugKVKgElSgCenrwPSeJy06mpQHg48OgRF15Mn2w1UKoUt+EYOZIragvQpw+wezdn\n",
697 "Iw4frraaPFKnDifcnD+fqbiypXD6NHcA8POzsuzD8+e51qGdHTB5stpq8gSl13vVarU51iuUXyMX\n",
698 "6PX09IQkSYbH5X1JkoT4+HhERkYiLCwMAFC9enVMmzYN77//Pg4ePIhq1aqhYsWKOHfuHADgww8/\n",
699 "xLvvvgs3Nzc8efIE3377LaZMmYL169ejSpUqWL58OaKjo3Hv3j3s2LEDBw4cwJkzZ9C4cWOsW7cO\n",
700 "zs7OWLFiBcaNG4fDhw+jfv36GDt2LBo0aAAvLy+LaNckDOxFbG2B117j24QJXDj07Fk2tdOngQsX\n",
701 "gBs3gOhofjw3uLgADRtyCfyuXYFmzaywgqp56dGDe4Tt389NRr291VaUB+Q2Eiaugm4q/vqLtx06\n",
702 "qKsjz0ycyNsPP1S++nYBkftuvQqtVovU1FSULVsWAHLsNyhnMLu4uAAAjhw5gokTJyI8PByHDx/G\n",
703 "Bx98gGrVqmH79u2G18vvcXZ2RunSpZGUlGQoCAwA5cuXN7SDatWqFcaOHYv33nsPzs7OSEtLg5+f\n",
704 "H1atWoXiGTv7WhDCwF6FnR3QpAnfZIh4hHX3Lud+P38OyBXmNRq+lSjBTa/KlOEvnwWuobAk3N2B\n",
705 "du240eiff7KZWQ116vD2/Hl1dWSDVRrYsWPcbdbRkS8krYyoqCisXbsWOp0OgYGBOVZr12q1qJoe\n",
706 "icnYokRGvm9nZwedTodNmzbB19cXEyZMQEBAgOFYM2fOROXKlSFJEu7du4fy5csjNjYWFy9exC+/\n",
707 "/IKVK1di48aNkCQJpUqVgouLC/z9/fHGG2+gTJkyaN26NcqVKweNRgMigo2NDYjIYF46nc5Qud9i\n",
708 "UDWAKRBkQK6N2Lq12krySFQUC7e3N0+11QIQFcU5EDY2RNHRaqvJJXo90euv82f65Zdqq3klGZMj\n",
709 "5H9/9dVXhkSHyMjIHN+v1+tp3rx5htT4F4vqyvu+dOkS+fj4kCRJVLx4cerWrRtFR0fT2rVrqVix\n",
710 "Yt33RU8AACAASURBVPTll1/SvXv3qHfv3jRu3DhasmQJjRgxgsqVK0eSJNHYsWMN+wwPD6fz589T\n",
711 "vJWUQMsOYWAKkZiYSAsWLKBx48apLcViiYw0tlh58kRtNXmkfHn+wbWE/hcZ2LSJZbVoobaSPLB3\n",
712 "L4t2d7f49ZCRkZE0depUWrZsGRHxOqnjx48bkh6CgoJyrCEom9Py5cupePHi1LNnT4PhvWhkz549\n",
713 "oxYtWlDNmjUNmYZERPfv36fWrVtT48aN6fbt2/T++++TJElkb29P1apVo2HDhtHGjRuzzDR8UYe1\n",
714 "IQxMIR48eEAAqHTp0mpLsWi6dOHfrgUL1FaSR7p3Z+Fr1qitJBMffMCypk1TW0ku0euJmjdn0TNm\n",
715 "qK3mlYSHhxvMavPmzURE1LRpU5IkiVq3bk23bt3K8f2ySS1fvtyQ7p7RaJKSkuj8+fMUHBxMaWlp\n",
716 "NGTIEGrSpAkRsVnKa7b+/PNP8vLyosuXL9OdO3fo3Llz5jhdi0NMzCiEHEdOSEhQWYll06cPb9ev\n",
717 "V1dHnrHQRA6rm//at4/nvzw9gY8+UlvNK/H29kZQUBC0Wi3ee+89tG7dGmfPnoWtrS2++OILVKpU\n",
718 "Kcf3U3ppJg8PD0iShPXr12P8+PGYOXMmWrRogTJlyqBu3br46KOPEBMTg8qVK2d6v5yp2KVLF4wY\n",
719 "MQKOjo6oUKEC6qTPy+r1euj1essrAWUiRBKHQsj1x+Lj41VWYtm8+SYngh48yHkyJUqorSiXWKCB\n",
720 "3brFN3d3i68zbGTqVN6OHQs4O6urJZf89NNPKF68OGbPno1Dhw4BAPr27Yu2bdtCr9fnWARXfq5W\n",
721 "rVqoXr06QkJCMH/+fABA7dq1MWjQILz11lvQaDRwdHREVFQUwsPDkZSUBAcHB8N+7O3t8c0332S7\n",
722 "/0KL2kPAooJeryetVksAKCUlRW05Fo1cFtKqwohXr7LocuXUVmJgwQIrq8B06hQLdnPj3l9WxJMn\n",
723 "T2j06NGGcGLVqlUpODiYiCjb5pEvcvv2berYsSPVqlWLPv74Y7p06RIlJCS89JrHpq4OZMUUcnu2\n",
724 "HCRJEqOwXPL227y1qjBilSrcv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6cN09dWwSNEiFgCiGWEJWjWTOe7F2v56n5GgSPWEY07H+Z3PLhtm3A1auAhwf3IgUChRECphD5\n",
777 "+fkAAFuRoUARDMuI0dHq2lFrRozgzzEx3LOpgOH8l0kJWGkpsHgxv160iC+BCgQKI/7XKURJSQkA\n",
778 "wNLSUmVLGgcvvghYWgLHjwPXr6ttTS3o2JF7Mjk5fM3wAXfu8BD6Jk14xL3JsHUrr13Tvj0waZLa\n",
779 "1ggaKULAFEIImLLY2QE6HUBUXgDS5KliGTEnhz8PG8ZFzCS4fx/4n//h1yEhfMNRIFABIWAKYRAw\n",
780 "CwsLlS1pPDTYZcQKaURatuSepElln9+0CUhN5V7j+PFqWyNoxAgBUwiDgJmbm6tsSeMhKIh7LfHx\n",
781 "wJUraltTC/r04anmk5OBf/0LAE9u8cILJhQjUVICfPQRvw4NNcGswoLGhBAwhZAebHLra1E2Q1A3\n",
782 "NG1aXql5+3Z1bakVZmZ83RMwWkacMwcwmfSZ69YB164Bnp7A6NFqWyNo5AgBU4gmDzYwCgoKVLak\n",
783 "cdHgDjUblhErCJi/v0q2PExBQbn39dFHwvsSqI4QMIUwCFhhYaHKljQudDqeKzchgQfNmTxDh3JP\n",
784 "7MQJIDMTAN8DMwlWrwZu3gS8vcuLrwkEKiIETCGsra0BCA9MaayseEg90EAONdvbcxHT603LbczL\n",
785 "A8LC+PWSJaJkisAkEAKmEMIDUw/DqtyBA+raUWsmTuTPW7aoa0dFVqzg6f39/XmaE4HABBACphDC\n",
786 "A1OPwYN5ooi4OO5ImDwjRvCDbGfOAJcuqW0NP00dEcGvhfclMCGEgCmECOJQD0dHwM+PZz8yVDU2\n",
787 "aayty6NP1qxR1xYACA8H8vOBwEATiigRCISAKYbBAxNLiOpgqBnZYJYR336bP2/cWGWJFcXIzARW\n",
788 "reLXH3+snh0CQRUIAVMI4YGpS0UBI1LXluq4fZs7OgCALl2AAQN4ra0NG9QzKjycFyR78UXgb39T\n",
789 "zw6BoAqEgCmEIQdicXGxypY0Try9eS2tq1d5ogtTZNUq7nDJGCocf/opFxGluXED+PJLfh0aqvz4\n",
790 "AkENCAFTCCFg6iJJ5cFzpriMWFICfP11+WodAJ7ct3t3nk7fICRKEhYGFBXxM1/duys/vkBQA0LA\n",
791 "FEIImPqY8j7YDz/w7SYLiwpLnJJUvu+0dClfTlSKjAyuqIDwvgQmixAwhRACpj4GD+yXX9RZkXsU\n",
792 "q1fz57feeihKfdgwHkKZlcVFTClCQ4HiYuDll4GuXZUbVyB4DISAKYQQMPVxdQV69uSrYocPq21N\n",
793 "Ob//zs+o2dmVn2GWYQxYvpxff/qpMufCzp4FoqJ4SisReSgwYYSAKYQQMNPgv/6LP2/erK4dFTF4\n",
794 "X5MnAzY2VTTo3RuYNo0Xkpwxo37DKIl48IjhuWPH+htLIHhKGJGpBhX/Z3Hjxg1otVq4urri5s2b\n",
795 "apvTaPn3v4FnnwXMzXleWkdHde3JyeFFKwsLuXP13HPVNMzO5mKSlQWsXQu8/nr9GLRhA/Daa0Dz\n",
796 "5jxc02TquAgElREemEIID8w0aN2aF4gsKQG++05ta3jYfGEhT3dVrXgBQLNmwOef8+s5c+SCl3XK\n",
797 "1avlofsREUK8BCaPEDCFMAiYoTKzQD1ee40/r1mj7qFmvb48U9Rbb9XiDePH80dBAU81VZeH4u/f\n",
798 "ByZN4iepR40CJkyou74FgnpCLCEqRGlpKczNzaHRaFBaWqq2OY2a+/eBtm358aqffuIemRocPMhD\n",
799 "+1u3BlJTecxEjeTm8kiU1FReETk6mofbPy1z5gArVwLPPAMkJvIlRIHAxBEemEJoNBowxlBWVoay\n",
800 "sjK1zWnUmJuXezyGVTk1MBxanjGjluIF8GW9vXt5yOL33wMLFz69G/nll1y8zM35gTQhXoIGgvDA\n",
801 "FMTKygrFxcUoLCyElZWV2uY0arKyuOdTVAQkJSkfbJeWBrRvzzUjPR1wcXnMDvbv55k6ysqA+fOB\n",
802 "zz57sjInmzYBU6bw6/oMDhEI6gHhgSmIhYUFABHIYQo4O/MtH4DXalSar77ijtMrrzyBeAGATsc9\n",
803 "MHNzfk7sv/+bq3FtIeIHo6dO5T9/+mmjEC+9Xo/x48dDkiS8Xov5ZmZm4oUXXkBKSooC1tUNCQkJ\n",
804 "WLx4MTaomQRaKUigGM7OzgSAbt26pbYpAiK6dImIMSILC6L0dOXGLSggcnIiAoji45+ys337iKys\n",
805 "eGedOxOdOFHze27dInrpJf4egCgs7CmNUJedO3eSk5MTMcbkR9euXenPP/+s1HbmzJnEGCN7e3ti\n",
806 "jNGRI0fke9u3b6d33nlH/lmv11Pfvn2JMUaffPIJERF5eHgYjWN4TJgwgdLS0oiIKDk5mZ5//vkq\n",
807 "2zHGaO7cuURElJGRQf7+/kb3LC0tacuWLU/0ORQVFdG4ceNIkiTS6XSUmJhIREQJCQkkSRKFhYXR\n",
808 "/fv3ydzcnN57771K7w8JCSHGGH377bdERLR+/Xpq3rx5lXPQaDSUkJDwRHbWJULAFESr1RIA+ve/\n",
809 "/622KYIHjB7Nv8MffKcowvr1fExvbyK9vg46/L//I3J3LxekgQOJNm4kysgoH6C4mOjMGaJ33yWy\n",
810 "t+ft7OyI9uypAwPU48yZM2RpaUmtWrWi2bNnU1RUFC1atIjs7e3Jzs6OLl26JLeNj48nxhhFRkbS\n",
811 "7du3yc3NjTw9PUn/4DOaM2cOMcZowYIFRET0xRdfkIWFBWk0GvL29iYiIsYYSZJEY8eOpaioKIqK\n",
812 "iqJp06YRY4z8/PyIiEin0xFjjIYOHSq3MTw2bNhA9+7do9LSUvL19SUzMzMaMWIErV27llavXk1d\n",
813 "unQhxhgtWbLksT6HwsJC8vLyIltbW1q7dq08JyKi5cuXE2OMpk6dSkVFRcQYoyZNmtCJh/7YMQjY\n",
814 "sWPH6ObNm8QYIzMzMwoNDa00j4MHDz7+P1Y9IARMQdq2bUsA6PLly2qbInhAYiL/Lre2JsrMrP/x\n",
815 "9Hqibt34mBs21GHHBQVEH3xAZGtbLmQAUdOmRI6ORGZmxq8HBhIlJ9ehAepw8eJFs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qgyAMFDR\n",
842 "exk1alS17fLz85Geno709HR4eHggNTVVvscYQ2xsLAIDA2W7q2L58uUYPnw43N3dqx3HQEZGBvbv\n",
843 "34/AwEAcP34cd+/exZo1a5CXl4fg4GBkZ2cjKSkJjDGYm5tX2cf777+P9PR0ODk5YciDsuUXLlwA\n",
844 "AIwZMwatW7fGlStX5PbPPvssUlJSYFbr/Gf1h/oWNCKEgJk2Hh48p21EBN+jOn0a0Gievt+LF3mB\n",
845 "Y0kCPvjg6fsTGENERlGC+fn5eOONN+Dg4CB/IScnJ8PKygq9e/c2eq+Pj4/swXXr1g3u7u7y76kB\n",
846 "Pz8/oz0lQ0adqmjSpAm0Wi08PT3RqlUrBAQE4JlnnkG/fv3g7OxcrWgBPEPPgQMHEBYWhri4uFrN\n",
847 "/ejRo3jjjTcgSZK8F+jn54djx46hT58+uHLlCkpKSsAYg6+vL/5VRRkeSZLw9ddfG73Wvn172NjY\n",
848 "YNSoUdA8+CV4/vnn0aZNG3Tr1s0kxAsQAqYoQsBMn9BQHvp99ixPL7hgwdP1RwTMns1TFs6YIbyv\n",
849 "uqaoqAh79uyBq6sr1q1bh5iYGOzevRu9evXCkSNH5HaXL1+GtbW10XKfgenTp8sBE8nJyZXuP/fc\n",
850 "c3juQbG2KVOmwNfXt1p7LCwskJ6eXivbt23bhpycHKxbtw6pqan46quvUFxcjNjY2Gr3zR6mb9++\n",
851 "sLS0RElJCXQ6HWJiYqptK0mSkdA/iuDgYOTl5dWqraqoGgPZyJg1axYBoBUrVqhtiuARxMaWh36f\n",
852 "Pv10fUVF8b6aNePR7IK6JTEx0SjFkY2NDYWGhlJeXp7aptVI9+7dZbsN6Z/OnTtXp2NkZGSQJEk0\n",
853 "f/58IiJKTU2lnj171ukYaiI8MAURHljDQKfjS4mRkTwM/ORJoFWrx+/nzz+59wXwsi1OTnVrSCc+\n",
854 "OgAADbxJREFUpwBwc3PD4sWLERAQgH79+qltzmMxf/585Obm4u233663MbRarVH5Jjc3N5w9e7be\n",
855 "xlMaIWAKYthEFQUtTZ/wcODMGS5eQ4cCx48Djo61f//t28Dw4TwRxpgxPHhDUPfY2dnhH//4h9pm\n",
856 "PBGTDOUQBE+MCKNXEMP6M4kSbCaPpSWvG9mpE3DhAtCvH8/SVBtycoBhw4DkZJ6q6uuvn6xUl0Ag\n",
857 "eDRCwBRECFjDolkz4OBBHnhx/jzQvTsPsX9UQe3TpwE/P+B//xdo146nHLS3V85mgaAxIQRMQQxn\n",
858 "SYSANRxatwbi4vhyYE4O8NprQIcOPFrx5595iHxCArBxI08K3Ls397y6dgWOHv3PyrghEJgaYg9M\n",
859 "QQwe2KNytwlMDycnvpz43Xf8HFdqKrB4cdVtLSyAuXOBkBCgSRNl7RQIGhtCwBRELCE2XBgDJkzg\n",
860 "ARmHDwN79vCyKFlZXLQ6dAD69OHBGtVkCBIIBHWMWEJUECFgDR8zMyAwkJfcOnECSEoCzp0DduwA\n",
861 "5s0T4mXq6PV6jB8/HpIk4fXXX6+xfWZmJl544QU5N2Bj5ejRowgNDcWPP/6otilGCAFTELEHJhDU\n",
862 "PT/++COcnZ0hSZL86NatGy5fvlyp7axZsxAdHQ07OzusX78eR48ele99//33ePfdd+WfiQgvv/wy\n",
863 "Dh8+jB07dgDguRMrjmN4TJw4Uc4XmJKSgj59+lTZTpIkzJs3DwBw/fp1BAQEGN2zsrLC1q1bn+hz\n",
864 "2LdvH9q3bw9JkvDcc89h586dldro9Xq88847sLCwkMccPXp0td9JOTk5GDJkCAYNGoSUlBR0794d\n",
865 "ALB7925IkoTo6GikpaVBo9HIyYMrMmXKFEiSJCcUDg8Ph52dXZWfi42NDa5fv/54k1bvDHXjY8mS\n",
866 "JQSAFi5cqLYpAsF/BGfOnCFLS0tq1aoVzZ49m6KiomjRokVkb29PdnZ2dOnSJbltfHw8McYoMjKS\n",
867 "bt++TW5ubuTp6Ul6vZ6IiObMmUOMMVqwYAEREX3xxRdkYWFBGo2GvL29iYjkrBljx46lqKgoioqK\n",
868 "omnTphFjjPz8/IiISKfTEWOMhg4dKrcxPDZs2ED37t2j0tJS8vX1JTMzMxoxYgStXbuWVq9eTV26\n",
869 "dCHGGC1ZsuSxPoft27eTmZkZOTg40MKFCyk8PJxGjhxZqV1ERAQxxqhr1670zTffkI+PDzHGaObM\n",
870 "mZXaXr9+nVq1akUuLi60e/duo3uzZ88mxhgtXryYkpKSiDFGLi4ulJSUZNRu8uTJxBijq1ev0unT\n",
871 "p4kxRk2bNqWIiIhKn01cXNxjzZmISAiYgnzyyScEQP4FEQgET8fFixfJ0tKSFi9ebPR6dnY2ubi4\n",
872 "UFBQkPzaihUryNLSknJycoiICxRjjGJjY4moXMBcXV0pISGBtFotLV++nMLCwowqMut0ukp2eHp6\n",
873 "kqurKxERLVu2jMzNzam4uPiRtgcEBBhVQCYi0uv1NG3aNHJwcKA///yzVp/BsWPHSKPRkKurK/3+\n",
874 "++/VtktNTSUzMzPq0qUL/fHHH0REVFZWRmPHjiXGGEVFRclts7Ozydvbm5ycnCg3N7dSX7GxsZUE\n",
875 "zFARuiKTJ08mjUZDmZmZVFJSQg4ODvThhx/Wal61QQRxKIjYAxP8R1JczOvFADx7sV7Po14YA/Lz\n",
876 "gYICwNmZh3MOHgx06VJnQ3fq1AmzZs2q9Dvl6OiITZs2Yfjw4cjNzYW9vT1iYmJgY2MDBwcHAEBQ\n",
877 "UBBCQkLkoo6GhL63bt2Ct7c3evTogenTp2P79u1GSXCDg4ONxtq/fz8uXbqE8PBwAICtrS3KysqQ\n",
878 "mJhoVFXZ2dnZKIv7mjVrEBQUZNQXYwyrVq3CgQMHsHfvXsydO/eR8y8uLsakSZPAGMORI0fg6elZ\n",
879 "bdulS5eiefPmOHv2rJwVSJIkbN26FTk5OVi1ahVee+01AEBISAgSEhLw5Zdfws7OrlJfu3btkq8r\n",
880 "1jg7cOAADh8+jEGDBgHgWYeef/55OeO/lZUVkpOTcfPmTfk9lpaWcHycNDcVqTMpFNRIeHg4AaB3\n",
881 "331XbVMEgrojL49nLK7N45tv6nz40NBQCg0NrfJeixYtKDo6mgoKCkir1dIrr7wi38vOzqbg4GDq\n",
882 "378/EREdPXqUGGM0d+5csrKyot9++42IiFJSUow8sI4dO1J8fDxdv36dIiMjycrKivz9/eV+IyMj\n",
883 "iTFGtra2JEmSfL1hwwYj29LS0qht27ZV2r1w4UIKDAysce7fffcdMcZoxowZj2yXlpZGFhYWdOjQ\n",
884 "oSrvG7y4y5cvExHR3r17ycnJiTQaDU2cOJEyMjKM2huWBlesWEFLly4lOzs7OnfuHPXo0YO8vLwo\n",
885 "Pz+fiIisra1pwIABRMS9y2bNmpG5uTk1adKEGGOk0WioV69edPfu3RrnWhXCA6tniAh//fUXHB0d\n",
886 "H3kOLDc3F3Z2drUudyAQmAwWFvzgmwFJKvfEbG35gbjMTCA3t069LwN6vd6o4GRFfH190aZNG2Rm\n",
887 "ZuLGjRtISkpCRkYGtm7divfeew96vb5S6ZJ58+Zh0qRJcu2uh/tOTk42qivm7+9vVMZkz549cHd3\n",
888 "R3JyMi5cuIDMzEz079+/Uj/0iJUYHx8f3Llzp8a5FxcXAwCmTp36yHZbtmyBr6+v7Bk9jJ2dHfR6\n",
889 "PS5duoR27dohKCgIWVlZ2LlzJ95//305KGTw4MFG7xs5ciQ2btyIZs2aoUuXLli5ciUGDhyIF198\n",
890 "EStXrkRRUZH8nRYXF4ecnBx8++23GD16NI4fP4527dqhXbt2Nc6zWp5I9gS1orS0lGbMmEEeHh50\n",
891 "+/Zt+vTTTwmAXNqAiP9VsnXrVnJ2dqZt27apaK1A0DDx8/OrtAdGRHTv3j2ysLCgvLw8SktLMyq7\n",
892 "YmtrSz/88AP17duXGGOUmZkpe2BXr1416mfjxo1GHphGo6HZs2fTwYMH6eeff6aioiKj9v369aOp\n",
893 "U6fWaPdXX31VrQc2fvx4WrlyZY19GGz+6KOPHtmua9eu9OOPP1Z5r7S0lMaNG0cdOnSg0tLSSvdL\n",
894 "Skrogw8+IK1WS2lpaUREFBQURJIk0ZUrVygkJMRoHtHR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jD+PHjERERgaZNmyImJgbLli3DggULoNfr0aFD\n",
908 "B4wePRrJycmVhHvHjh348MMPIUmSvF8/dOhQxMTEwMvLC7/88gsAoGXLltBqtVXaZG1tje+//97o\n",
909 "NQ8PD7i4uGD48OEAuKAPGjQILi4u8PX1rfV8jaizxUjBI/n1119Jo9EQAAJAWq2Wdu3apbZZAkGD\n",
910 "prCwkHr06EFDhw6ltWvX0siRI4kxRj4+PkaRbWvWrKFmzZpV2UdISEi1+0MPM3Xq1EqHdZ+UsLAw\n",
911 "sre3p7Vr19KiRYvI0dGRmjRpQr/88kud9P+knDhxgjQaDUmSVGV0o2Evq127dkTEo0Cr28urb4SA\n",
912 "KcjUqVMJAHXu3Jn++usvtc0RCBo8iYmJRsEZNjY2FBoaSnl5eWqbViPdu3eX7ZYkiXQ6HZ07d05t\n",
913 "s2rk5MmTpNFo6PPPPyciotOnT9cq5L8+YETiVK1S0ENLHQKB4OnIy8tDZGQkAgIC0K9fP7XNeSw2\n",
914 "b96M3NxcvP3222qb0mARAiYQCASCBokIoxcIBAJBg0QImEAgEAgaJELABAKBQNAgEQImEAgEggaJ\n",
915 "EDCBQCAQNEiEgAkEAoGgQSIETCAQCAQNEiFgAoFAIGiQCAETCAQCQYPk/wEPvRJNIO9OCwAAAABJ\n",
916 "RU5ErkJggg==\n"
917 ],
918 "text/plain": [
919 "<IPython.core.display.Image object>"
920 ]
921 },
922 "execution_count": 10,
923 "metadata": {},
924 "output_type": "execute_result"
925 }
926 ],
927 "source": [
271 "source": [
928 "from IPython.display import Image\n",
272 "from IPython.display import Image\n",
929 "Image(data=resources['outputs']['output_3_0.png'],format='png')"
273 "Image(data=resources['outputs']['output_3_0.png'],format='png')"
930 ]
274 ]
931 },
275 },
932 {
276 {
933 "cell_type": "markdown",
277 "cell_type": "markdown",
934 "metadata": {},
278 "metadata": {},
935 "source": [
279 "source": [
936 "Yep, this is indeed the image we were expecting, and I was able to see it without ever writing or reading it from disk. I don't think I'll have to show to you what to do with those data, as if you are here you are most probably familiar with IO."
280 "This image is being rendered without reading or writing to the disk."
937 ]
281 ]
938 },
282 },
939 {
283 {
940 "cell_type": "markdown",
284 "cell_type": "markdown",
941 "metadata": {},
285 "metadata": {},
942 "source": [
286 "source": [
943 "## Extracting figures with HTML Exporter ?"
287 "## Extracting figures with HTML Exporter ?"
944 ]
288 ]
945 },
289 },
946 {
290 {
947 "cell_type": "markdown",
291 "cell_type": "markdown",
948 "metadata": {},
292 "metadata": {},
949 "source": [
293 "source": [
950 "Use case:\n",
294 "Use case:\n",
951 "\n",
295 "\n",
952 "> I write an [awesome blog](http://jakevdp.github.io/) in HTML, and I want all but having base64 embeded images. \n",
296 "> I write an [awesome blog](http://jakevdp.github.io/) using IPython notebooks converted to HTML, and I want the images to be cached. Having one html file with all of the images base64 encoded inside it is nice when sharing with a coworker, but for a website, not so much. I need an HTML exporter, and I want it to extract the figures!"
953 "Having one html file with all inside is nice to send to coworker, but I definitively want resources to be cached !\n",
954 "So I need an HTML exporter, and I want it to extract the figures !"
955 ]
297 ]
956 },
298 },
957 {
299 {
958 "cell_type": "markdown",
300 "cell_type": "markdown",
959 "metadata": {},
301 "metadata": {},
960 "source": [
302 "source": [
961 "### Some theory"
303 "### Some theory"
962 ]
304 ]
963 },
305 },
964 {
306 {
965 "cell_type": "markdown",
307 "cell_type": "markdown",
966 "metadata": {},
308 "metadata": {},
967 "source": [
309 "source": [
968 "The process of converting a notebook to a another format with the nbconvert Exporters happend in a few steps:\n",
310 "The process of converting a notebook to a another format with happens in a few steps:\n",
969 "\n",
311 "\n",
970 " - Get the notebook data and other required files. (you are responsible for that)\n",
312 " - Retrieve the notebook and it's accompanying resource (you are responsible for this).\n",
971 " - Feed them to the exporter that will\n",
313 " - Feed them into the exporter, which:\n",
972 " - sequentially feed the data to a number of `Preprocessors`. Preprocessor only act on the **structure**\n",
314 " - Sequentially feeds them into an array of `Preprocessors`. Preprocessors only act on the **structure** of the notebook, and have unrestricted access to it. \n",
973 " of the notebook, and have access to it all. \n",
315 " - Feeds the notebook into the Jinja templating engine.\n",
974 " - feed the notebook through the jinja templating engine\n",
316 " - The template is configured (you can change which one is used).\n",
975 " - the use templates are configurable.\n",
317 " - Templates make use of configurable macros called `filters`.\n",
976 " - templates make use of configurable macros called filters.\n",
318 " - The exporter returns the converted notebook and other relevant resources as a tuple.\n",
977 " - The exporter return the converted notebook as well as other relevant resources as a tuple.\n",
319 " - You write the data to the disk, or elsewhere (you are responsible for this too)."
978 " - Write what you need to disk, or elsewhere. (You are responsible for it)"
979 ]
320 ]
980 },
321 },
981 {
322 {
982 "cell_type": "markdown",
323 "cell_type": "markdown",
983 "metadata": {},
324 "metadata": {},
984 "source": [
325 "source": [
985 "Here we'll be interested in the `Preprocessors`. Each `Preprocessor` is applied successively and in order on the notebook before going through the conversion process.\n",
326 "You can use `Preprocessors` to accomplish the task at hand. IPython has preprocessors built in which you can use. One of them, the `ExtractOutputPreprocessor` is responsible for crawling the notebook, finding all of the figures, and putting them into the resources directory, as well as choosing the key (i.e. `filename_xx_y.extension`) that can replace the figure inside the template.\n",
986 "\n",
987 "We provide some preprocessor that do some modification on the notebook structure by default.\n",
988 "One of them, the `ExtractOutputPreprocessor` is responsible for crawling notebook,\n",
989 "finding all the figures, and put them into the resources directory, as well as choosing the key\n",
990 "(`filename_xx_y.extension`) that can replace the figure in the template.\n",
991 "\n",
992 "\n",
327 "\n",
993 "The `ExtractOutputPreprocessor` is special in the fact that it **should** be availlable on all `Exporter`s, but is just inactive by default on some exporter."
328 "The `ExtractOutputPreprocessor` is special because it's available in all of the `Exporter`s, and is just disabled in some by default."
994 ]
329 ]
995 },
330 },
996 {
331 {
997 "cell_type": "code",
332 "cell_type": "code",
998 "execution_count": 11,
333 "execution_count": null,
999 "metadata": {
334 "metadata": {
1000 "collapsed": false
335 "collapsed": false
1001 },
336 },
1002 "outputs": [
337 "outputs": [],
1003 {
1004 "data": {
1005 "text/plain": [
1006 "[<function IPython.nbconvert.preprocessors.coalescestreams.cell_preprocessor.<locals>.wrappedfunc>,\n",
1007 " <IPython.nbconvert.preprocessors.svg2pdf.SVG2PDFPreprocessor at 0x107d1a630>,\n",
1008 " <IPython.nbconvert.preprocessors.extractoutput.ExtractOutputPreprocessor at 0x107d1a748>,\n",
1009 " <IPython.nbconvert.preprocessors.csshtmlheader.CSSHTMLHeaderPreprocessor at 0x107d1aba8>,\n",
1010 " <IPython.nbconvert.preprocessors.revealhelp.RevealHelpPreprocessor at 0x107d1a710>,\n",
1011 " <IPython.nbconvert.preprocessors.latex.LatexPreprocessor at 0x107daa860>,\n",
1012 " <IPython.nbconvert.preprocessors.clearoutput.ClearOutputPreprocessor at 0x107db7080>,\n",
1013 " <IPython.nbconvert.preprocessors.execute.ExecutePreprocessor at 0x107db7160>,\n",
1014 " <IPython.nbconvert.preprocessors.highlightmagics.HighlightMagicsPreprocessor at 0x107db7048>]"
1015 ]
1016 },
1017 "execution_count": 11,
1018 "metadata": {},
1019 "output_type": "execute_result"
1020 }
1021 ],
1022 "source": [
338 "source": [
1023 "# 3rd one should be <ExtractOutputPreprocessor>\n",
339 "# 3rd one should be <ExtractOutputPreprocessor>\n",
1024 "html_exporter._preprocessors"
340 "html_exporter._preprocessors"
1025 ]
341 ]
1026 },
342 },
1027 {
343 {
1028 "cell_type": "markdown",
344 "cell_type": "markdown",
1029 "metadata": {},
345 "metadata": {},
1030 "source": [
346 "source": [
1031 "To enable it we will use IPython configuration/Traitlets system. If you are have already set some IPython configuration options, \n",
347 "Use the IPython configuration/Traitlets system to enable it. If you have already set IPython configuration options, this system is familiar to you. Configuration options will always of the form:\n",
1032 "this will look pretty familiar to you. Configuration option are always of the form:\n",
1033 "\n",
348 "\n",
1034 " ClassName.attribute_name = value\n",
349 " ClassName.attribute_name = value\n",
1035 " \n",
350 " \n",
1036 "A few ways exist to create such config, like reading a config file in your profile, but you can also do it programatically usign a dictionary. Let's create such a config object, and see the difference if we pass it to our `HTMLExporter`"
351 "You can create a configuration object a couple of different ways. Everytime you launch IPython, configuration objects are created from reading config files in your profile directory. Instead of writing a config file, you can also do it programatically using a dictionary. The following creates a config object, that enables the figure extracter, and passes it to an `HTMLExporter`. The output is compared to an `HTMLExporter` without the config object."
1037 ]
352 ]
1038 },
353 },
1039 {
354 {
1040 "cell_type": "code",
355 "cell_type": "code",
1041 "execution_count": 12,
356 "execution_count": null,
1042 "metadata": {
357 "metadata": {
1043 "collapsed": false
358 "collapsed": false
1044 },
359 },
1045 "outputs": [
360 "outputs": [],
1046 {
1047 "name": "stdout",
1048 "output_type": "stream",
1049 "text": [
1050 "resources without the \"figures\" key :\n",
1051 "['raw_mimetypes', 'inlining', 'metadata', 'output_extension']\n",
1052 "\n",
1053 "Here we have one more field\n",
1054 "['outputs', 'raw_mimetypes', 'inlining', 'metadata', 'output_extension']\n"
1055 ]
1056 },
1057 {
1058 "data": {
1059 "text/plain": [
1060 "['output_5_0.png',\n",
1061 " 'output_16_0.png',\n",
1062 " 'output_13_1.png',\n",
1063 " 'output_18_1.png',\n",
1064 " 'output_3_0.png']"
1065 ]
1066 },
1067 "execution_count": 12,
1068 "metadata": {},
1069 "output_type": "execute_result"
1070 }
1071 ],
1072 "source": [
361 "source": [
1073 "from IPython.config import Config\n",
362 "from IPython.config import Config\n",
1074 "\n",
363 "\n",
1075 "c = Config({\n",
364 "c = Config({\n",
1076 " 'ExtractOutputPreprocessor':{'enabled':True}\n",
365 " 'ExtractOutputPreprocessor':{'enabled':True}\n",
1077 " })\n",
366 " })\n",
1078 "\n",
367 "\n",
1079 "exportHTML = HTMLExporter()\n",
368 "exportHTML = HTMLExporter()\n",
1080 "exportHTML_and_figs = HTMLExporter(config=c)\n",
369 "exportHTML_and_figs = HTMLExporter(config=c)\n",
1081 "\n",
370 "\n",
1082 "(_, resources) = exportHTML.from_notebook_node(jake_notebook)\n",
371 "(_, resources) = exportHTML.from_notebook_node(jake_notebook)\n",
1083 "(_, resources_with_fig) = exportHTML_and_figs.from_notebook_node(jake_notebook)\n",
372 "(_, resources_with_fig) = exportHTML_and_figs.from_notebook_node(jake_notebook)\n",
1084 "\n",
373 "\n",
1085 "print('resources without the \"figures\" key :')\n",
374 "print('resources without the \"figures\" key:')\n",
1086 "print(list(resources))\n",
375 "print(list(resources))\n",
1087 "\n",
376 "\n",
1088 "print('')\n",
377 "print('')\n",
1089 "print('Here we have one more field')\n",
378 "print('ditto, notice that there\\'s one more field:')\n",
1090 "print(list(resources_with_fig))\n",
379 "print(list(resources_with_fig))\n",
1091 "list(resources_with_fig['outputs'])"
380 "list(resources_with_fig['outputs'])"
1092 ]
381 ]
1093 },
382 },
1094 {
383 {
1095 "cell_type": "markdown",
384 "cell_type": "markdown",
1096 "metadata": {},
385 "metadata": {},
1097 "source": [
386 "source": [
1098 "So now you can loop through the dict and write all those figures to disk in the right place... "
1099 ]
1100 },
1101 {
1102 "cell_type": "markdown",
1103 "metadata": {},
1104 "source": [
1105 "#### Custom Preprocessor"
387 "#### Custom Preprocessor"
1106 ]
388 ]
1107 },
389 },
1108 {
390 {
1109 "cell_type": "markdown",
391 "cell_type": "markdown",
1110 "metadata": {},
392 "metadata": {},
1111 "source": [
393 "source": [
1112 "Of course you can imagine many transformation that you would like to apply to a notebook. This is one of the reason we provide a way to register your own preprocessors that will be applied to the notebook after the default ones.\n",
394 "There are an endless number of transformations that you may want to apply to a notebook. This is why we provide a way to register your own preprocessors that will be applied to the notebook after the default ones.\n",
1113 "\n",
395 "\n",
1114 "To do so you'll have to pass an ordered list of `Preprocessor`s to the Exporter constructor. \n",
396 "To do so, you'll have to pass an ordered list of `Preprocessor`s to the `Exporter`'s constructor. \n",
1115 "\n",
397 "\n",
1116 "But what is an preprocessor ? Preprocessor can be either *decorated function* for dead-simple `Preprocessor`s that apply\n",
398 "For simple cell-by-cell transformations, `Preprocessor` can be created using a decorator. For more complex operations, you need to subclass `Preprocessor` and define a `call` method (as seen below).\n",
1117 "independently to each cell, for more advance transformation that support configurability You have to inherit from\n",
1118 "`Preprocessor` and define a `call` method as we'll see below.\n",
1119 "\n",
399 "\n",
1120 "All transforers have a magic attribute that allows it to be activated/disactivate from the config dict."
400 "All transforers have a flag that allows you to enable and disable them via a configuration object."
1121 ]
401 ]
1122 },
402 },
1123 {
403 {
1124 "cell_type": "code",
404 "cell_type": "code",
1125 "execution_count": 13,
405 "execution_count": null,
1126 "metadata": {
406 "metadata": {
1127 "collapsed": false
407 "collapsed": false
1128 },
408 },
1129 "outputs": [
409 "outputs": [],
1130 {
1131 "name": "stdout",
1132 "output_type": "stream",
1133 "text": [
1134 "Four relevant docstring\n",
1135 "=============================\n",
1136 " A configurable preprocessor\n",
1137 "\n",
1138 " Inherit from this class if you wish to have configurability for your\n",
1139 " preprocessor.\n",
1140 "\n",
1141 " Any configurable traitlets this class exposed will be configurable in\n",
1142 " profiles using c.SubClassName.attribute = value\n",
1143 "\n",
1144 " you can overwrite :meth:`preprocess_cell` to apply a transformation\n",
1145 " independently on each cell or :meth:`preprocess` if you prefer your own\n",
1146 " logic. See corresponding docstring for informations.\n",
1147 "\n",
1148 " Disabled by default and can be enabled via the config by\n",
1149 " 'c.YourPreprocessorName.enabled = True'\n",
1150 " \n",
1151 "=============================\n",
1152 "\n",
1153 " Preprocessing to apply on each notebook.\n",
1154 " \n",
1155 " Must return modified nb, resources.\n",
1156 " \n",
1157 " If you wish to apply your preprocessing to each cell, you might want\n",
1158 " to override preprocess_cell method instead.\n",
1159 " \n",
1160 " Parameters\n",
1161 " ----------\n",
1162 " nb : NotebookNode\n",
1163 " Notebook being converted\n",
1164 " resources : dictionary\n",
1165 " Additional resources used in the conversion process. Allows\n",
1166 " preprocessors to pass variables into the Jinja engine.\n",
1167 " \n",
1168 "=============================\n",
1169 "\n",
1170 " Override if you want to apply some preprocessing to each cell.\n",
1171 " Must return modified cell and resource dictionary.\n",
1172 " \n",
1173 " Parameters\n",
1174 " ----------\n",
1175 " cell : NotebookNode cell\n",
1176 " Notebook cell being processed\n",
1177 " resources : dictionary\n",
1178 " Additional resources used in the conversion process. Allows\n",
1179 " preprocessors to pass variables into the Jinja engine.\n",
1180 " index : int\n",
1181 " Index of the cell being processed\n",
1182 " \n",
1183 "=============================\n"
1184 ]
1185 }
1186 ],
1187 "source": [
410 "source": [
1188 "from IPython.nbconvert.preprocessors import Preprocessor\n",
411 "from IPython.nbconvert.preprocessors import Preprocessor\n",
1189 "import IPython.config\n",
412 "import IPython.config\n",
1190 "print(\"Four relevant docstring\")\n",
413 "print(\"Four relevant docstring\")\n",
1191 "print('=============================')\n",
414 "print('=============================')\n",
1192 "print(Preprocessor.__doc__)\n",
415 "print(Preprocessor.__doc__)\n",
1193 "print('=============================')\n",
416 "print('=============================')\n",
1194 "print(Preprocessor.preprocess.__doc__)\n",
417 "print(Preprocessor.preprocess.__doc__)\n",
1195 "print('=============================')\n",
418 "print('=============================')\n",
1196 "print(Preprocessor.preprocess_cell.__doc__)\n",
419 "print(Preprocessor.preprocess_cell.__doc__)\n",
1197 "print('=============================')"
420 "print('=============================')"
1198 ]
421 ]
1199 },
422 },
1200 {
423 {
1201 "cell_type": "markdown",
424 "cell_type": "markdown",
1202 "metadata": {},
425 "metadata": {},
1203 "source": [
426 "source": [
1204 "***\n",
1205 "We don't provide convenient method to be aplied on each worksheet as the **data structure** for worksheet will be removed. (not the worksheet functionality, which is still on it's way)\n",
1206 "***"
1207 ]
1208 },
1209 {
1210 "cell_type": "markdown",
1211 "metadata": {},
1212 "source": [
1213 "### Example"
427 "### Example"
1214 ]
428 ]
1215 },
429 },
1216 {
430 {
1217 "cell_type": "markdown",
431 "cell_type": "markdown",
1218 "metadata": {},
432 "metadata": {},
1219 "source": [
433 "source": [
1220 "I'll now demonstrate a specific example [requested](https://github.com/ipython/nbconvert/pull/137#issuecomment-18658235) while nbconvert 2 was being developed. The ability to exclude cell from the conversion process based on their index. \n",
434 "The following demonstration was requested in [an IPython GitHub issue](https://github.com/ipython/nbconvert/pull/137#issuecomment-18658235), the ability to exclude a cell by index. \n",
1221 "\n",
435 "\n",
1222 "I'll let you imagin how to inject cell, if what you just want is to happend static content at the beginning/end of a notebook, plese refer to templating section, it will be much easier and cleaner."
436 "Inject cells is similar, and won't be covered here. If you want to inject static content at the beginning/end of a notebook, use a custom template."
1223 ]
437 ]
1224 },
438 },
1225 {
439 {
1226 "cell_type": "code",
440 "cell_type": "code",
1227 "execution_count": 14,
441 "execution_count": null,
1228 "metadata": {
442 "metadata": {
1229 "collapsed": false
443 "collapsed": false
1230 },
444 },
1231 "outputs": [],
445 "outputs": [],
1232 "source": [
446 "source": [
1233 "from IPython.utils.traitlets import Integer"
447 "from IPython.utils.traitlets import Integer"
1234 ]
448 ]
1235 },
449 },
1236 {
450 {
1237 "cell_type": "code",
451 "cell_type": "code",
1238 "execution_count": 15,
452 "execution_count": null,
1239 "metadata": {
453 "metadata": {
1240 "collapsed": false
454 "collapsed": false
1241 },
455 },
1242 "outputs": [],
456 "outputs": [],
1243 "source": [
457 "source": [
1244 "class PelicanSubCell(Preprocessor):\n",
458 "class PelicanSubCell(Preprocessor):\n",
1245 " \"\"\"A Pelican specific preprocessor to remove somme of the cells of a notebook\"\"\"\n",
459 " \"\"\"A Pelican specific preprocessor to remove some of the cells of a notebook\"\"\"\n",
1246 " \n",
460 " \n",
1247 " # I could also read the cells from nbc.metadata.pelican is someone wrote a JS extension\n",
461 " # I could also read the cells from nbc.metadata.pelican is someone wrote a JS extension\n",
1248 " # But I'll stay with configurable value. \n",
462 " # But I'll stay with configurable value. \n",
1249 " start = Integer(0, config=True, help=\"first cell of notebook to be converted\")\n",
463 " start = Integer(0, config=True, help=\"first cell of notebook to be converted\")\n",
1250 " end = Integer(-1, config=True, help=\"last cell of notebook to be converted\")\n",
464 " end = Integer(-1, config=True, help=\"last cell of notebook to be converted\")\n",
1251 " \n",
465 " \n",
1252 " def preprocess(self, nb, resources):\n",
466 " def preprocess(self, nb, resources):\n",
1253 "\n",
467 "\n",
1254 " #nbc = deepcopy(nb)\n",
468 " #nbc = deepcopy(nb)\n",
1255 " nbc = nb\n",
469 " nbc = nb\n",
1256 " # don't print in real preprocessor !!!\n",
470 " # don't print in real preprocessor !!!\n",
1257 " print(\"I'll keep only cells from \", self.start, \"to \", self.end, \"\\n\\n\")\n",
471 " print(\"I'll keep only cells from \", self.start, \"to \", self.end, \"\\n\\n\")\n",
1258 " nbc.cells = nb.cells[self.start:self.end] \n",
472 " nbc.cells = nb.cells[self.start:self.end] \n",
1259 " return nbc, resources"
473 " return nbc, resources"
1260 ]
474 ]
1261 },
475 },
1262 {
476 {
1263 "cell_type": "code",
477 "cell_type": "code",
1264 "execution_count": 16,
478 "execution_count": null,
1265 "metadata": {
479 "metadata": {
1266 "collapsed": false
480 "collapsed": false
1267 },
481 },
1268 "outputs": [],
482 "outputs": [],
1269 "source": [
483 "source": [
1270 "# I create this on the fly, but this could be loaded from a DB, and config object support merging...\n",
484 "# I create this on the fly, but this could be loaded from a DB, and config object support merging...\n",
1271 "c = Config()\n",
485 "c = Config()\n",
1272 "c.PelicanSubCell.enabled = True\n",
486 "c.PelicanSubCell.enabled = True\n",
1273 "c.PelicanSubCell.start = 4\n",
487 "c.PelicanSubCell.start = 4\n",
1274 "c.PelicanSubCell.end = 6"
488 "c.PelicanSubCell.end = 6"
1275 ]
489 ]
1276 },
490 },
1277 {
491 {
1278 "cell_type": "markdown",
492 "cell_type": "markdown",
1279 "metadata": {},
493 "metadata": {},
1280 "source": [
494 "source": [
1281 "I'm creating a pelican exporter that take `PelicanSubCell` extra preprocessors and a `config` object as parameter. This might seem redundant, but with configuration system you'll see that one can register an inactive preprocessor on all exporters and activate it at will form its config files and command line. "
495 "Here a Pelican exporter is created that takes `PelicanSubCell` preprocessors and a `config` object as parameters. This may seem redundant, but with the configuration system you can register an inactive preprocessor on all of the exporters and activate it from config files or the command line. "
1282 ]
496 ]
1283 },
497 },
1284 {
498 {
1285 "cell_type": "code",
499 "cell_type": "code",
1286 "execution_count": 17,
500 "execution_count": null,
1287 "metadata": {
501 "metadata": {
1288 "collapsed": false
502 "collapsed": false
1289 },
503 },
1290 "outputs": [],
504 "outputs": [],
1291 "source": [
505 "source": [
1292 "pelican = RSTExporter(preprocessors=[PelicanSubCell], config=c)"
506 "pelican = RSTExporter(preprocessors=[PelicanSubCell], config=c)"
1293 ]
507 ]
1294 },
508 },
1295 {
509 {
1296 "cell_type": "code",
510 "cell_type": "code",
1297 "execution_count": 18,
511 "execution_count": null,
1298 "metadata": {
512 "metadata": {
1299 "collapsed": false
513 "collapsed": false
1300 },
514 },
1301 "outputs": [
515 "outputs": [],
1302 {
1303 "name": "stdout",
1304 "output_type": "stream",
1305 "text": [
1306 "I'll keep only cells from 4 to 6 \n",
1307 "\n",
1308 "\n",
1309 "\n",
1310 "Sometimes when showing schematic plots, this is the type of figure I\n",
1311 "want to display. But drawing it by hand is a pain: I'd rather just use\n",
1312 "matplotlib. The problem is, matplotlib is a bit too precise. Attempting\n",
1313 "to duplicate this figure in matplotlib leads to something like this:\n",
1314 "\n",
1315 ".. code:: python\n",
1316 "\n",
1317 " Image('http://jakevdp.github.com/figures/mpl_version.png')\n",
1318 "\n",
1319 "\n",
1320 "\n",
1321 ".. image:: output_5_0.png\n",
1322 "\n",
1323 "\n",
1324 "\n"
1325 ]
1326 }
1327 ],
1328 "source": [
516 "source": [
1329 "print(pelican.from_notebook_node(jake_notebook)[0])"
517 "print(pelican.from_notebook_node(jake_notebook)[0])"
1330 ]
518 ]
1331 },
519 },
1332 {
520 {
1333 "cell_type": "markdown",
521 "cell_type": "markdown",
1334 "metadata": {},
522 "metadata": {},
1335 "source": [
523 "source": [
1336 "### Programatically make templates"
524 "### Programatically make templates"
1337 ]
525 ]
1338 },
526 },
1339 {
527 {
1340 "cell_type": "code",
528 "cell_type": "code",
1341 "execution_count": 19,
529 "execution_count": null,
1342 "metadata": {
530 "metadata": {
1343 "collapsed": false
531 "collapsed": false
1344 },
532 },
1345 "outputs": [
533 "outputs": [],
1346 {
1347 "name": "stdout",
1348 "output_type": "stream",
1349 "text": [
1350 "</div>\n",
1351 "</div>\n",
1352 "FOOOOOOOOTEEEEER\n",
1353 "\n"
1354 ]
1355 }
1356 ],
1357 "source": [
534 "source": [
1358 "from jinja2 import DictLoader\n",
535 "from jinja2 import DictLoader\n",
1359 "\n",
536 "\n",
1360 "dl = DictLoader({'full.tpl': \n",
537 "dl = DictLoader({'full.tpl': \n",
1361 "\"\"\"\n",
538 "\"\"\"\n",
1362 "{%- extends 'basic.tpl' -%} \n",
539 "{%- extends 'basic.tpl' -%} \n",
1363 "\n",
540 "\n",
1364 "{% block footer %}\n",
541 "{% block footer %}\n",
1365 "FOOOOOOOOTEEEEER\n",
542 "FOOOOOOOOTEEEEER\n",
1366 "{% endblock footer %}\n",
543 "{% endblock footer %}\n",
1367 "\"\"\"})\n",
544 "\"\"\"})\n",
1368 "\n",
545 "\n",
1369 "\n",
546 "\n",
1370 "exportHTML = HTMLExporter(extra_loaders=[dl])\n",
547 "exportHTML = HTMLExporter(extra_loaders=[dl])\n",
1371 "(body,resources) = exportHTML.from_notebook_node(jake_notebook)\n",
548 "(body,resources) = exportHTML.from_notebook_node(jake_notebook)\n",
1372 "for l in body.split('\\n')[-4:]:\n",
549 "for l in body.split('\\n')[-4:]:\n",
1373 " print(l)"
550 " print(l)"
1374 ]
551 ]
1375 },
552 },
1376 {
553 {
1377 "cell_type": "markdown",
554 "cell_type": "markdown",
1378 "metadata": {},
555 "metadata": {},
1379 "source": [
556 "source": [
1380 "### Real World Use"
557 "### Real World Use"
1381 ]
558 ]
1382 },
559 },
1383 {
560 {
1384 "cell_type": "markdown",
561 "cell_type": "markdown",
1385 "metadata": {},
562 "metadata": {},
1386 "source": [
563 "source": [
1387 "@jakevdp use Pelican and IPython Notebook to blog. Pelican [Will use](https://github.com/getpelican/pelican-plugins/pull/21) nbconvert programatically to generate blog post. Have a look a [Pythonic Preambulations](http://jakevdp.github.io/) for Jake blog post."
564 "@jakevdp uses Pelican and IPython Notebook to blog. Pelican [will use](https://github.com/getpelican/pelican-plugins/pull/21) nbconvert programatically to generate blog post. Have a look a [Pythonic Preambulations](http://jakevdp.github.io/) for Jake's blog post."
1388 ]
565 ]
1389 },
566 },
1390 {
567 {
1391 "cell_type": "markdown",
568 "cell_type": "markdown",
1392 "metadata": {},
569 "metadata": {},
1393 "source": [
570 "source": [
1394 "@damianavila Wrote a Nicholas Plugin to [Write blog post as Notebook](http://www.damian.oquanta.info/posts/one-line-deployment-of-your-site-to-gh-pages.html) and is developping a js-extension to publish notebooks in one click from the web app."
571 "@damianavila wrote the Nicholas Plugin to [write blog post as Notebooks](http://www.damian.oquanta.info/posts/one-line-deployment-of-your-site-to-gh-pages.html) and is developping a js-extension to publish notebooks via one click from the web app."
1395 ]
572 ]
1396 },
573 },
1397 {
574 {
1398 "cell_type": "markdown",
575 "cell_type": "markdown",
1399 "metadata": {},
576 "metadata": {},
1400 "source": [
577 "source": [
1401 "<center>\n",
578 "<center>\n",
1402 "<blockquote class=\"twitter-tweet\"><p>As <a href=\"https://twitter.com/Mbussonn\">@Mbussonn</a> requested... easieeeeer! Deploy your Nikola site with just a click in the IPython notebook! <a href=\"http://t.co/860sJunZvj\">http://t.co/860sJunZvj</a> cc <a href=\"https://twitter.com/ralsina\">@ralsina</a></p>&mdash; Damián Avila (@damian_avila) <a href=\"https://twitter.com/damian_avila/statuses/370306057828335616\">August 21, 2013</a></blockquote>\n",
579 "<blockquote class=\"twitter-tweet\"><p>As <a href=\"https://twitter.com/Mbussonn\">@Mbussonn</a> requested... easieeeeer! Deploy your Nikola site with just a click in the IPython notebook! <a href=\"http://t.co/860sJunZvj\">http://t.co/860sJunZvj</a> cc <a href=\"https://twitter.com/ralsina\">@ralsina</a></p>&mdash; Damián Avila (@damian_avila) <a href=\"https://twitter.com/damian_avila/statuses/370306057828335616\">August 21, 2013</a></blockquote>\n",
1403 "</center>"
580 "</center>"
1404 ]
581 ]
1405 },
582 },
1406 {
583 {
1407 "cell_type": "markdown",
584 "cell_type": "markdown",
1408 "metadata": {},
585 "metadata": {},
1409 "source": [
586 "source": [
1410 "And finaly, what you just did, is replicate what [nbviewer](http://nbviewer.ipython.org) does. WHich to fetch a notebook from url, convert it and send in back to you as a static html."
1411 ]
1412 },
1413 {
1414 "cell_type": "markdown",
1415 "metadata": {},
1416 "source": [
1417 "##### A few gotchas"
587 "##### A few gotchas"
1418 ]
588 ]
1419 },
589 },
1420 {
590 {
1421 "cell_type": "markdown",
591 "cell_type": "markdown",
1422 "metadata": {},
592 "metadata": {},
1423 "source": [
593 "source": [
1424 "Jinja blocks use `{% %}`by default which does not play nicely with $\\LaTeX$, hence thoses are replaced by `((* *))` in latex templates."
594 "Jinja blocks use `{% %}`by default which does not play nicely with $\\LaTeX$, hence thoses are replaced by `((* *))` in latex templates."
1425 ]
595 ]
1426 }
596 }
1427 ],
597 ],
1428 "metadata": {
598 "metadata": {
1429 "kernelspec": {
599 "kernelspec": {
1430 "display_name": "Python 3",
600 "display_name": "Python 3",
1431 "language": "python",
601 "language": "python",
1432 "name": "python3"
602 "name": "python3"
1433 },
603 },
1434 "language_info": {
604 "language_info": {
1435 "codemirror_mode": {
605 "codemirror_mode": {
1436 "name": "ipython",
606 "name": "ipython",
1437 "version": 3
607 "version": 3
1438 },
608 },
1439 "file_extension": ".py",
609 "file_extension": ".py",
1440 "mimetype": "text/x-python",
610 "mimetype": "text/x-python",
1441 "name": "python",
611 "name": "python",
1442 "nbconvert_exporter": "python",
612 "nbconvert_exporter": "python",
1443 "pygments_lexer": "ipython3",
613 "pygments_lexer": "ipython3",
1444 "version": "3.4.2"
614 "version": "3.4.3"
1445 }
615 }
1446 },
616 },
1447 "nbformat": 4,
617 "nbformat": 4,
1448 "nbformat_minor": 0
618 "nbformat_minor": 0
1449 }
619 }
@@ -1,184 +1,183 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {
5 "metadata": {
6 "slideshow": {
6 "slideshow": {
7 "slide_type": "slide"
7 "slide_type": "slide"
8 }
8 }
9 },
9 },
10 "source": [
10 "source": [
11 "# What is the IPython Notebook?"
11 "# What is the IPython Notebook?"
12 ]
12 ]
13 },
13 },
14 {
14 {
15 "cell_type": "markdown",
15 "cell_type": "markdown",
16 "metadata": {},
16 "metadata": {},
17 "source": [
17 "source": [
18 "## Introduction"
18 "## Introduction"
19 ]
19 ]
20 },
20 },
21 {
21 {
22 "cell_type": "markdown",
22 "cell_type": "markdown",
23 "metadata": {},
23 "metadata": {},
24 "source": [
24 "source": [
25 "The IPython Notebook is an **interactive computing environment** that enables users to author notebook documents that include: \n",
25 "The IPython Notebook is an **interactive computing environment** that enables users to author notebook documents that include: \n",
26 "- Live code\n",
26 "- Live code\n",
27 "- Interactive widgets\n",
27 "- Interactive widgets\n",
28 "- Plots\n",
28 "- Plots\n",
29 "- Narrative text\n",
29 "- Narrative text\n",
30 "- Equations\n",
30 "- Equations\n",
31 "- Images\n",
31 "- Images\n",
32 "- Video\n",
32 "- Video\n",
33 "\n",
33 "\n",
34 "These documents provide a **complete and self-contained record of a computation** that can be converted to various formats and shared with others using email, [Dropbox](http://dropbox.com), version control systems (like git/[GitHub](http://github.com)) or [nbviewer.ipython.org](http://nbviewer.ipython.org)."
34 "These documents provide a **complete and self-contained record of a computation** that can be converted to various formats and shared with others using email, [Dropbox](http://dropbox.com), version control systems (like git/[GitHub](http://github.com)) or [nbviewer.ipython.org](http://nbviewer.ipython.org)."
35 ]
35 ]
36 },
36 },
37 {
37 {
38 "cell_type": "markdown",
38 "cell_type": "markdown",
39 "metadata": {
39 "metadata": {
40 "slideshow": {
40 "slideshow": {
41 "slide_type": "slide"
41 "slide_type": "slide"
42 }
42 }
43 },
43 },
44 "source": [
44 "source": [
45 "### Components"
45 "### Components"
46 ]
46 ]
47 },
47 },
48 {
48 {
49 "cell_type": "markdown",
49 "cell_type": "markdown",
50 "metadata": {},
50 "metadata": {},
51 "source": [
51 "source": [
52 "The IPython Notebook combines three components:\n",
52 "The IPython Notebook combines three components:\n",
53 "\n",
53 "\n",
54 "* **The notebook web application**: An interactive web application for writing and running code interactively and authoring notebook documents.\n",
54 "* **The notebook web application**: An interactive web application for writing and running code interactively and authoring notebook documents.\n",
55 "* **Kernels**: Separate processes started by the notebook web application that runs users' code in a given language and returns output back to the notebook web application. The kernel also handles things like computations for interactive widgets, tab completion and introspection. \n",
55 "* **Kernels**: Separate processes started by the notebook web application that runs users' code in a given language and returns output back to the notebook web application. The kernel also handles things like computations for interactive widgets, tab completion and introspection. \n",
56 "* **Notebook documents**: Self-contained documents that contain a representation of all content visible in the notebook web application, including inputs and outputs of the computations, narrative\n",
56 "* **Notebook documents**: Self-contained documents that contain a representation of all content visible in the notebook web application, including inputs and outputs of the computations, narrative\n",
57 "text, equations, images, and rich media representations of objects. Each notebook document has its own kernel."
57 "text, equations, images, and rich media representations of objects. Each notebook document has its own kernel."
58 ]
58 ]
59 },
59 },
60 {
60 {
61 "cell_type": "markdown",
61 "cell_type": "markdown",
62 "metadata": {
62 "metadata": {
63 "slideshow": {
63 "slideshow": {
64 "slide_type": "slide"
64 "slide_type": "slide"
65 }
65 }
66 },
66 },
67 "source": [
67 "source": [
68 "## Notebook web application"
68 "## Notebook web application"
69 ]
69 ]
70 },
70 },
71 {
71 {
72 "cell_type": "markdown",
72 "cell_type": "markdown",
73 "metadata": {},
73 "metadata": {},
74 "source": [
74 "source": [
75 "The notebook web application enables users to:\n",
75 "The notebook web application enables users to:\n",
76 "\n",
76 "\n",
77 "* **Edit code in the browser**, with automatic syntax highlighting, indentation, and tab completion/introspection.\n",
77 "* **Edit code in the browser**, with automatic syntax highlighting, indentation, and tab completion/introspection.\n",
78 "* **Run code from the browser**, with the results of computations attached to the code which generated them.\n",
78 "* **Run code from the browser**, with the results of computations attached to the code which generated them.\n",
79 "* See the results of computations with **rich media representations**, such as HTML, LaTeX, PNG, SVG, PDF, etc.\n",
79 "* See the results of computations with **rich media representations**, such as HTML, LaTeX, PNG, SVG, PDF, etc.\n",
80 "* Create and use **interactive JavaScript wigets**, which bind interactive user interface controls and visualizations to reactive kernel side computations.\n",
80 "* Create and use **interactive JavaScript wigets**, which bind interactive user interface controls and visualizations to reactive kernel side computations.\n",
81 "* Author **narrative text** using the [Markdown](https://daringfireball.net/projects/markdown/) markup language.\n",
81 "* Author **narrative text** using the [Markdown](https://daringfireball.net/projects/markdown/) markup language.\n",
82 "* Build **hierarchical documents** that are organized into sections with different levels of headings.\n",
82 "* Build **hierarchical documents** that are organized into sections with different levels of headings.\n",
83 "* Include mathematical equations using **LaTeX syntax in Markdown**, which are rendered in-browser by [MathJax](http://www.mathjax.org/).\n",
83 "* Include mathematical equations using **LaTeX syntax in Markdown**, which are rendered in-browser by [MathJax](http://www.mathjax.org/).\n",
84 "* Start **parallel computing** clusters that work with IPython's interactive parallel computing libraries `IPython.parallel`."
84 "* Start **parallel computing** clusters that work with IPython's interactive parallel computing libraries `IPython.parallel`."
85 ]
85 ]
86 },
86 },
87 {
87 {
88 "cell_type": "markdown",
88 "cell_type": "markdown",
89 "metadata": {
89 "metadata": {
90 "slideshow": {
90 "slideshow": {
91 "slide_type": "slide"
91 "slide_type": "slide"
92 }
92 }
93 },
93 },
94 "source": [
94 "source": [
95 "## Kernels"
95 "## Kernels"
96 ]
96 ]
97 },
97 },
98 {
98 {
99 "cell_type": "markdown",
99 "cell_type": "markdown",
100 "metadata": {},
100 "metadata": {},
101 "source": [
101 "source": [
102 "Through IPython's kernel and messaging architecture, the Notebook allows code to be run in a range of different programming languages. For each notebook document that a user opens, the web application starts a kernel that runs the code for that notebook. Each kernel is capable of running code in a single programming language and there are kernels available in the following languages:\n",
102 "Through IPython's kernel and messaging architecture, the Notebook allows code to be run in a range of different programming languages. For each notebook document that a user opens, the web application starts a kernel that runs the code for that notebook. Each kernel is capable of running code in a single programming language and there are kernels available in the following languages:\n",
103 "\n",
103 "\n",
104 "* Python(https://github.com/ipython/ipython)\n",
104 "* Python(https://github.com/ipython/ipython)\n",
105 "* Julia (https://github.com/JuliaLang/IJulia.jl)\n",
105 "* Julia (https://github.com/JuliaLang/IJulia.jl)\n",
106 "* R (https://github.com/takluyver/IRkernel)\n",
106 "* R (https://github.com/takluyver/IRkernel)\n",
107 "* Ruby (https://github.com/minrk/iruby)\n",
107 "* Ruby (https://github.com/minrk/iruby)\n",
108 "* Haskell (https://github.com/gibiansky/IHaskell)\n",
108 "* Haskell (https://github.com/gibiansky/IHaskell)\n",
109 "* Scala (https://github.com/Bridgewater/scala-notebook)\n",
109 "* Scala (https://github.com/Bridgewater/scala-notebook)\n",
110 "* node.js (https://gist.github.com/Carreau/4279371)\n",
110 "* node.js (https://gist.github.com/Carreau/4279371)\n",
111 "* Go (https://github.com/takluyver/igo)\n",
111 "* Go (https://github.com/takluyver/igo)\n",
112 "\n",
112 "\n",
113 "The default kernel runs Python code. When it is released in the Summer/Fall of 2014, IPython 3.0 will provide a simple way for users to pick which of these kernels is used for a given notebook. \n",
113 "The default kernel runs Python code. IPython 3.0 provides a simple way for users to pick which of these kernels is used for a given notebook. \n",
114 "\n",
114 "\n",
115 "Each of these kernels communicate with the notebook web application and web browser using a JSON over ZeroMQ/WebSockets message protocol that is described [here](http://ipython.org/ipython-doc/dev/development/messaging.html). Most users don't need to know about these details, but it helps to understand that \"kernels run code.\""
115 "Each of these kernels communicate with the notebook web application and web browser using a JSON over ZeroMQ/WebSockets message protocol that is described [here](http://ipython.org/ipython-doc/dev/development/messaging.html). Most users don't need to know about these details, but it helps to understand that \"kernels run code.\""
116 ]
116 ]
117 },
117 },
118 {
118 {
119 "cell_type": "markdown",
119 "cell_type": "markdown",
120 "metadata": {
120 "metadata": {
121 "slideshow": {
121 "slideshow": {
122 "slide_type": "slide"
122 "slide_type": "slide"
123 }
123 }
124 },
124 },
125 "source": [
125 "source": [
126 "## Notebook documents"
126 "## Notebook documents"
127 ]
127 ]
128 },
128 },
129 {
129 {
130 "cell_type": "markdown",
130 "cell_type": "markdown",
131 "metadata": {},
131 "metadata": {},
132 "source": [
132 "source": [
133 "Notebook documents contain the **inputs and outputs** of an interactive session as well as **narrative text** that accompanies the code but is not meant for execution. **Rich output** generated by running code, including HTML, images, video, and plots, is embeddeed in the notebook, which makes it a complete and self-contained record of a computation. "
133 "Notebook documents contain the **inputs and outputs** of an interactive session as well as **narrative text** that accompanies the code but is not meant for execution. **Rich output** generated by running code, including HTML, images, video, and plots, is embeddeed in the notebook, which makes it a complete and self-contained record of a computation. "
134 ]
134 ]
135 },
135 },
136 {
136 {
137 "cell_type": "markdown",
137 "cell_type": "markdown",
138 "metadata": {},
138 "metadata": {},
139 "source": [
139 "source": [
140 "When you run the notebook web application on your computer, notebook documents are just **files on your local filesystem with a `.ipynb` extension**. This allows you to use familiar workflows for organizing your notebooks into folders and sharing them with others using email, Dropbox and version control systems."
140 "When you run the notebook web application on your computer, notebook documents are just **files on your local filesystem with a `.ipynb` extension**. This allows you to use familiar workflows for organizing your notebooks into folders and sharing them with others."
141 ]
141 ]
142 },
142 },
143 {
143 {
144 "cell_type": "markdown",
144 "cell_type": "markdown",
145 "metadata": {},
145 "metadata": {},
146 "source": [
146 "source": [
147 "Notebooks consist of a **linear sequence of cells**. There are four basic cell types:\n",
147 "Notebooks consist of a **linear sequence of cells**. There are four basic cell types:\n",
148 "\n",
148 "\n",
149 "* **Code cells:** Input and output of live code that is run in the kernel\n",
149 "* **Code cells:** Input and output of live code that is run in the kernel\n",
150 "* **Markdown cells:** Narrative text with embedded LaTeX equations\n",
150 "* **Markdown cells:** Narrative text with embedded LaTeX equations\n",
151 "* **Heading cells:** 6 levels of hierarchical organization and formatting\n",
151 "* **Heading cells:** 6 levels of hierarchical organization and formatting\n",
152 "* **Raw cells:** Unformatted text that is included, without modification, when notebooks are converted to different formats using nbconvert\n",
152 "* **Raw cells:** Unformatted text that is included, without modification, when notebooks are converted to different formats using nbconvert\n",
153 "\n",
153 "\n",
154 "Internally, notebook documents are **[JSON](http://en.wikipedia.org/wiki/JSON) data** with **binary values [base64](http://en.wikipedia.org/wiki/Base64)** encoded. This allows them to be **read and manipulated programmatically** by any programming language. Because JSON is a text format, notebook documents are version control friendly.\n",
154 "Internally, notebook documents are **[JSON](http://en.wikipedia.org/wiki/JSON) data** with **binary values [base64](http://en.wikipedia.org/wiki/Base64)** encoded. This allows them to be **read and manipulated programmatically** by any programming language. Because JSON is a text format, notebook documents are version control friendly.\n",
155 "\n",
155 "\n",
156 "**Notebooks can be exported** to different static formats including HTML, reStructeredText, LaTeX, PDF, and slide shows ([reveal.js](http://lab.hakim.se/reveal-js/#/)) using IPython's `nbconvert` utility.\n",
156 "**Notebooks can be exported** to different static formats including HTML, reStructeredText, LaTeX, PDF, and slide shows ([reveal.js](http://lab.hakim.se/reveal-js/#/)) using IPython's `nbconvert` utility.\n",
157 "\n",
157 "\n",
158 "Furthermore, any notebook document available from a **public URL on or GitHub can be shared** via [nbviewer](http://nbviewer.ipython.org). This service loads the notebook document from the URL and renders it as a static web page. The resulting web page may thus be shared with others **without their needing to install IPython**."
158 "Furthermore, any notebook document available from a **public URL on or GitHub can be shared** via [nbviewer](http://nbviewer.ipython.org). This service loads the notebook document from the URL and renders it as a static web page. The resulting web page may thus be shared with others **without their needing to install IPython**."
159 ]
159 ]
160 }
160 }
161 ],
161 ],
162 "metadata": {
162 "metadata": {
163 "celltoolbar": "Slideshow",
164 "kernelspec": {
163 "kernelspec": {
165 "display_name": "Python 3",
164 "display_name": "Python 3",
166 "language": "python",
165 "language": "python",
167 "name": "python3"
166 "name": "python3"
168 },
167 },
169 "language_info": {
168 "language_info": {
170 "codemirror_mode": {
169 "codemirror_mode": {
171 "name": "ipython",
170 "name": "ipython",
172 "version": 3
171 "version": 3
173 },
172 },
174 "file_extension": ".py",
173 "file_extension": ".py",
175 "mimetype": "text/x-python",
174 "mimetype": "text/x-python",
176 "name": "python",
175 "name": "python",
177 "nbconvert_exporter": "python",
176 "nbconvert_exporter": "python",
178 "pygments_lexer": "ipython3",
177 "pygments_lexer": "ipython3",
179 "version": "3.4.2"
178 "version": "3.4.3"
180 }
179 }
181 },
180 },
182 "nbformat": 4,
181 "nbformat": 4,
183 "nbformat_minor": 0
182 "nbformat_minor": 0
184 }
183 }
@@ -1,320 +1,320 b''
1 {
1 {
2 "cells": [
2 "cells": [
3 {
3 {
4 "cell_type": "markdown",
4 "cell_type": "markdown",
5 "metadata": {},
5 "metadata": {},
6 "source": [
6 "source": [
7 "# Markdown Cells"
7 "# Markdown Cells"
8 ]
8 ]
9 },
9 },
10 {
10 {
11 "cell_type": "markdown",
11 "cell_type": "markdown",
12 "metadata": {},
12 "metadata": {},
13 "source": [
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",
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",
15 "\n",
16 "<http://daringfireball.net/projects/markdown/>"
16 "<http://daringfireball.net/projects/markdown/>"
17 ]
17 ]
18 },
18 },
19 {
19 {
20 "cell_type": "markdown",
20 "cell_type": "markdown",
21 "metadata": {},
21 "metadata": {},
22 "source": [
22 "source": [
23 "## Markdown basics"
23 "## Markdown basics"
24 ]
24 ]
25 },
25 },
26 {
26 {
27 "cell_type": "markdown",
27 "cell_type": "markdown",
28 "metadata": {},
28 "metadata": {},
29 "source": [
29 "source": [
30 "You can make text *italic* or **bold**."
30 "You can make text *italic* or **bold**."
31 ]
31 ]
32 },
32 },
33 {
33 {
34 "cell_type": "markdown",
34 "cell_type": "markdown",
35 "metadata": {},
35 "metadata": {},
36 "source": [
36 "source": [
37 "You can build nested itemized or enumerated lists:\n",
37 "You can build nested itemized or enumerated lists:\n",
38 "\n",
38 "\n",
39 "* One\n",
39 "* One\n",
40 " - Sublist\n",
40 " - Sublist\n",
41 " - This\n",
41 " - This\n",
42 " - Sublist\n",
42 " - Sublist\n",
43 " - That\n",
43 " - That\n",
44 " - The other thing\n",
44 " - The other thing\n",
45 "* Two\n",
45 "* Two\n",
46 " - Sublist\n",
46 " - Sublist\n",
47 "* Three\n",
47 "* Three\n",
48 " - Sublist\n",
48 " - Sublist\n",
49 "\n",
49 "\n",
50 "Now another list:\n",
50 "Now another list:\n",
51 "\n",
51 "\n",
52 "1. Here we go\n",
52 "1. Here we go\n",
53 " 1. Sublist\n",
53 " 1. Sublist\n",
54 " 2. Sublist\n",
54 " 2. Sublist\n",
55 "2. There we go\n",
55 "2. There we go\n",
56 "3. Now this"
56 "3. Now this"
57 ]
57 ]
58 },
58 },
59 {
59 {
60 "cell_type": "markdown",
60 "cell_type": "markdown",
61 "metadata": {},
61 "metadata": {},
62 "source": [
62 "source": [
63 "You can add horizontal rules:\n",
63 "You can add horizontal rules:\n",
64 "\n",
64 "\n",
65 "---"
65 "---"
66 ]
66 ]
67 },
67 },
68 {
68 {
69 "cell_type": "markdown",
69 "cell_type": "markdown",
70 "metadata": {},
70 "metadata": {},
71 "source": [
71 "source": [
72 "Here is a blockquote:\n",
72 "Here is a blockquote:\n",
73 "\n",
73 "\n",
74 "> Beautiful is better than ugly.\n",
74 "> Beautiful is better than ugly.\n",
75 "> Explicit is better than implicit.\n",
75 "> Explicit is better than implicit.\n",
76 "> Simple is better than complex.\n",
76 "> Simple is better than complex.\n",
77 "> Complex is better than complicated.\n",
77 "> Complex is better than complicated.\n",
78 "> Flat is better than nested.\n",
78 "> Flat is better than nested.\n",
79 "> Sparse is better than dense.\n",
79 "> Sparse is better than dense.\n",
80 "> Readability counts.\n",
80 "> Readability counts.\n",
81 "> Special cases aren't special enough to break the rules.\n",
81 "> Special cases aren't special enough to break the rules.\n",
82 "> Although practicality beats purity.\n",
82 "> Although practicality beats purity.\n",
83 "> Errors should never pass silently.\n",
83 "> Errors should never pass silently.\n",
84 "> Unless explicitly silenced.\n",
84 "> Unless explicitly silenced.\n",
85 "> In the face of ambiguity, refuse the temptation to guess.\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",
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",
87 "> Although that way may not be obvious at first unless you're Dutch.\n",
88 "> Now is better than never.\n",
88 "> Now is better than never.\n",
89 "> Although never is often better than *right* now.\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",
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",
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!"
92 "> Namespaces are one honking great idea -- let's do more of those!"
93 ]
93 ]
94 },
94 },
95 {
95 {
96 "cell_type": "markdown",
96 "cell_type": "markdown",
97 "metadata": {},
97 "metadata": {},
98 "source": [
98 "source": [
99 "And shorthand for links:\n",
99 "And shorthand for links:\n",
100 "\n",
100 "\n",
101 "[IPython's website](http://ipython.org)"
101 "[IPython's website](http://ipython.org)"
102 ]
102 ]
103 },
103 },
104 {
104 {
105 "cell_type": "markdown",
105 "cell_type": "markdown",
106 "metadata": {},
106 "metadata": {},
107 "source": [
107 "source": [
108 "## Headings"
108 "## Headings"
109 ]
109 ]
110 },
110 },
111 {
111 {
112 "cell_type": "markdown",
112 "cell_type": "markdown",
113 "metadata": {},
113 "metadata": {},
114 "source": [
114 "source": [
115 "If you want, you can add headings using Markdown's syntax:\n",
115 "If you want, you can add headings using Markdown's syntax:\n",
116 "\n",
116 "\n",
117 "# Heading 1\n",
117 "# Heading 1\n",
118 "# Heading 2\n",
118 "# Heading 2\n",
119 "## Heading 2.1\n",
119 "## Heading 2.1\n",
120 "## Heading 2.2"
120 "## Heading 2.2"
121 ]
121 ]
122 },
122 },
123 {
123 {
124 "cell_type": "markdown",
124 "cell_type": "markdown",
125 "metadata": {},
125 "metadata": {},
126 "source": [
126 "source": [
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."
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 "cell_type": "markdown",
131 "cell_type": "markdown",
132 "metadata": {},
132 "metadata": {},
133 "source": [
133 "source": [
134 "## Embedded code"
134 "## Embedded code"
135 ]
135 ]
136 },
136 },
137 {
137 {
138 "cell_type": "markdown",
138 "cell_type": "markdown",
139 "metadata": {},
139 "metadata": {},
140 "source": [
140 "source": [
141 "You can embed code meant for illustration instead of execution in Python:\n",
141 "You can embed code meant for illustration instead of execution in Python:\n",
142 "\n",
142 "\n",
143 " def f(x):\n",
143 " def f(x):\n",
144 " \"\"\"a docstring\"\"\"\n",
144 " \"\"\"a docstring\"\"\"\n",
145 " return x**2\n",
145 " return x**2\n",
146 "\n",
146 "\n",
147 "or other languages:\n",
147 "or other languages:\n",
148 "\n",
148 "\n",
149 " if (i=0; i<n; i++) {\n",
149 " if (i=0; i<n; i++) {\n",
150 " printf(\"hello %d\\n\", i);\n",
150 " printf(\"hello %d\\n\", i);\n",
151 " x += 4;\n",
151 " x += 4;\n",
152 " }"
152 " }"
153 ]
153 ]
154 },
154 },
155 {
155 {
156 "cell_type": "markdown",
156 "cell_type": "markdown",
157 "metadata": {},
157 "metadata": {},
158 "source": [
158 "source": [
159 "## LaTeX equations"
159 "## LaTeX equations"
160 ]
160 ]
161 },
161 },
162 {
162 {
163 "cell_type": "markdown",
163 "cell_type": "markdown",
164 "metadata": {},
164 "metadata": {},
165 "source": [
165 "source": [
166 "Courtesy of MathJax, you can include mathematical expressions both inline: \n",
166 "Courtesy of MathJax, you can include mathematical expressions both inline: \n",
167 "$e^{i\\pi} + 1 = 0$ and displayed:\n",
167 "$e^{i\\pi} + 1 = 0$ and displayed:\n",
168 "\n",
168 "\n",
169 "$$e^x=\\sum_{i=0}^\\infty \\frac{1}{i!}x^i$$"
169 "$$e^x=\\sum_{i=0}^\\infty \\frac{1}{i!}x^i$$"
170 ]
170 ]
171 },
171 },
172 {
172 {
173 "cell_type": "markdown",
173 "cell_type": "markdown",
174 "metadata": {},
174 "metadata": {},
175 "source": [
175 "source": [
176 "## Github flavored markdown (GFM)"
176 "## Github flavored markdown (GFM)"
177 ]
177 ]
178 },
178 },
179 {
179 {
180 "cell_type": "markdown",
180 "cell_type": "markdown",
181 "metadata": {},
181 "metadata": {},
182 "source": [
182 "source": [
183 "The Notebook webapp support Github flavored markdown meaning that you can use triple backticks for code blocks \n",
183 "The Notebook webapp support Github flavored markdown meaning that you can use triple backticks for code blocks \n",
184 "<pre>\n",
184 "<pre>\n",
185 "```python\n",
185 "```python\n",
186 "print \"Hello World\"\n",
186 "print \"Hello World\"\n",
187 "```\n",
187 "```\n",
188 "\n",
188 "\n",
189 "```javascript\n",
189 "```javascript\n",
190 "console.log(\"Hello World\")\n",
190 "console.log(\"Hello World\")\n",
191 "```\n",
191 "```\n",
192 "</pre>\n",
192 "</pre>\n",
193 "\n",
193 "\n",
194 "Gives \n",
194 "Gives \n",
195 "```python\n",
195 "```python\n",
196 "print \"Hello World\"\n",
196 "print \"Hello World\"\n",
197 "```\n",
197 "```\n",
198 "\n",
198 "\n",
199 "```javascript\n",
199 "```javascript\n",
200 "console.log(\"Hello World\")\n",
200 "console.log(\"Hello World\")\n",
201 "```\n",
201 "```\n",
202 "\n",
202 "\n",
203 "And a table like this : \n",
203 "And a table like this : \n",
204 "\n",
204 "\n",
205 "<pre>\n",
205 "<pre>\n",
206 "| This | is |\n",
206 "| This | is |\n",
207 "|------|------|\n",
207 "|------|------|\n",
208 "| a | table| \n",
208 "| a | table| \n",
209 "</pre>\n",
209 "</pre>\n",
210 "\n",
210 "\n",
211 "A nice Html Table\n",
211 "A nice Html Table\n",
212 "\n",
212 "\n",
213 "| This | is |\n",
213 "| This | is |\n",
214 "|------|------|\n",
214 "|------|------|\n",
215 "| a | table| "
215 "| a | table| "
216 ]
216 ]
217 },
217 },
218 {
218 {
219 "cell_type": "markdown",
219 "cell_type": "markdown",
220 "metadata": {},
220 "metadata": {},
221 "source": [
221 "source": [
222 "## General HTML"
222 "## General HTML"
223 ]
223 ]
224 },
224 },
225 {
225 {
226 "cell_type": "markdown",
226 "cell_type": "markdown",
227 "metadata": {},
227 "metadata": {},
228 "source": [
228 "source": [
229 "Because Markdown is a superset of HTML you can even add things like HTML tables:\n",
229 "Because Markdown is a superset of HTML you can even add things like HTML tables:\n",
230 "\n",
230 "\n",
231 "<table>\n",
231 "<table>\n",
232 "<tr>\n",
232 "<tr>\n",
233 "<th>Header 1</th>\n",
233 "<th>Header 1</th>\n",
234 "<th>Header 2</th>\n",
234 "<th>Header 2</th>\n",
235 "</tr>\n",
235 "</tr>\n",
236 "<tr>\n",
236 "<tr>\n",
237 "<td>row 1, cell 1</td>\n",
237 "<td>row 1, cell 1</td>\n",
238 "<td>row 1, cell 2</td>\n",
238 "<td>row 1, cell 2</td>\n",
239 "</tr>\n",
239 "</tr>\n",
240 "<tr>\n",
240 "<tr>\n",
241 "<td>row 2, cell 1</td>\n",
241 "<td>row 2, cell 1</td>\n",
242 "<td>row 2, cell 2</td>\n",
242 "<td>row 2, cell 2</td>\n",
243 "</tr>\n",
243 "</tr>\n",
244 "</table>"
244 "</table>"
245 ]
245 ]
246 },
246 },
247 {
247 {
248 "cell_type": "markdown",
248 "cell_type": "markdown",
249 "metadata": {},
249 "metadata": {},
250 "source": [
250 "source": [
251 "## Local files"
251 "## Local files"
252 ]
252 ]
253 },
253 },
254 {
254 {
255 "cell_type": "markdown",
255 "cell_type": "markdown",
256 "metadata": {},
256 "metadata": {},
257 "source": [
257 "source": [
258 "If you have local files in your Notebook directory, you can refer to these files in Markdown cells directly:\n",
258 "If you have local files in your Notebook directory, you can refer to these files in Markdown cells directly:\n",
259 "\n",
259 "\n",
260 " [subdirectory/]<filename>\n",
260 " [subdirectory/]<filename>\n",
261 "\n",
261 "\n",
262 "For example, in the images folder, we have the Python logo:\n",
262 "For example, in the images folder, we have the Python logo:\n",
263 "\n",
263 "\n",
264 " <img src=\"../images/python_logo.svg\" />\n",
264 " <img src=\"../images/python_logo.svg\" />\n",
265 "\n",
265 "\n",
266 "<img src=\"../images/python_logo.svg\" />\n",
266 "<img src=\"../images/python_logo.svg\" />\n",
267 "\n",
267 "\n",
268 "and a video with the HTML5 video tag:\n",
268 "and a video with the HTML5 video tag:\n",
269 "\n",
269 "\n",
270 " <video controls src=\"images/animation.m4v\" />\n",
270 " <video controls src=\"images/animation.m4v\" />\n",
271 "\n",
271 "\n",
272 "<video controls src=\"images/animation.m4v\" />\n",
272 "<video controls src=\"images/animation.m4v\" />\n",
273 "\n",
273 "\n",
274 "These do not embed the data into the notebook file, and require that the files exist when you are viewing the notebook."
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 "cell_type": "markdown",
278 "cell_type": "markdown",
279 "metadata": {},
279 "metadata": {},
280 "source": [
280 "source": [
281 "### Security of local files"
281 "### Security of local files"
282 ]
282 ]
283 },
283 },
284 {
284 {
285 "cell_type": "markdown",
285 "cell_type": "markdown",
286 "metadata": {},
286 "metadata": {},
287 "source": [
287 "source": [
288 "Note that this means that the IPython notebook server also acts as a generic file server\n",
288 "Note that this means that the IPython notebook server also acts as a generic file server\n",
289 "for files inside the same tree as your notebooks. Access is not granted outside the\n",
289 "for files inside the same tree as your notebooks. Access is not granted outside the\n",
290 "notebook folder so you have strict control over what files are visible, but for this\n",
290 "notebook folder so you have strict control over what files are visible, but for this\n",
291 "reason it is highly recommended that you do not run the notebook server with a notebook\n",
291 "reason it is highly recommended that you do not run the notebook server with a notebook\n",
292 "directory at a high level in your filesystem (e.g. your home directory).\n",
292 "directory at a high level in your filesystem (e.g. your home directory).\n",
293 "\n",
293 "\n",
294 "When you run the notebook in a password-protected manner, local file access is restricted\n",
294 "When you run the notebook in a password-protected manner, local file access is restricted\n",
295 "to authenticated users unless read-only views are active."
295 "to authenticated users unless read-only views are active."
296 ]
296 ]
297 }
297 }
298 ],
298 ],
299 "metadata": {
299 "metadata": {
300 "kernelspec": {
300 "kernelspec": {
301 "display_name": "Python 3",
301 "display_name": "Python 3",
302 "language": "python",
302 "language": "python",
303 "name": "python3"
303 "name": "python3"
304 },
304 },
305 "language_info": {
305 "language_info": {
306 "codemirror_mode": {
306 "codemirror_mode": {
307 "name": "ipython",
307 "name": "ipython",
308 "version": 3
308 "version": 3
309 },
309 },
310 "file_extension": ".py",
310 "file_extension": ".py",
311 "mimetype": "text/x-python",
311 "mimetype": "text/x-python",
312 "name": "python",
312 "name": "python",
313 "nbconvert_exporter": "python",
313 "nbconvert_exporter": "python",
314 "pygments_lexer": "ipython3",
314 "pygments_lexer": "ipython3",
315 "version": "3.4.2"
315 "version": "3.4.3"
316 }
316 }
317 },
317 },
318 "nbformat": 4,
318 "nbformat": 4,
319 "nbformat_minor": 0
319 "nbformat_minor": 0
320 }
320 }
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now