|
46 | 46 | "source": [
|
47 | 47 | "from urllib.request import urlopen\n",
|
48 | 48 | "\n",
|
49 |
| - "url = 'https://jakevdp.github.io/downloads/notebooks/XKCD_plots.ipynb'\n", |
| 49 | + "url = \"https://jakevdp.github.io/downloads/notebooks/XKCD_plots.ipynb\"\n", |
50 | 50 | "response = urlopen(url).read().decode()\n",
|
51 |
| - "response[0:60] + ' ...'" |
| 51 | + "response[0:60] + \" ...\"" |
52 | 52 | ]
|
53 | 53 | },
|
54 | 54 | {
|
|
102 | 102 | "\n",
|
103 | 103 | "# 2. Instantiate the exporter. We use the `classic` template for now; we'll get into more details\n",
|
104 | 104 | "# later about how to customize the exporter further.\n",
|
105 |
| - "html_exporter = HTMLExporter(template_name='classic')\n", |
| 105 | + "html_exporter = HTMLExporter(template_name=\"classic\")\n", |
106 | 106 | "\n",
|
107 | 107 | "# 3. Process the notebook we loaded earlier\n",
|
108 | 108 | "(body, resources) = html_exporter.from_notebook_node(jake_notebook)"
|
|
125 | 125 | },
|
126 | 126 | "outputs": [],
|
127 | 127 | "source": [
|
128 |
| - "print(body[:400] + '...')" |
| 128 | + "print(body[:400] + \"...\")" |
129 | 129 | ]
|
130 | 130 | },
|
131 | 131 | {
|
|
148 | 148 | "outputs": [],
|
149 | 149 | "source": [
|
150 | 150 | "print(\"Resources:\", resources.keys())\n",
|
151 |
| - "print(\"Metadata:\", resources['metadata'].keys())\n", |
152 |
| - "print(\"Inlining:\", resources['inlining'].keys())\n", |
153 |
| - "print(\"Extension:\", resources['output_extension'])" |
| 151 | + "print(\"Metadata:\", resources[\"metadata\"].keys())\n", |
| 152 | + "print(\"Inlining:\", resources[\"inlining\"].keys())\n", |
| 153 | + "print(\"Extension:\", resources[\"output_extension\"])" |
154 | 154 | ]
|
155 | 155 | },
|
156 | 156 | {
|
|
192 | 192 | "# Convert the notebook to RST format\n",
|
193 | 193 | "(body, resources) = rst_exporter.from_notebook_node(jake_notebook)\n",
|
194 | 194 | "\n",
|
195 |
| - "print(body[:970] + '...')\n", |
196 |
| - "print('[.....]')\n", |
197 |
| - "print(body[800:1200] + '...')" |
| 195 | + "print(body[:970] + \"...\")\n", |
| 196 | + "print(\"[.....]\")\n", |
| 197 | + "print(body[800:1200] + \"...\")" |
198 | 198 | ]
|
199 | 199 | },
|
200 | 200 | {
|
|
218 | 218 | },
|
219 | 219 | "outputs": [],
|
220 | 220 | "source": [
|
221 |
| - "sorted(resources['outputs'].keys())" |
| 221 | + "sorted(resources[\"outputs\"].keys())" |
222 | 222 | ]
|
223 | 223 | },
|
224 | 224 | {
|
|
240 | 240 | "source": [
|
241 | 241 | "from IPython.display import Image\n",
|
242 | 242 | "\n",
|
243 |
| - "Image(data=resources['outputs']['output_3_0.png'], format='png')" |
| 243 | + "Image(data=resources[\"outputs\"][\"output_3_0.png\"], format=\"png\")" |
244 | 244 | ]
|
245 | 245 | },
|
246 | 246 | {
|
|
302 | 302 | "from traitlets.config import Config\n",
|
303 | 303 | "\n",
|
304 | 304 | "c = Config()\n",
|
305 |
| - "c.HTMLExporter.preprocessors = ['nbconvert.preprocessors.ExtractOutputPreprocessor']\n", |
| 305 | + "c.HTMLExporter.preprocessors = [\"nbconvert.preprocessors.ExtractOutputPreprocessor\"]\n", |
306 | 306 | "\n",
|
307 | 307 | "# create the new exporter using the custom config\n",
|
308 | 308 | "html_exporter_with_figs = HTMLExporter(config=c)\n",
|
|
336 | 336 | "print(sorted(resources_with_fig.keys()))\n",
|
337 | 337 | "\n",
|
338 | 338 | "print(\"\\nthe actual figures are:\")\n",
|
339 |
| - "print(sorted(resources_with_fig['outputs'].keys()))" |
| 339 | + "print(sorted(resources_with_fig[\"outputs\"].keys()))" |
340 | 340 | ]
|
341 | 341 | },
|
342 | 342 | {
|
|
382 | 382 | "outputs": [],
|
383 | 383 | "source": [
|
384 | 384 | "from traitlets import Integer\n",
|
| 385 | + "\n", |
385 | 386 | "from nbconvert.preprocessors import Preprocessor\n",
|
386 | 387 | "\n",
|
387 | 388 | "\n",
|
|
450 | 451 | "\n",
|
451 | 452 | "dl = DictLoader(\n",
|
452 | 453 | " {\n",
|
453 |
| - " 'footer': \"\"\"\n", |
454 |
| - "{%- extends 'lab/index.html.j2' -%} \n", |
| 454 | + " \"footer\": \"\"\"\n", |
| 455 | + "{%- extends 'lab/index.html.j2' -%}\n", |
455 | 456 | "\n",
|
456 | 457 | "{% block footer %}\n",
|
457 | 458 | "FOOOOOOOOTEEEEER\n",
|
|
461 | 462 | ")\n",
|
462 | 463 | "\n",
|
463 | 464 | "\n",
|
464 |
| - "exportHTML = HTMLExporter(extra_loaders=[dl], template_file='footer')\n", |
| 465 | + "exportHTML = HTMLExporter(extra_loaders=[dl], template_file=\"footer\")\n", |
465 | 466 | "(body, resources) = exportHTML.from_notebook_node(jake_notebook)\n",
|
466 |
| - "for l in body.split('\\n')[-4:]:\n", |
| 467 | + "for l in body.split(\"\\n\")[-4:]:\n", |
467 | 468 | " print(l)"
|
468 | 469 | ]
|
469 | 470 | },
|
|
0 commit comments