Show More
This diff has been collapsed as it changes many lines, (2522 lines changed) Show them Hide them | |||
@@ -0,0 +1,2522 b'' | |||
|
1 | { | |
|
2 | "metadata": { | |
|
3 | "name": "" | |
|
4 | }, | |
|
5 | "nbformat": 3, | |
|
6 | "nbformat_minor": 0, | |
|
7 | "worksheets": [ | |
|
8 | { | |
|
9 | "cells": [ | |
|
10 | { | |
|
11 | "cell_type": "markdown", | |
|
12 | "metadata": {}, | |
|
13 | "source": [ | |
|
14 | "**WARNING: This document will not render correctly using nbviewer or nbconvert. To render this notebook correctly, open in `IPython Notebook` and run `Cell->Run All` from the menu bar.**" | |
|
15 | ] | |
|
16 | }, | |
|
17 | { | |
|
18 | "cell_type": "heading", | |
|
19 | "level": 1, | |
|
20 | "metadata": {}, | |
|
21 | "source": [ | |
|
22 | "Introduction" | |
|
23 | ] | |
|
24 | }, | |
|
25 | { | |
|
26 | "cell_type": "markdown", | |
|
27 | "metadata": {}, | |
|
28 | "source": [ | |
|
29 | "The IPython Notebook allows Markdown, HTML, and inline LaTeX in *Mardown Cells*. The inline LaTeX is parsed with [MathJax](http://www.mathjax.org/) and Markdown is parsed with [marked](https://github.com/chjj/marked). Any inline HTML is left to the web browser to parse. NBConvert is a utility that allows users to easily convert their notebooks to various formats. Pandoc is used to parse markdown text in NBConvert. Since what the notebook web interface supports is a mix of Markdown, HTML, and LaTeX, Pandoc has trouble converting notebook markdown. This results in incomplete representations of the notebook in nbviewer or a compiled Latex PDF.\n", | |
|
30 | "\n", | |
|
31 | "This isn't a Pandoc flaw; Pandoc isn't designed to parse and convert a mixed format document. Unfortunately, this means that Pandoc can only support a subset of the markup supported in the notebook web interface. This notebook compares output of Pandoc to the notebook web interface.\n", | |
|
32 | "\n", | |
|
33 | "**Changes:**\n", | |
|
34 | "\n", | |
|
35 | "05102013\n", | |
|
36 | "\n", | |
|
37 | " * heading anchors\n", | |
|
38 | " * note on remote images\n", | |
|
39 | "\n", | |
|
40 | "06102013\n", | |
|
41 | "\n", | |
|
42 | " * remove strip_math_space filter\n", | |
|
43 | " * add lxml test\n", | |
|
44 | " \n", | |
|
45 | "<style>\n", | |
|
46 | " .rendered_html xmp { \n", | |
|
47 | " white-space: pre-wrap;\n", | |
|
48 | " }\n", | |
|
49 | "</style>" | |
|
50 | ] | |
|
51 | }, | |
|
52 | { | |
|
53 | "cell_type": "heading", | |
|
54 | "level": 2, | |
|
55 | "metadata": {}, | |
|
56 | "source": [ | |
|
57 | "Utilities" | |
|
58 | ] | |
|
59 | }, | |
|
60 | { | |
|
61 | "cell_type": "markdown", | |
|
62 | "metadata": {}, | |
|
63 | "source": [ | |
|
64 | "Define functions to render Markdown using the notebook and Pandoc." | |
|
65 | ] | |
|
66 | }, | |
|
67 | { | |
|
68 | "cell_type": "code", | |
|
69 | "collapsed": false, | |
|
70 | "input": [ | |
|
71 | "from IPython.nbconvert.utils.pandoc import pandoc\n", | |
|
72 | "from IPython.display import HTML, Javascript, display\n", | |
|
73 | "\n", | |
|
74 | "from IPython.nbconvert.filters import citation2latex, strip_files_prefix, \\\n", | |
|
75 | " markdown2html, markdown2latex\n", | |
|
76 | "\n", | |
|
77 | "def pandoc_render(markdown):\n", | |
|
78 | " \"\"\"Render Pandoc Markdown->LaTeX content.\"\"\"\n", | |
|
79 | " \n", | |
|
80 | " ## Convert the markdown directly to latex. This is what nbconvert does.\n", | |
|
81 | " #latex = pandoc(markdown, \"markdown\", \"latex\")\n", | |
|
82 | " #html = pandoc(markdown, \"markdown\", \"html\", [\"--mathjax\"])\n", | |
|
83 | " \n", | |
|
84 | " # nbconvert template conversions\n", | |
|
85 | " html = strip_files_prefix(markdown2html(markdown))\n", | |
|
86 | " latex = markdown2latex(citation2latex(markdown))\n", | |
|
87 | " display(HTML(data=\"<div style='display: inline-block; width: 30%; vertical-align: top;'>\" \\\n", | |
|
88 | " \"<div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div>\" \\\n", | |
|
89 | " \"<pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\" + latex + \"</xmp></pre>\"\\\n", | |
|
90 | " \"</div>\" \\\n", | |
|
91 | " \"<div style='display: inline-block; width: 2%;'></div>\" \\\n", | |
|
92 | " \"<div style='display: inline-block; width: 30%; vertical-align: top;'>\" \\\n", | |
|
93 | " \"<div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div>\" \\\n", | |
|
94 | " \"<div style='display: inline-block; width: 100%;'>\" + html + \"</div>\" \\\n", | |
|
95 | " \"</div>\"))\n", | |
|
96 | " javascript = \"\"\"\n", | |
|
97 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n", | |
|
98 | "\"\"\"\n", | |
|
99 | " display(Javascript(data=javascript))\n", | |
|
100 | "\n", | |
|
101 | "def notebook_render(markdown):\n", | |
|
102 | " javascript = \"\"\"\n", | |
|
103 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
104 | "mdcell.create_element();\n", | |
|
105 | "mdcell.set_text('\"\"\" + markdown.replace(\"\\\\\", \"\\\\\\\\\").replace(\"'\", \"\\'\").replace(\"\\n\", \"\\\\n\") + \"\"\"');\n", | |
|
106 | "mdcell.render();\n", | |
|
107 | "$(element).append(mdcell.element)\n", | |
|
108 | ".removeClass()\n", | |
|
109 | ".css('left', '66%')\n", | |
|
110 | ".css('position', 'absolute')\n", | |
|
111 | ".css('width', '30%')\n", | |
|
112 | "mdcell.element.prepend(\n", | |
|
113 | " $('<div />')\n", | |
|
114 | " .removeClass()\n", | |
|
115 | " .css('background', '#AAAAFF')\n", | |
|
116 | " .css('width', '100 %')\n", | |
|
117 | " .html('Notebook Output')\n", | |
|
118 | "\n", | |
|
119 | ");\n", | |
|
120 | "container.show()\n", | |
|
121 | "\"\"\"\n", | |
|
122 | " display(Javascript(data=javascript))\n", | |
|
123 | "\n", | |
|
124 | " \n", | |
|
125 | "def pandoc_html_render(markdown):\n", | |
|
126 | " \"\"\"Render Pandoc Markdown->LaTeX content.\"\"\"\n", | |
|
127 | " \n", | |
|
128 | " # Convert the markdown directly to latex. This is what nbconvert does.\n", | |
|
129 | " latex = pandoc(markdown, \"markdown\", \"latex\")\n", | |
|
130 | " \n", | |
|
131 | " # Convert the pandoc generated latex to HTML so it can be rendered in \n", | |
|
132 | " # the web browser.\n", | |
|
133 | " html = pandoc(latex, \"latex\", \"html\", [\"--mathjax\"])\n", | |
|
134 | " display(HTML(data=\"<div style='background: #AAFFAA; width: 40%;'>HTML Pandoc Output</div>\" \\\n", | |
|
135 | " \"<div style='display: inline-block; width: 40%;'>\" + html + \"</div>\"))\n", | |
|
136 | " return html\n", | |
|
137 | " \n", | |
|
138 | "def compare_render(markdown):\n", | |
|
139 | " notebook_render(markdown)\n", | |
|
140 | " pandoc_render(markdown)" | |
|
141 | ], | |
|
142 | "language": "python", | |
|
143 | "metadata": {}, | |
|
144 | "outputs": [], | |
|
145 | "prompt_number": 1 | |
|
146 | }, | |
|
147 | { | |
|
148 | "cell_type": "heading", | |
|
149 | "level": 1, | |
|
150 | "metadata": {}, | |
|
151 | "source": [ | |
|
152 | "Outputs" | |
|
153 | ] | |
|
154 | }, | |
|
155 | { | |
|
156 | "cell_type": "code", | |
|
157 | "collapsed": false, | |
|
158 | "input": [ | |
|
159 | "try:\n", | |
|
160 | " import lxml\n", | |
|
161 | " print 'LXML found!'\n", | |
|
162 | "except:\n", | |
|
163 | " print 'Warning! No LXML found - the old citation2latex filter will not work'" | |
|
164 | ], | |
|
165 | "language": "python", | |
|
166 | "metadata": {}, | |
|
167 | "outputs": [ | |
|
168 | { | |
|
169 | "output_type": "stream", | |
|
170 | "stream": "stdout", | |
|
171 | "text": [ | |
|
172 | "LXML found!\n" | |
|
173 | ] | |
|
174 | } | |
|
175 | ], | |
|
176 | "prompt_number": 1 | |
|
177 | }, | |
|
178 | { | |
|
179 | "cell_type": "heading", | |
|
180 | "level": 2, | |
|
181 | "metadata": {}, | |
|
182 | "source": [ | |
|
183 | "General markdown" | |
|
184 | ] | |
|
185 | }, | |
|
186 | { | |
|
187 | "cell_type": "markdown", | |
|
188 | "metadata": {}, | |
|
189 | "source": [ | |
|
190 | "Heading level 6 is not supported by Pandoc." | |
|
191 | ] | |
|
192 | }, | |
|
193 | { | |
|
194 | "cell_type": "code", | |
|
195 | "collapsed": false, | |
|
196 | "input": [ | |
|
197 | "compare_render(r\"\"\"\n", | |
|
198 | "\n", | |
|
199 | "# Heading 1 \n", | |
|
200 | "## Heading 2 \n", | |
|
201 | "### Heading 3 \n", | |
|
202 | "#### Heading 4 \n", | |
|
203 | "##### Heading 5 \n", | |
|
204 | "###### Heading 6\"\"\")" | |
|
205 | ], | |
|
206 | "language": "python", | |
|
207 | "metadata": {}, | |
|
208 | "outputs": [ | |
|
209 | { | |
|
210 | "javascript": [ | |
|
211 | "\n", | |
|
212 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
213 | "mdcell.create_element();\n", | |
|
214 | "mdcell.set_text('\\n\\n# Heading 1 \\n## Heading 2 \\n### Heading 3 \\n#### Heading 4 \\n##### Heading 5 \\n###### Heading 6');\n", | |
|
215 | "mdcell.render();\n", | |
|
216 | "$(element).append(mdcell.element)\n", | |
|
217 | ".removeClass()\n", | |
|
218 | ".css('left', '66%')\n", | |
|
219 | ".css('position', 'absolute')\n", | |
|
220 | ".css('width', '30%')\n", | |
|
221 | "mdcell.element.prepend(\n", | |
|
222 | " $('<div />')\n", | |
|
223 | " .removeClass()\n", | |
|
224 | " .css('background', '#AAAAFF')\n", | |
|
225 | " .css('width', '100 %')\n", | |
|
226 | " .html('Notebook Output')\n", | |
|
227 | "\n", | |
|
228 | ");\n", | |
|
229 | "container.show()\n" | |
|
230 | ], | |
|
231 | "metadata": {}, | |
|
232 | "output_type": "display_data", | |
|
233 | "text": [ | |
|
234 | "<IPython.core.display.Javascript at 0x21ac2d0>" | |
|
235 | ] | |
|
236 | }, | |
|
237 | { | |
|
238 | "html": [ | |
|
239 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\section{Heading 1}\n", | |
|
240 | "\n", | |
|
241 | "\\subsection{Heading 2}\n", | |
|
242 | "\n", | |
|
243 | "\\subsubsection{Heading 3}\n", | |
|
244 | "\n", | |
|
245 | "\\paragraph{Heading 4}\n", | |
|
246 | "\n", | |
|
247 | "\\subparagraph{Heading 5}\n", | |
|
248 | "\n", | |
|
249 | "Heading 6</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><h1 id=\"heading-1\">Heading 1</h1>\n", | |
|
250 | "<h2 id=\"heading-2\">Heading 2</h2>\n", | |
|
251 | "<h3 id=\"heading-3\">Heading 3</h3>\n", | |
|
252 | "<h4 id=\"heading-4\">Heading 4</h4>\n", | |
|
253 | "<h5 id=\"heading-5\">Heading 5</h5>\n", | |
|
254 | "<h6 id=\"heading-6\">Heading 6</h6></div></div>" | |
|
255 | ], | |
|
256 | "metadata": {}, | |
|
257 | "output_type": "display_data", | |
|
258 | "text": [ | |
|
259 | "<IPython.core.display.HTML at 0x21b9fd0>" | |
|
260 | ] | |
|
261 | }, | |
|
262 | { | |
|
263 | "javascript": [ | |
|
264 | "\n", | |
|
265 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
266 | ], | |
|
267 | "metadata": {}, | |
|
268 | "output_type": "display_data", | |
|
269 | "text": [ | |
|
270 | "<IPython.core.display.Javascript at 0x21b9fd0>" | |
|
271 | ] | |
|
272 | } | |
|
273 | ], | |
|
274 | "prompt_number": 2 | |
|
275 | }, | |
|
276 | { | |
|
277 | "cell_type": "markdown", | |
|
278 | "metadata": {}, | |
|
279 | "source": [ | |
|
280 | "Headers aren't recognized by (Pandoc on Windows?) if there isn't a blank line above the headers." | |
|
281 | ] | |
|
282 | }, | |
|
283 | { | |
|
284 | "cell_type": "code", | |
|
285 | "collapsed": false, | |
|
286 | "input": [ | |
|
287 | "compare_render(r\"\"\"\n", | |
|
288 | "# Heading 1 \n", | |
|
289 | "## Heading 2 \n", | |
|
290 | "### Heading 3 \n", | |
|
291 | "#### Heading 4 \n", | |
|
292 | "##### Heading 5 \n", | |
|
293 | "###### Heading 6 \"\"\")\n", | |
|
294 | "\n", | |
|
295 | "print(\"\\n\"*10)" | |
|
296 | ], | |
|
297 | "language": "python", | |
|
298 | "metadata": {}, | |
|
299 | "outputs": [ | |
|
300 | { | |
|
301 | "javascript": [ | |
|
302 | "\n", | |
|
303 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
304 | "mdcell.create_element();\n", | |
|
305 | "mdcell.set_text('\\n# Heading 1 \\n## Heading 2 \\n### Heading 3 \\n#### Heading 4 \\n##### Heading 5 \\n###### Heading 6 ');\n", | |
|
306 | "mdcell.render();\n", | |
|
307 | "$(element).append(mdcell.element)\n", | |
|
308 | ".removeClass()\n", | |
|
309 | ".css('left', '66%')\n", | |
|
310 | ".css('position', 'absolute')\n", | |
|
311 | ".css('width', '30%')\n", | |
|
312 | "mdcell.element.prepend(\n", | |
|
313 | " $('<div />')\n", | |
|
314 | " .removeClass()\n", | |
|
315 | " .css('background', '#AAAAFF')\n", | |
|
316 | " .css('width', '100 %')\n", | |
|
317 | " .html('Notebook Output')\n", | |
|
318 | "\n", | |
|
319 | ");\n", | |
|
320 | "container.show()\n" | |
|
321 | ], | |
|
322 | "metadata": {}, | |
|
323 | "output_type": "display_data", | |
|
324 | "text": [ | |
|
325 | "<IPython.core.display.Javascript at 0x21ac550>" | |
|
326 | ] | |
|
327 | }, | |
|
328 | { | |
|
329 | "html": [ | |
|
330 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\section{Heading 1}\n", | |
|
331 | "\n", | |
|
332 | "\\subsection{Heading 2}\n", | |
|
333 | "\n", | |
|
334 | "\\subsubsection{Heading 3}\n", | |
|
335 | "\n", | |
|
336 | "\\paragraph{Heading 4}\n", | |
|
337 | "\n", | |
|
338 | "\\subparagraph{Heading 5}\n", | |
|
339 | "\n", | |
|
340 | "Heading 6</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><h1 id=\"heading-1\">Heading 1</h1>\n", | |
|
341 | "<h2 id=\"heading-2\">Heading 2</h2>\n", | |
|
342 | "<h3 id=\"heading-3\">Heading 3</h3>\n", | |
|
343 | "<h4 id=\"heading-4\">Heading 4</h4>\n", | |
|
344 | "<h5 id=\"heading-5\">Heading 5</h5>\n", | |
|
345 | "<h6 id=\"heading-6\">Heading 6</h6></div></div>" | |
|
346 | ], | |
|
347 | "metadata": {}, | |
|
348 | "output_type": "display_data", | |
|
349 | "text": [ | |
|
350 | "<IPython.core.display.HTML at 0x21ac550>" | |
|
351 | ] | |
|
352 | }, | |
|
353 | { | |
|
354 | "javascript": [ | |
|
355 | "\n", | |
|
356 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
357 | ], | |
|
358 | "metadata": {}, | |
|
359 | "output_type": "display_data", | |
|
360 | "text": [ | |
|
361 | "<IPython.core.display.Javascript at 0x21ac550>" | |
|
362 | ] | |
|
363 | }, | |
|
364 | { | |
|
365 | "output_type": "stream", | |
|
366 | "stream": "stdout", | |
|
367 | "text": [ | |
|
368 | "\n", | |
|
369 | "\n", | |
|
370 | "\n", | |
|
371 | "\n", | |
|
372 | "\n", | |
|
373 | "\n", | |
|
374 | "\n", | |
|
375 | "\n", | |
|
376 | "\n", | |
|
377 | "\n", | |
|
378 | "\n" | |
|
379 | ] | |
|
380 | } | |
|
381 | ], | |
|
382 | "prompt_number": 3 | |
|
383 | }, | |
|
384 | { | |
|
385 | "cell_type": "markdown", | |
|
386 | "metadata": {}, | |
|
387 | "source": [ | |
|
388 | "If internal links are defined, these will not work in nbviewer and latex as the local link is not existing." | |
|
389 | ] | |
|
390 | }, | |
|
391 | { | |
|
392 | "cell_type": "code", | |
|
393 | "collapsed": false, | |
|
394 | "input": [ | |
|
395 | "compare_render(r\"\"\"\n", | |
|
396 | "[Link2Heading](http://127.0.0.1:8888/0a2d8086-ee24-4e5b-a32b-f66b525836cb#General-markdown)\n", | |
|
397 | "\"\"\")" | |
|
398 | ], | |
|
399 | "language": "python", | |
|
400 | "metadata": {}, | |
|
401 | "outputs": [ | |
|
402 | { | |
|
403 | "javascript": [ | |
|
404 | "\n", | |
|
405 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
406 | "mdcell.create_element();\n", | |
|
407 | "mdcell.set_text('\\n[Link2Heading](http://127.0.0.1:8888/0a2d8086-ee24-4e5b-a32b-f66b525836cb#General-markdown)\\n');\n", | |
|
408 | "mdcell.render();\n", | |
|
409 | "$(element).append(mdcell.element)\n", | |
|
410 | ".removeClass()\n", | |
|
411 | ".css('left', '66%')\n", | |
|
412 | ".css('position', 'absolute')\n", | |
|
413 | ".css('width', '30%')\n", | |
|
414 | "mdcell.element.prepend(\n", | |
|
415 | " $('<div />')\n", | |
|
416 | " .removeClass()\n", | |
|
417 | " .css('background', '#AAAAFF')\n", | |
|
418 | " .css('width', '100 %')\n", | |
|
419 | " .html('Notebook Output')\n", | |
|
420 | "\n", | |
|
421 | ");\n", | |
|
422 | "container.show()\n" | |
|
423 | ], | |
|
424 | "metadata": {}, | |
|
425 | "output_type": "display_data", | |
|
426 | "text": [ | |
|
427 | "<IPython.core.display.Javascript at 0x21ac210>" | |
|
428 | ] | |
|
429 | }, | |
|
430 | { | |
|
431 | "html": [ | |
|
432 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\href{http://127.0.0.1:8888/0a2d8086-ee24-4e5b-a32b-f66b525836cb\\#General-markdown}{Link2Heading}</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p><a href=\"http://127.0.0.1:8888/0a2d8086-ee24-4e5b-a32b-f66b525836cb#General-markdown\">Link2Heading</a></p></div></div>" | |
|
433 | ], | |
|
434 | "metadata": {}, | |
|
435 | "output_type": "display_data", | |
|
436 | "text": [ | |
|
437 | "<IPython.core.display.HTML at 0x21ac210>" | |
|
438 | ] | |
|
439 | }, | |
|
440 | { | |
|
441 | "javascript": [ | |
|
442 | "\n", | |
|
443 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
444 | ], | |
|
445 | "metadata": {}, | |
|
446 | "output_type": "display_data", | |
|
447 | "text": [ | |
|
448 | "<IPython.core.display.Javascript at 0x21ac210>" | |
|
449 | ] | |
|
450 | } | |
|
451 | ], | |
|
452 | "prompt_number": 4 | |
|
453 | }, | |
|
454 | { | |
|
455 | "cell_type": "markdown", | |
|
456 | "metadata": {}, | |
|
457 | "source": [ | |
|
458 | "Basic Markdown bold and italic works." | |
|
459 | ] | |
|
460 | }, | |
|
461 | { | |
|
462 | "cell_type": "code", | |
|
463 | "collapsed": false, | |
|
464 | "input": [ | |
|
465 | "compare_render(r\"\"\"\n", | |
|
466 | "This is Markdown **bold** and *italic* text.\n", | |
|
467 | "\"\"\")" | |
|
468 | ], | |
|
469 | "language": "python", | |
|
470 | "metadata": {}, | |
|
471 | "outputs": [ | |
|
472 | { | |
|
473 | "javascript": [ | |
|
474 | "\n", | |
|
475 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
476 | "mdcell.create_element();\n", | |
|
477 | "mdcell.set_text('\\nThis is Markdown **bold** and *italic* text.\\n');\n", | |
|
478 | "mdcell.render();\n", | |
|
479 | "$(element).append(mdcell.element)\n", | |
|
480 | ".removeClass()\n", | |
|
481 | ".css('left', '66%')\n", | |
|
482 | ".css('position', 'absolute')\n", | |
|
483 | ".css('width', '30%')\n", | |
|
484 | "mdcell.element.prepend(\n", | |
|
485 | " $('<div />')\n", | |
|
486 | " .removeClass()\n", | |
|
487 | " .css('background', '#AAAAFF')\n", | |
|
488 | " .css('width', '100 %')\n", | |
|
489 | " .html('Notebook Output')\n", | |
|
490 | "\n", | |
|
491 | ");\n", | |
|
492 | "container.show()\n" | |
|
493 | ], | |
|
494 | "metadata": {}, | |
|
495 | "output_type": "display_data", | |
|
496 | "text": [ | |
|
497 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
498 | ] | |
|
499 | }, | |
|
500 | { | |
|
501 | "html": [ | |
|
502 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>This is Markdown \\textbf{bold} and \\emph{italic} text.</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p>This is Markdown <strong>bold</strong> and <em>italic</em> text.</p></div></div>" | |
|
503 | ], | |
|
504 | "metadata": {}, | |
|
505 | "output_type": "display_data", | |
|
506 | "text": [ | |
|
507 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
508 | ] | |
|
509 | }, | |
|
510 | { | |
|
511 | "javascript": [ | |
|
512 | "\n", | |
|
513 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
514 | ], | |
|
515 | "metadata": {}, | |
|
516 | "output_type": "display_data", | |
|
517 | "text": [ | |
|
518 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
519 | ] | |
|
520 | } | |
|
521 | ], | |
|
522 | "prompt_number": 5 | |
|
523 | }, | |
|
524 | { | |
|
525 | "cell_type": "markdown", | |
|
526 | "metadata": {}, | |
|
527 | "source": [ | |
|
528 | "Nested lists work as well" | |
|
529 | ] | |
|
530 | }, | |
|
531 | { | |
|
532 | "cell_type": "code", | |
|
533 | "collapsed": false, | |
|
534 | "input": [ | |
|
535 | "compare_render(r\"\"\"\n", | |
|
536 | "- li 1\n", | |
|
537 | "- li 2\n", | |
|
538 | " 1. li 3\n", | |
|
539 | " 1. li 4\n", | |
|
540 | "- li 5\n", | |
|
541 | "\"\"\")" | |
|
542 | ], | |
|
543 | "language": "python", | |
|
544 | "metadata": {}, | |
|
545 | "outputs": [ | |
|
546 | { | |
|
547 | "javascript": [ | |
|
548 | "\n", | |
|
549 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
550 | "mdcell.create_element();\n", | |
|
551 | "mdcell.set_text('\\n- li 1\\n- li 2\\n 1. li 3\\n 1. li 4\\n- li 5\\n');\n", | |
|
552 | "mdcell.render();\n", | |
|
553 | "$(element).append(mdcell.element)\n", | |
|
554 | ".removeClass()\n", | |
|
555 | ".css('left', '66%')\n", | |
|
556 | ".css('position', 'absolute')\n", | |
|
557 | ".css('width', '30%')\n", | |
|
558 | "mdcell.element.prepend(\n", | |
|
559 | " $('<div />')\n", | |
|
560 | " .removeClass()\n", | |
|
561 | " .css('background', '#AAAAFF')\n", | |
|
562 | " .css('width', '100 %')\n", | |
|
563 | " .html('Notebook Output')\n", | |
|
564 | "\n", | |
|
565 | ");\n", | |
|
566 | "container.show()\n" | |
|
567 | ], | |
|
568 | "metadata": {}, | |
|
569 | "output_type": "display_data", | |
|
570 | "text": [ | |
|
571 | "<IPython.core.display.Javascript at 0x21ac150>" | |
|
572 | ] | |
|
573 | }, | |
|
574 | { | |
|
575 | "html": [ | |
|
576 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\begin{itemize}\n", | |
|
577 | "\\itemsep1pt\\parskip0pt\\parsep0pt\n", | |
|
578 | "\\item\n", | |
|
579 | " li 1\n", | |
|
580 | "\\item\n", | |
|
581 | " li 2\n", | |
|
582 | "\n", | |
|
583 | " \\begin{enumerate}\n", | |
|
584 | " \\def\\labelenumi{\\arabic{enumi}.}\n", | |
|
585 | " \\itemsep1pt\\parskip0pt\\parsep0pt\n", | |
|
586 | " \\item\n", | |
|
587 | " li 3\n", | |
|
588 | " \\item\n", | |
|
589 | " li 4\n", | |
|
590 | " \\end{enumerate}\n", | |
|
591 | "\\item\n", | |
|
592 | " li 5\n", | |
|
593 | "\\end{itemize}</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><ul>\n", | |
|
594 | "<li>li 1</li>\n", | |
|
595 | "<li>li 2\n", | |
|
596 | "<ol style=\"list-style-type: decimal\">\n", | |
|
597 | "<li>li 3</li>\n", | |
|
598 | "<li>li 4</li>\n", | |
|
599 | "</ol></li>\n", | |
|
600 | "<li>li 5</li>\n", | |
|
601 | "</ul></div></div>" | |
|
602 | ], | |
|
603 | "metadata": {}, | |
|
604 | "output_type": "display_data", | |
|
605 | "text": [ | |
|
606 | "<IPython.core.display.HTML at 0x21ac150>" | |
|
607 | ] | |
|
608 | }, | |
|
609 | { | |
|
610 | "javascript": [ | |
|
611 | "\n", | |
|
612 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
613 | ], | |
|
614 | "metadata": {}, | |
|
615 | "output_type": "display_data", | |
|
616 | "text": [ | |
|
617 | "<IPython.core.display.Javascript at 0x21ac150>" | |
|
618 | ] | |
|
619 | } | |
|
620 | ], | |
|
621 | "prompt_number": 6 | |
|
622 | }, | |
|
623 | { | |
|
624 | "cell_type": "markdown", | |
|
625 | "metadata": {}, | |
|
626 | "source": [ | |
|
627 | "Unicode support" | |
|
628 | ] | |
|
629 | }, | |
|
630 | { | |
|
631 | "cell_type": "code", | |
|
632 | "collapsed": false, | |
|
633 | "input": [ | |
|
634 | "compare_render(ur\"\"\"\n", | |
|
635 | "\u00fcberschu\u00df +***^\u00b0\u00b3\u00b3 \u03b1 \u03b2 \u03b8\n", | |
|
636 | "\"\"\")" | |
|
637 | ], | |
|
638 | "language": "python", | |
|
639 | "metadata": {}, | |
|
640 | "outputs": [ | |
|
641 | { | |
|
642 | "javascript": [ | |
|
643 | "\n", | |
|
644 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
645 | "mdcell.create_element();\n", | |
|
646 | "mdcell.set_text('\\n\u00fcberschu\u00df +***^\u00b0\u00b3\u00b3 \u03b1 \u03b2 \u03b8\\n');\n", | |
|
647 | "mdcell.render();\n", | |
|
648 | "$(element).append(mdcell.element)\n", | |
|
649 | ".removeClass()\n", | |
|
650 | ".css('left', '66%')\n", | |
|
651 | ".css('position', 'absolute')\n", | |
|
652 | ".css('width', '30%')\n", | |
|
653 | "mdcell.element.prepend(\n", | |
|
654 | " $('<div />')\n", | |
|
655 | " .removeClass()\n", | |
|
656 | " .css('background', '#AAAAFF')\n", | |
|
657 | " .css('width', '100 %')\n", | |
|
658 | " .html('Notebook Output')\n", | |
|
659 | "\n", | |
|
660 | ");\n", | |
|
661 | "container.show()\n" | |
|
662 | ], | |
|
663 | "metadata": {}, | |
|
664 | "output_type": "display_data", | |
|
665 | "text": [ | |
|
666 | "<IPython.core.display.Javascript at 0x22b6950>" | |
|
667 | ] | |
|
668 | }, | |
|
669 | { | |
|
670 | "html": [ | |
|
671 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\u00fcberschu\u00df +\\emph{*}\\^{}\u00b0\u00b3\u00b3 \u03b1 \u03b2 \u03b8</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p>\u00fcberschu\u00df +<em>*</em>^\u00b0\u00b3\u00b3 \u03b1 \u03b2 \u03b8</p></div></div>" | |
|
672 | ], | |
|
673 | "metadata": {}, | |
|
674 | "output_type": "display_data", | |
|
675 | "text": [ | |
|
676 | "<IPython.core.display.HTML at 0x21ac3d0>" | |
|
677 | ] | |
|
678 | }, | |
|
679 | { | |
|
680 | "javascript": [ | |
|
681 | "\n", | |
|
682 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
683 | ], | |
|
684 | "metadata": {}, | |
|
685 | "output_type": "display_data", | |
|
686 | "text": [ | |
|
687 | "<IPython.core.display.Javascript at 0x21ac3d0>" | |
|
688 | ] | |
|
689 | } | |
|
690 | ], | |
|
691 | "prompt_number": 7 | |
|
692 | }, | |
|
693 | { | |
|
694 | "cell_type": "markdown", | |
|
695 | "metadata": {}, | |
|
696 | "source": [ | |
|
697 | "Pandoc may produce invalid latex, e.g \\sout is not allowed in headings" | |
|
698 | ] | |
|
699 | }, | |
|
700 | { | |
|
701 | "cell_type": "code", | |
|
702 | "collapsed": false, | |
|
703 | "input": [ | |
|
704 | "compare_render(r\"\"\"\n", | |
|
705 | "\n", | |
|
706 | "# Heading 1 ~~strikeout~~\n", | |
|
707 | "\"\"\")" | |
|
708 | ], | |
|
709 | "language": "python", | |
|
710 | "metadata": {}, | |
|
711 | "outputs": [ | |
|
712 | { | |
|
713 | "javascript": [ | |
|
714 | "\n", | |
|
715 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
716 | "mdcell.create_element();\n", | |
|
717 | "mdcell.set_text('\\n\\n# Heading 1 ~~strikeout~~\\n');\n", | |
|
718 | "mdcell.render();\n", | |
|
719 | "$(element).append(mdcell.element)\n", | |
|
720 | ".removeClass()\n", | |
|
721 | ".css('left', '66%')\n", | |
|
722 | ".css('position', 'absolute')\n", | |
|
723 | ".css('width', '30%')\n", | |
|
724 | "mdcell.element.prepend(\n", | |
|
725 | " $('<div />')\n", | |
|
726 | " .removeClass()\n", | |
|
727 | " .css('background', '#AAAAFF')\n", | |
|
728 | " .css('width', '100 %')\n", | |
|
729 | " .html('Notebook Output')\n", | |
|
730 | "\n", | |
|
731 | ");\n", | |
|
732 | "container.show()\n" | |
|
733 | ], | |
|
734 | "metadata": {}, | |
|
735 | "output_type": "display_data", | |
|
736 | "text": [ | |
|
737 | "<IPython.core.display.Javascript at 0x21ac590>" | |
|
738 | ] | |
|
739 | }, | |
|
740 | { | |
|
741 | "html": [ | |
|
742 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\section{Heading 1 \\sout{strikeout}}</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><h1 id=\"heading-1-strikeout\">Heading 1 <del>strikeout</del></h1></div></div>" | |
|
743 | ], | |
|
744 | "metadata": {}, | |
|
745 | "output_type": "display_data", | |
|
746 | "text": [ | |
|
747 | "<IPython.core.display.HTML at 0x21ac590>" | |
|
748 | ] | |
|
749 | }, | |
|
750 | { | |
|
751 | "javascript": [ | |
|
752 | "\n", | |
|
753 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
754 | ], | |
|
755 | "metadata": {}, | |
|
756 | "output_type": "display_data", | |
|
757 | "text": [ | |
|
758 | "<IPython.core.display.Javascript at 0x21ac590>" | |
|
759 | ] | |
|
760 | } | |
|
761 | ], | |
|
762 | "prompt_number": 8 | |
|
763 | }, | |
|
764 | { | |
|
765 | "cell_type": "markdown", | |
|
766 | "metadata": {}, | |
|
767 | "source": [ | |
|
768 | "Horizontal lines work just fine" | |
|
769 | ] | |
|
770 | }, | |
|
771 | { | |
|
772 | "cell_type": "code", | |
|
773 | "collapsed": false, | |
|
774 | "input": [ | |
|
775 | "compare_render(r\"\"\"\n", | |
|
776 | "above\n", | |
|
777 | "\n", | |
|
778 | "--------\n", | |
|
779 | "\n", | |
|
780 | "below\n", | |
|
781 | "\"\"\")" | |
|
782 | ], | |
|
783 | "language": "python", | |
|
784 | "metadata": {}, | |
|
785 | "outputs": [ | |
|
786 | { | |
|
787 | "javascript": [ | |
|
788 | "\n", | |
|
789 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
790 | "mdcell.create_element();\n", | |
|
791 | "mdcell.set_text('\\nabove\\n\\n--------\\n\\nbelow\\n');\n", | |
|
792 | "mdcell.render();\n", | |
|
793 | "$(element).append(mdcell.element)\n", | |
|
794 | ".removeClass()\n", | |
|
795 | ".css('left', '66%')\n", | |
|
796 | ".css('position', 'absolute')\n", | |
|
797 | ".css('width', '30%')\n", | |
|
798 | "mdcell.element.prepend(\n", | |
|
799 | " $('<div />')\n", | |
|
800 | " .removeClass()\n", | |
|
801 | " .css('background', '#AAAAFF')\n", | |
|
802 | " .css('width', '100 %')\n", | |
|
803 | " .html('Notebook Output')\n", | |
|
804 | "\n", | |
|
805 | ");\n", | |
|
806 | "container.show()\n" | |
|
807 | ], | |
|
808 | "metadata": {}, | |
|
809 | "output_type": "display_data", | |
|
810 | "text": [ | |
|
811 | "<IPython.core.display.Javascript at 0x21ac150>" | |
|
812 | ] | |
|
813 | }, | |
|
814 | { | |
|
815 | "html": [ | |
|
816 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>above\n", | |
|
817 | "\n", | |
|
818 | "\\begin{center}\\rule{3in}{0.4pt}\\end{center}\n", | |
|
819 | "\n", | |
|
820 | "below</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p>above</p>\n", | |
|
821 | "<hr />\n", | |
|
822 | "<p>below</p></div></div>" | |
|
823 | ], | |
|
824 | "metadata": {}, | |
|
825 | "output_type": "display_data", | |
|
826 | "text": [ | |
|
827 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
828 | ] | |
|
829 | }, | |
|
830 | { | |
|
831 | "javascript": [ | |
|
832 | "\n", | |
|
833 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
834 | ], | |
|
835 | "metadata": {}, | |
|
836 | "output_type": "display_data", | |
|
837 | "text": [ | |
|
838 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
839 | ] | |
|
840 | } | |
|
841 | ], | |
|
842 | "prompt_number": 9 | |
|
843 | }, | |
|
844 | { | |
|
845 | "cell_type": "heading", | |
|
846 | "level": 2, | |
|
847 | "metadata": {}, | |
|
848 | "source": [ | |
|
849 | "Extended markdown of pandoc" | |
|
850 | ] | |
|
851 | }, | |
|
852 | { | |
|
853 | "cell_type": "markdown", | |
|
854 | "metadata": {}, | |
|
855 | "source": [ | |
|
856 | "(maybe we should deactivate this) " | |
|
857 | ] | |
|
858 | }, | |
|
859 | { | |
|
860 | "cell_type": "code", | |
|
861 | "collapsed": false, | |
|
862 | "input": [ | |
|
863 | "compare_render(r\"\"\"\n", | |
|
864 | "This is Markdown ~subscript~ and ^superscript^ text.\n", | |
|
865 | "\"\"\")" | |
|
866 | ], | |
|
867 | "language": "python", | |
|
868 | "metadata": {}, | |
|
869 | "outputs": [ | |
|
870 | { | |
|
871 | "javascript": [ | |
|
872 | "\n", | |
|
873 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
874 | "mdcell.create_element();\n", | |
|
875 | "mdcell.set_text('\\nThis is Markdown ~subscript~ and ^superscript^ text.\\n');\n", | |
|
876 | "mdcell.render();\n", | |
|
877 | "$(element).append(mdcell.element)\n", | |
|
878 | ".removeClass()\n", | |
|
879 | ".css('left', '66%')\n", | |
|
880 | ".css('position', 'absolute')\n", | |
|
881 | ".css('width', '30%')\n", | |
|
882 | "mdcell.element.prepend(\n", | |
|
883 | " $('<div />')\n", | |
|
884 | " .removeClass()\n", | |
|
885 | " .css('background', '#AAAAFF')\n", | |
|
886 | " .css('width', '100 %')\n", | |
|
887 | " .html('Notebook Output')\n", | |
|
888 | "\n", | |
|
889 | ");\n", | |
|
890 | "container.show()\n" | |
|
891 | ], | |
|
892 | "metadata": {}, | |
|
893 | "output_type": "display_data", | |
|
894 | "text": [ | |
|
895 | "<IPython.core.display.Javascript at 0x21ac150>" | |
|
896 | ] | |
|
897 | }, | |
|
898 | { | |
|
899 | "html": [ | |
|
900 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>This is Markdown \\textsubscript{subscript} and\n", | |
|
901 | "\\textsuperscript{superscript} text.</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p>This is Markdown <sub>subscript</sub> and <sup>superscript</sup> text.</p></div></div>" | |
|
902 | ], | |
|
903 | "metadata": {}, | |
|
904 | "output_type": "display_data", | |
|
905 | "text": [ | |
|
906 | "<IPython.core.display.HTML at 0x21ac150>" | |
|
907 | ] | |
|
908 | }, | |
|
909 | { | |
|
910 | "javascript": [ | |
|
911 | "\n", | |
|
912 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
913 | ], | |
|
914 | "metadata": {}, | |
|
915 | "output_type": "display_data", | |
|
916 | "text": [ | |
|
917 | "<IPython.core.display.Javascript at 0x21ac150>" | |
|
918 | ] | |
|
919 | } | |
|
920 | ], | |
|
921 | "prompt_number": 10 | |
|
922 | }, | |
|
923 | { | |
|
924 | "cell_type": "markdown", | |
|
925 | "metadata": {}, | |
|
926 | "source": [ | |
|
927 | "No space before underline behaves inconsistent (Pandoc extension: intraword_underscores - deactivate?)" | |
|
928 | ] | |
|
929 | }, | |
|
930 | { | |
|
931 | "cell_type": "code", | |
|
932 | "collapsed": false, | |
|
933 | "input": [ | |
|
934 | "compare_render(r\"\"\"\n", | |
|
935 | "This is Markdown not_italic_.\n", | |
|
936 | "\"\"\")" | |
|
937 | ], | |
|
938 | "language": "python", | |
|
939 | "metadata": {}, | |
|
940 | "outputs": [ | |
|
941 | { | |
|
942 | "javascript": [ | |
|
943 | "\n", | |
|
944 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
945 | "mdcell.create_element();\n", | |
|
946 | "mdcell.set_text('\\nThis is Markdown not_italic_.\\n');\n", | |
|
947 | "mdcell.render();\n", | |
|
948 | "$(element).append(mdcell.element)\n", | |
|
949 | ".removeClass()\n", | |
|
950 | ".css('left', '66%')\n", | |
|
951 | ".css('position', 'absolute')\n", | |
|
952 | ".css('width', '30%')\n", | |
|
953 | "mdcell.element.prepend(\n", | |
|
954 | " $('<div />')\n", | |
|
955 | " .removeClass()\n", | |
|
956 | " .css('background', '#AAAAFF')\n", | |
|
957 | " .css('width', '100 %')\n", | |
|
958 | " .html('Notebook Output')\n", | |
|
959 | "\n", | |
|
960 | ");\n", | |
|
961 | "container.show()\n" | |
|
962 | ], | |
|
963 | "metadata": {}, | |
|
964 | "output_type": "display_data", | |
|
965 | "text": [ | |
|
966 | "<IPython.core.display.Javascript at 0x21ac5d0>" | |
|
967 | ] | |
|
968 | }, | |
|
969 | { | |
|
970 | "html": [ | |
|
971 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>This is Markdown not\\_italic\\_.</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p>This is Markdown not_italic_.</p></div></div>" | |
|
972 | ], | |
|
973 | "metadata": {}, | |
|
974 | "output_type": "display_data", | |
|
975 | "text": [ | |
|
976 | "<IPython.core.display.HTML at 0x21ac5d0>" | |
|
977 | ] | |
|
978 | }, | |
|
979 | { | |
|
980 | "javascript": [ | |
|
981 | "\n", | |
|
982 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
983 | ], | |
|
984 | "metadata": {}, | |
|
985 | "output_type": "display_data", | |
|
986 | "text": [ | |
|
987 | "<IPython.core.display.Javascript at 0x21ac5d0>" | |
|
988 | ] | |
|
989 | } | |
|
990 | ], | |
|
991 | "prompt_number": 11 | |
|
992 | }, | |
|
993 | { | |
|
994 | "cell_type": "markdown", | |
|
995 | "metadata": {}, | |
|
996 | "source": [ | |
|
997 | "Pandoc allows to define tex macros which are respected for all output formats, the notebook not. " | |
|
998 | ] | |
|
999 | }, | |
|
1000 | { | |
|
1001 | "cell_type": "code", | |
|
1002 | "collapsed": false, | |
|
1003 | "input": [ | |
|
1004 | "compare_render(r\"\"\"\n", | |
|
1005 | "\\newcommand{\\tuple}[1]{\\langle #1 \\rangle}\n", | |
|
1006 | "\n", | |
|
1007 | "$\\tuple{a, b, c}$\n", | |
|
1008 | "\"\"\")" | |
|
1009 | ], | |
|
1010 | "language": "python", | |
|
1011 | "metadata": {}, | |
|
1012 | "outputs": [ | |
|
1013 | { | |
|
1014 | "javascript": [ | |
|
1015 | "\n", | |
|
1016 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1017 | "mdcell.create_element();\n", | |
|
1018 | "mdcell.set_text('\\n\\\\newcommand{\\\\tuple}[1]{\\\\langle #1 \\\\rangle}\\n\\n$\\\\tuple{a, b, c}$\\n');\n", | |
|
1019 | "mdcell.render();\n", | |
|
1020 | "$(element).append(mdcell.element)\n", | |
|
1021 | ".removeClass()\n", | |
|
1022 | ".css('left', '66%')\n", | |
|
1023 | ".css('position', 'absolute')\n", | |
|
1024 | ".css('width', '30%')\n", | |
|
1025 | "mdcell.element.prepend(\n", | |
|
1026 | " $('<div />')\n", | |
|
1027 | " .removeClass()\n", | |
|
1028 | " .css('background', '#AAAAFF')\n", | |
|
1029 | " .css('width', '100 %')\n", | |
|
1030 | " .html('Notebook Output')\n", | |
|
1031 | "\n", | |
|
1032 | ");\n", | |
|
1033 | "container.show()\n" | |
|
1034 | ], | |
|
1035 | "metadata": {}, | |
|
1036 | "output_type": "display_data", | |
|
1037 | "text": [ | |
|
1038 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
1039 | ] | |
|
1040 | }, | |
|
1041 | { | |
|
1042 | "html": [ | |
|
1043 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\newcommand{\\tuple}[1]{\\langle #1 \\rangle}\n", | |
|
1044 | "\n", | |
|
1045 | "$\\tuple{a, b, c}$</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p><span class=\"math\">\\(\\langle a, b, c \\rangle\\)</span></p></div></div>" | |
|
1046 | ], | |
|
1047 | "metadata": {}, | |
|
1048 | "output_type": "display_data", | |
|
1049 | "text": [ | |
|
1050 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
1051 | ] | |
|
1052 | }, | |
|
1053 | { | |
|
1054 | "javascript": [ | |
|
1055 | "\n", | |
|
1056 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
1057 | ], | |
|
1058 | "metadata": {}, | |
|
1059 | "output_type": "display_data", | |
|
1060 | "text": [ | |
|
1061 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
1062 | ] | |
|
1063 | } | |
|
1064 | ], | |
|
1065 | "prompt_number": 12 | |
|
1066 | }, | |
|
1067 | { | |
|
1068 | "cell_type": "markdown", | |
|
1069 | "metadata": {}, | |
|
1070 | "source": [ | |
|
1071 | "When placing the \\newcommand inside a math environment it works within the notebook and nbviewer, but produces invalid latex (the newcommand is only valid in the same math environment)." | |
|
1072 | ] | |
|
1073 | }, | |
|
1074 | { | |
|
1075 | "cell_type": "code", | |
|
1076 | "collapsed": false, | |
|
1077 | "input": [ | |
|
1078 | "compare_render(r\"\"\"\n", | |
|
1079 | "$\\newcommand{\\foo}[1]{...:: #1 ::...}$\n", | |
|
1080 | "$\\foo{bar}$\n", | |
|
1081 | "\"\"\")" | |
|
1082 | ], | |
|
1083 | "language": "python", | |
|
1084 | "metadata": {}, | |
|
1085 | "outputs": [ | |
|
1086 | { | |
|
1087 | "javascript": [ | |
|
1088 | "\n", | |
|
1089 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1090 | "mdcell.create_element();\n", | |
|
1091 | "mdcell.set_text('\\n$\\\\newcommand{\\\\foo}[1]{...:: #1 ::...}$\\n$\\\\foo{bar}$\\n');\n", | |
|
1092 | "mdcell.render();\n", | |
|
1093 | "$(element).append(mdcell.element)\n", | |
|
1094 | ".removeClass()\n", | |
|
1095 | ".css('left', '66%')\n", | |
|
1096 | ".css('position', 'absolute')\n", | |
|
1097 | ".css('width', '30%')\n", | |
|
1098 | "mdcell.element.prepend(\n", | |
|
1099 | " $('<div />')\n", | |
|
1100 | " .removeClass()\n", | |
|
1101 | " .css('background', '#AAAAFF')\n", | |
|
1102 | " .css('width', '100 %')\n", | |
|
1103 | " .html('Notebook Output')\n", | |
|
1104 | "\n", | |
|
1105 | ");\n", | |
|
1106 | "container.show()\n" | |
|
1107 | ], | |
|
1108 | "metadata": {}, | |
|
1109 | "output_type": "display_data", | |
|
1110 | "text": [ | |
|
1111 | "<IPython.core.display.Javascript at 0x21ac590>" | |
|
1112 | ] | |
|
1113 | }, | |
|
1114 | { | |
|
1115 | "html": [ | |
|
1116 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>$\\newcommand{\\foo}[1]{...:: #1 ::...}$ $\\foo{bar}$</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p><span class=\"math\">\\(\\newcommand{\\foo}[1]{...:: #1 ::...}\\)</span> <span class=\"math\">\\(\\foo{bar}\\)</span></p></div></div>" | |
|
1117 | ], | |
|
1118 | "metadata": {}, | |
|
1119 | "output_type": "display_data", | |
|
1120 | "text": [ | |
|
1121 | "<IPython.core.display.HTML at 0x21ac590>" | |
|
1122 | ] | |
|
1123 | }, | |
|
1124 | { | |
|
1125 | "javascript": [ | |
|
1126 | "\n", | |
|
1127 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
1128 | ], | |
|
1129 | "metadata": {}, | |
|
1130 | "output_type": "display_data", | |
|
1131 | "text": [ | |
|
1132 | "<IPython.core.display.Javascript at 0x21ac590>" | |
|
1133 | ] | |
|
1134 | } | |
|
1135 | ], | |
|
1136 | "prompt_number": 13 | |
|
1137 | }, | |
|
1138 | { | |
|
1139 | "cell_type": "heading", | |
|
1140 | "level": 2, | |
|
1141 | "metadata": {}, | |
|
1142 | "source": [ | |
|
1143 | "HTML or LaTeX injections" | |
|
1144 | ] | |
|
1145 | }, | |
|
1146 | { | |
|
1147 | "cell_type": "markdown", | |
|
1148 | "metadata": {}, | |
|
1149 | "source": [ | |
|
1150 | "Raw HTML gets dropped entirely when converting to $\\LaTeX$." | |
|
1151 | ] | |
|
1152 | }, | |
|
1153 | { | |
|
1154 | "cell_type": "code", | |
|
1155 | "collapsed": false, | |
|
1156 | "input": [ | |
|
1157 | "compare_render(r\"\"\"\n", | |
|
1158 | "This is HTML <b>bold</b> and <i>italic</i> text.\n", | |
|
1159 | "\"\"\")" | |
|
1160 | ], | |
|
1161 | "language": "python", | |
|
1162 | "metadata": {}, | |
|
1163 | "outputs": [ | |
|
1164 | { | |
|
1165 | "javascript": [ | |
|
1166 | "\n", | |
|
1167 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1168 | "mdcell.create_element();\n", | |
|
1169 | "mdcell.set_text('\\nThis is HTML <b>bold</b> and <i>italic</i> text.\\n');\n", | |
|
1170 | "mdcell.render();\n", | |
|
1171 | "$(element).append(mdcell.element)\n", | |
|
1172 | ".removeClass()\n", | |
|
1173 | ".css('left', '66%')\n", | |
|
1174 | ".css('position', 'absolute')\n", | |
|
1175 | ".css('width', '30%')\n", | |
|
1176 | "mdcell.element.prepend(\n", | |
|
1177 | " $('<div />')\n", | |
|
1178 | " .removeClass()\n", | |
|
1179 | " .css('background', '#AAAAFF')\n", | |
|
1180 | " .css('width', '100 %')\n", | |
|
1181 | " .html('Notebook Output')\n", | |
|
1182 | "\n", | |
|
1183 | ");\n", | |
|
1184 | "container.show()\n" | |
|
1185 | ], | |
|
1186 | "metadata": {}, | |
|
1187 | "output_type": "display_data", | |
|
1188 | "text": [ | |
|
1189 | "<IPython.core.display.Javascript at 0x21ac5d0>" | |
|
1190 | ] | |
|
1191 | }, | |
|
1192 | { | |
|
1193 | "html": [ | |
|
1194 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>This is HTML bold and italic text.</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p>This is HTML <b>bold</b> and <i>italic</i> text.</p></div></div>" | |
|
1195 | ], | |
|
1196 | "metadata": {}, | |
|
1197 | "output_type": "display_data", | |
|
1198 | "text": [ | |
|
1199 | "<IPython.core.display.HTML at 0x21ac5d0>" | |
|
1200 | ] | |
|
1201 | }, | |
|
1202 | { | |
|
1203 | "javascript": [ | |
|
1204 | "\n", | |
|
1205 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
1206 | ], | |
|
1207 | "metadata": {}, | |
|
1208 | "output_type": "display_data", | |
|
1209 | "text": [ | |
|
1210 | "<IPython.core.display.Javascript at 0x21ac5d0>" | |
|
1211 | ] | |
|
1212 | } | |
|
1213 | ], | |
|
1214 | "prompt_number": 14 | |
|
1215 | }, | |
|
1216 | { | |
|
1217 | "cell_type": "markdown", | |
|
1218 | "metadata": {}, | |
|
1219 | "source": [ | |
|
1220 | "Same for something like center" | |
|
1221 | ] | |
|
1222 | }, | |
|
1223 | { | |
|
1224 | "cell_type": "code", | |
|
1225 | "collapsed": false, | |
|
1226 | "input": [ | |
|
1227 | "compare_render(r\"\"\"\n", | |
|
1228 | "<center>Center aligned</center>\n", | |
|
1229 | "\"\"\")" | |
|
1230 | ], | |
|
1231 | "language": "python", | |
|
1232 | "metadata": {}, | |
|
1233 | "outputs": [ | |
|
1234 | { | |
|
1235 | "javascript": [ | |
|
1236 | "\n", | |
|
1237 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1238 | "mdcell.create_element();\n", | |
|
1239 | "mdcell.set_text('\\n<center>Center aligned</center>\\n');\n", | |
|
1240 | "mdcell.render();\n", | |
|
1241 | "$(element).append(mdcell.element)\n", | |
|
1242 | ".removeClass()\n", | |
|
1243 | ".css('left', '66%')\n", | |
|
1244 | ".css('position', 'absolute')\n", | |
|
1245 | ".css('width', '30%')\n", | |
|
1246 | "mdcell.element.prepend(\n", | |
|
1247 | " $('<div />')\n", | |
|
1248 | " .removeClass()\n", | |
|
1249 | " .css('background', '#AAAAFF')\n", | |
|
1250 | " .css('width', '100 %')\n", | |
|
1251 | " .html('Notebook Output')\n", | |
|
1252 | "\n", | |
|
1253 | ");\n", | |
|
1254 | "container.show()\n" | |
|
1255 | ], | |
|
1256 | "metadata": {}, | |
|
1257 | "output_type": "display_data", | |
|
1258 | "text": [ | |
|
1259 | "<IPython.core.display.Javascript at 0x21ac210>" | |
|
1260 | ] | |
|
1261 | }, | |
|
1262 | { | |
|
1263 | "html": [ | |
|
1264 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>Center aligned</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><center>\n", | |
|
1265 | "Center aligned\n", | |
|
1266 | "</center></div></div>" | |
|
1267 | ], | |
|
1268 | "metadata": {}, | |
|
1269 | "output_type": "display_data", | |
|
1270 | "text": [ | |
|
1271 | "<IPython.core.display.HTML at 0x21ac210>" | |
|
1272 | ] | |
|
1273 | }, | |
|
1274 | { | |
|
1275 | "javascript": [ | |
|
1276 | "\n", | |
|
1277 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
1278 | ], | |
|
1279 | "metadata": {}, | |
|
1280 | "output_type": "display_data", | |
|
1281 | "text": [ | |
|
1282 | "<IPython.core.display.Javascript at 0x21ac210>" | |
|
1283 | ] | |
|
1284 | } | |
|
1285 | ], | |
|
1286 | "prompt_number": 15 | |
|
1287 | }, | |
|
1288 | { | |
|
1289 | "cell_type": "markdown", | |
|
1290 | "metadata": {}, | |
|
1291 | "source": [ | |
|
1292 | "Raw $\\LaTeX$ gets droppen entirely when converted to HTML. (I don't know why the HTML output is cropped here???)" | |
|
1293 | ] | |
|
1294 | }, | |
|
1295 | { | |
|
1296 | "cell_type": "code", | |
|
1297 | "collapsed": false, | |
|
1298 | "input": [ | |
|
1299 | "compare_render(r\"\"\"\n", | |
|
1300 | "This is \\LaTeX \\bf{bold} and \\emph{italic} text.\n", | |
|
1301 | "\"\"\")" | |
|
1302 | ], | |
|
1303 | "language": "python", | |
|
1304 | "metadata": {}, | |
|
1305 | "outputs": [ | |
|
1306 | { | |
|
1307 | "javascript": [ | |
|
1308 | "\n", | |
|
1309 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1310 | "mdcell.create_element();\n", | |
|
1311 | "mdcell.set_text('\\nThis is \\\\LaTeX \\\\bf{bold} and \\\\emph{italic} text.\\n');\n", | |
|
1312 | "mdcell.render();\n", | |
|
1313 | "$(element).append(mdcell.element)\n", | |
|
1314 | ".removeClass()\n", | |
|
1315 | ".css('left', '66%')\n", | |
|
1316 | ".css('position', 'absolute')\n", | |
|
1317 | ".css('width', '30%')\n", | |
|
1318 | "mdcell.element.prepend(\n", | |
|
1319 | " $('<div />')\n", | |
|
1320 | " .removeClass()\n", | |
|
1321 | " .css('background', '#AAAAFF')\n", | |
|
1322 | " .css('width', '100 %')\n", | |
|
1323 | " .html('Notebook Output')\n", | |
|
1324 | "\n", | |
|
1325 | ");\n", | |
|
1326 | "container.show()\n" | |
|
1327 | ], | |
|
1328 | "metadata": {}, | |
|
1329 | "output_type": "display_data", | |
|
1330 | "text": [ | |
|
1331 | "<IPython.core.display.Javascript at 0x21ac590>" | |
|
1332 | ] | |
|
1333 | }, | |
|
1334 | { | |
|
1335 | "html": [ | |
|
1336 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>This is \\LaTeX \\bf{bold} and \\emph{italic} text.</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p>This is </p></div></div>" | |
|
1337 | ], | |
|
1338 | "metadata": {}, | |
|
1339 | "output_type": "display_data", | |
|
1340 | "text": [ | |
|
1341 | "<IPython.core.display.HTML at 0x21ac590>" | |
|
1342 | ] | |
|
1343 | }, | |
|
1344 | { | |
|
1345 | "javascript": [ | |
|
1346 | "\n", | |
|
1347 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
1348 | ], | |
|
1349 | "metadata": {}, | |
|
1350 | "output_type": "display_data", | |
|
1351 | "text": [ | |
|
1352 | "<IPython.core.display.Javascript at 0x21ac590>" | |
|
1353 | ] | |
|
1354 | } | |
|
1355 | ], | |
|
1356 | "prompt_number": 16 | |
|
1357 | }, | |
|
1358 | { | |
|
1359 | "cell_type": "markdown", | |
|
1360 | "metadata": {}, | |
|
1361 | "source": [ | |
|
1362 | "A combination of raw $\\LaTeX$ and raw HTML" | |
|
1363 | ] | |
|
1364 | }, | |
|
1365 | { | |
|
1366 | "cell_type": "code", | |
|
1367 | "collapsed": false, | |
|
1368 | "input": [ | |
|
1369 | "compare_render(r\"\"\"\n", | |
|
1370 | "**foo** $\\left( \\sum_{k=1}^n a_k b_k \\right)^2 \\leq$ <b>b\\$ar</b> $$test$$ \n", | |
|
1371 | "\\cite{}\n", | |
|
1372 | "\"\"\")" | |
|
1373 | ], | |
|
1374 | "language": "python", | |
|
1375 | "metadata": {}, | |
|
1376 | "outputs": [ | |
|
1377 | { | |
|
1378 | "javascript": [ | |
|
1379 | "\n", | |
|
1380 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1381 | "mdcell.create_element();\n", | |
|
1382 | "mdcell.set_text('\\n**foo** $\\\\left( \\\\sum_{k=1}^n a_k b_k \\\\right)^2 \\\\leq$ <b>b\\\\$ar</b> $$test$$ \\n\\\\cite{}\\n');\n", | |
|
1383 | "mdcell.render();\n", | |
|
1384 | "$(element).append(mdcell.element)\n", | |
|
1385 | ".removeClass()\n", | |
|
1386 | ".css('left', '66%')\n", | |
|
1387 | ".css('position', 'absolute')\n", | |
|
1388 | ".css('width', '30%')\n", | |
|
1389 | "mdcell.element.prepend(\n", | |
|
1390 | " $('<div />')\n", | |
|
1391 | " .removeClass()\n", | |
|
1392 | " .css('background', '#AAAAFF')\n", | |
|
1393 | " .css('width', '100 %')\n", | |
|
1394 | " .html('Notebook Output')\n", | |
|
1395 | "\n", | |
|
1396 | ");\n", | |
|
1397 | "container.show()\n" | |
|
1398 | ], | |
|
1399 | "metadata": {}, | |
|
1400 | "output_type": "display_data", | |
|
1401 | "text": [ | |
|
1402 | "<IPython.core.display.Javascript at 0x21ac590>" | |
|
1403 | ] | |
|
1404 | }, | |
|
1405 | { | |
|
1406 | "html": [ | |
|
1407 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\textbf{foo} $\\left( \\sum_{k=1}^n a_k b_k \\right)^2 \\leq$ b\\$ar \\[test\\]\n", | |
|
1408 | "\\cite{}</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p><strong>foo</strong> <span class=\"math\">\\(\\left( \\sum_{k=1}^n a_k b_k \\right)^2 \\leq\\)</span> <b>b$ar</b> <span class=\"math\">\\[test\\]</span> </p></div></div>" | |
|
1409 | ], | |
|
1410 | "metadata": {}, | |
|
1411 | "output_type": "display_data", | |
|
1412 | "text": [ | |
|
1413 | "<IPython.core.display.HTML at 0x21ac590>" | |
|
1414 | ] | |
|
1415 | }, | |
|
1416 | { | |
|
1417 | "javascript": [ | |
|
1418 | "\n", | |
|
1419 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
1420 | ], | |
|
1421 | "metadata": {}, | |
|
1422 | "output_type": "display_data", | |
|
1423 | "text": [ | |
|
1424 | "<IPython.core.display.Javascript at 0x21ac590>" | |
|
1425 | ] | |
|
1426 | } | |
|
1427 | ], | |
|
1428 | "prompt_number": 17 | |
|
1429 | }, | |
|
1430 | { | |
|
1431 | "cell_type": "heading", | |
|
1432 | "level": 2, | |
|
1433 | "metadata": {}, | |
|
1434 | "source": [ | |
|
1435 | "Tables" | |
|
1436 | ] | |
|
1437 | }, | |
|
1438 | { | |
|
1439 | "cell_type": "markdown", | |
|
1440 | "metadata": {}, | |
|
1441 | "source": [ | |
|
1442 | "HTML tables render in the notebook, but not in Pandoc." | |
|
1443 | ] | |
|
1444 | }, | |
|
1445 | { | |
|
1446 | "cell_type": "code", | |
|
1447 | "collapsed": false, | |
|
1448 | "input": [ | |
|
1449 | "compare_render(r\"\"\"\n", | |
|
1450 | "<table>\n", | |
|
1451 | " <tr>\n", | |
|
1452 | " <td>a</td>\n", | |
|
1453 | " <td>b</td>\n", | |
|
1454 | " </tr>\n", | |
|
1455 | " <tr>\n", | |
|
1456 | " <td>c</td>\n", | |
|
1457 | " <td>d</td>\n", | |
|
1458 | " </tr>\n", | |
|
1459 | "</table>\n", | |
|
1460 | "\"\"\")" | |
|
1461 | ], | |
|
1462 | "language": "python", | |
|
1463 | "metadata": {}, | |
|
1464 | "outputs": [ | |
|
1465 | { | |
|
1466 | "javascript": [ | |
|
1467 | "\n", | |
|
1468 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1469 | "mdcell.create_element();\n", | |
|
1470 | "mdcell.set_text('\\n<table>\\n <tr>\\n <td>a</td>\\n <td>b</td>\\n </tr>\\n <tr>\\n <td>c</td>\\n <td>d</td>\\n </tr>\\n</table>\\n');\n", | |
|
1471 | "mdcell.render();\n", | |
|
1472 | "$(element).append(mdcell.element)\n", | |
|
1473 | ".removeClass()\n", | |
|
1474 | ".css('left', '66%')\n", | |
|
1475 | ".css('position', 'absolute')\n", | |
|
1476 | ".css('width', '30%')\n", | |
|
1477 | "mdcell.element.prepend(\n", | |
|
1478 | " $('<div />')\n", | |
|
1479 | " .removeClass()\n", | |
|
1480 | " .css('background', '#AAAAFF')\n", | |
|
1481 | " .css('width', '100 %')\n", | |
|
1482 | " .html('Notebook Output')\n", | |
|
1483 | "\n", | |
|
1484 | ");\n", | |
|
1485 | "container.show()\n" | |
|
1486 | ], | |
|
1487 | "metadata": {}, | |
|
1488 | "output_type": "display_data", | |
|
1489 | "text": [ | |
|
1490 | "<IPython.core.display.Javascript at 0x21ac5d0>" | |
|
1491 | ] | |
|
1492 | }, | |
|
1493 | { | |
|
1494 | "html": [ | |
|
1495 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>a\n", | |
|
1496 | "\n", | |
|
1497 | "b\n", | |
|
1498 | "\n", | |
|
1499 | "c\n", | |
|
1500 | "\n", | |
|
1501 | "d</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><table>\n", | |
|
1502 | " <tr>\n", | |
|
1503 | " <td>\n", | |
|
1504 | "a\n", | |
|
1505 | "</td>\n", | |
|
1506 | " <td>\n", | |
|
1507 | "b\n", | |
|
1508 | "</td>\n", | |
|
1509 | " </tr>\n", | |
|
1510 | " <tr>\n", | |
|
1511 | " <td>\n", | |
|
1512 | "c\n", | |
|
1513 | "</td>\n", | |
|
1514 | " <td>\n", | |
|
1515 | "d\n", | |
|
1516 | "</td>\n", | |
|
1517 | " </tr>\n", | |
|
1518 | "</table></div></div>" | |
|
1519 | ], | |
|
1520 | "metadata": {}, | |
|
1521 | "output_type": "display_data", | |
|
1522 | "text": [ | |
|
1523 | "<IPython.core.display.HTML at 0x21ac5d0>" | |
|
1524 | ] | |
|
1525 | }, | |
|
1526 | { | |
|
1527 | "javascript": [ | |
|
1528 | "\n", | |
|
1529 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
1530 | ], | |
|
1531 | "metadata": {}, | |
|
1532 | "output_type": "display_data", | |
|
1533 | "text": [ | |
|
1534 | "<IPython.core.display.Javascript at 0x21ac5d0>" | |
|
1535 | ] | |
|
1536 | } | |
|
1537 | ], | |
|
1538 | "prompt_number": 18 | |
|
1539 | }, | |
|
1540 | { | |
|
1541 | "cell_type": "markdown", | |
|
1542 | "metadata": {}, | |
|
1543 | "source": [ | |
|
1544 | "Instead, Pandoc supports simple ascii tables. Unfortunately marked.js doesn't support this, and therefore it is not supported in the notebook." | |
|
1545 | ] | |
|
1546 | }, | |
|
1547 | { | |
|
1548 | "cell_type": "code", | |
|
1549 | "collapsed": false, | |
|
1550 | "input": [ | |
|
1551 | "compare_render(r\"\"\"\n", | |
|
1552 | "+---+---+\n", | |
|
1553 | "| a | b |\n", | |
|
1554 | "+---+---+\n", | |
|
1555 | "| c | d |\n", | |
|
1556 | "+---+---+\n", | |
|
1557 | "\"\"\")" | |
|
1558 | ], | |
|
1559 | "language": "python", | |
|
1560 | "metadata": {}, | |
|
1561 | "outputs": [ | |
|
1562 | { | |
|
1563 | "javascript": [ | |
|
1564 | "\n", | |
|
1565 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1566 | "mdcell.create_element();\n", | |
|
1567 | "mdcell.set_text('\\n+---+---+\\n| a | b |\\n+---+---+\\n| c | d |\\n+---+---+\\n');\n", | |
|
1568 | "mdcell.render();\n", | |
|
1569 | "$(element).append(mdcell.element)\n", | |
|
1570 | ".removeClass()\n", | |
|
1571 | ".css('left', '66%')\n", | |
|
1572 | ".css('position', 'absolute')\n", | |
|
1573 | ".css('width', '30%')\n", | |
|
1574 | "mdcell.element.prepend(\n", | |
|
1575 | " $('<div />')\n", | |
|
1576 | " .removeClass()\n", | |
|
1577 | " .css('background', '#AAAAFF')\n", | |
|
1578 | " .css('width', '100 %')\n", | |
|
1579 | " .html('Notebook Output')\n", | |
|
1580 | "\n", | |
|
1581 | ");\n", | |
|
1582 | "container.show()\n" | |
|
1583 | ], | |
|
1584 | "metadata": {}, | |
|
1585 | "output_type": "display_data", | |
|
1586 | "text": [ | |
|
1587 | "<IPython.core.display.Javascript at 0x21ac210>" | |
|
1588 | ] | |
|
1589 | }, | |
|
1590 | { | |
|
1591 | "html": [ | |
|
1592 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\begin{longtable}[c]{@{}ll@{}}\n", | |
|
1593 | "\\hline\\noalign{\\medskip}\n", | |
|
1594 | "\\begin{minipage}[t]{0.06\\columnwidth}\\raggedright\n", | |
|
1595 | "a\n", | |
|
1596 | "\\end{minipage} & \\begin{minipage}[t]{0.06\\columnwidth}\\raggedright\n", | |
|
1597 | "b\n", | |
|
1598 | "\\end{minipage}\n", | |
|
1599 | "\\\\\\noalign{\\medskip}\n", | |
|
1600 | "\\begin{minipage}[t]{0.06\\columnwidth}\\raggedright\n", | |
|
1601 | "c\n", | |
|
1602 | "\\end{minipage} & \\begin{minipage}[t]{0.06\\columnwidth}\\raggedright\n", | |
|
1603 | "d\n", | |
|
1604 | "\\end{minipage}\n", | |
|
1605 | "\\\\\\noalign{\\medskip}\n", | |
|
1606 | "\\hline\n", | |
|
1607 | "\\end{longtable}</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><table>\n", | |
|
1608 | "<col width=\"5%\" />\n", | |
|
1609 | "<col width=\"5%\" />\n", | |
|
1610 | "<tbody>\n", | |
|
1611 | "<tr class=\"odd\">\n", | |
|
1612 | "<td align=\"left\"><p>a</p></td>\n", | |
|
1613 | "<td align=\"left\"><p>b</p></td>\n", | |
|
1614 | "</tr>\n", | |
|
1615 | "<tr class=\"even\">\n", | |
|
1616 | "<td align=\"left\"><p>c</p></td>\n", | |
|
1617 | "<td align=\"left\"><p>d</p></td>\n", | |
|
1618 | "</tr>\n", | |
|
1619 | "</tbody>\n", | |
|
1620 | "</table></div></div>" | |
|
1621 | ], | |
|
1622 | "metadata": {}, | |
|
1623 | "output_type": "display_data", | |
|
1624 | "text": [ | |
|
1625 | "<IPython.core.display.HTML at 0x21ac210>" | |
|
1626 | ] | |
|
1627 | }, | |
|
1628 | { | |
|
1629 | "javascript": [ | |
|
1630 | "\n", | |
|
1631 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
1632 | ], | |
|
1633 | "metadata": {}, | |
|
1634 | "output_type": "display_data", | |
|
1635 | "text": [ | |
|
1636 | "<IPython.core.display.Javascript at 0x21ac210>" | |
|
1637 | ] | |
|
1638 | } | |
|
1639 | ], | |
|
1640 | "prompt_number": 19 | |
|
1641 | }, | |
|
1642 | { | |
|
1643 | "cell_type": "markdown", | |
|
1644 | "metadata": {}, | |
|
1645 | "source": [ | |
|
1646 | "An alternative to basic ascii tables is pipe tables. Pipe tables can be recognized by Pandoc and are supported by marked, hence, this is the **best way to add tables**." | |
|
1647 | ] | |
|
1648 | }, | |
|
1649 | { | |
|
1650 | "cell_type": "code", | |
|
1651 | "collapsed": false, | |
|
1652 | "input": [ | |
|
1653 | "compare_render(r\"\"\"\n", | |
|
1654 | "|Left |Center |Right|\n", | |
|
1655 | "|:----|:-----:|----:|\n", | |
|
1656 | "|Text1|Text2 |Text3|\n", | |
|
1657 | "\"\"\")" | |
|
1658 | ], | |
|
1659 | "language": "python", | |
|
1660 | "metadata": {}, | |
|
1661 | "outputs": [ | |
|
1662 | { | |
|
1663 | "javascript": [ | |
|
1664 | "\n", | |
|
1665 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1666 | "mdcell.create_element();\n", | |
|
1667 | "mdcell.set_text('\\n|Left |Center |Right|\\n|:----|:-----:|----:|\\n|Text1|Text2 |Text3|\\n');\n", | |
|
1668 | "mdcell.render();\n", | |
|
1669 | "$(element).append(mdcell.element)\n", | |
|
1670 | ".removeClass()\n", | |
|
1671 | ".css('left', '66%')\n", | |
|
1672 | ".css('position', 'absolute')\n", | |
|
1673 | ".css('width', '30%')\n", | |
|
1674 | "mdcell.element.prepend(\n", | |
|
1675 | " $('<div />')\n", | |
|
1676 | " .removeClass()\n", | |
|
1677 | " .css('background', '#AAAAFF')\n", | |
|
1678 | " .css('width', '100 %')\n", | |
|
1679 | " .html('Notebook Output')\n", | |
|
1680 | "\n", | |
|
1681 | ");\n", | |
|
1682 | "container.show()\n" | |
|
1683 | ], | |
|
1684 | "metadata": {}, | |
|
1685 | "output_type": "display_data", | |
|
1686 | "text": [ | |
|
1687 | "<IPython.core.display.Javascript at 0x21ac150>" | |
|
1688 | ] | |
|
1689 | }, | |
|
1690 | { | |
|
1691 | "html": [ | |
|
1692 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\begin{longtable}[c]{@{}lcr@{}}\n", | |
|
1693 | "\\hline\\noalign{\\medskip}\n", | |
|
1694 | "Left & Center & Right\n", | |
|
1695 | "\\\\\\noalign{\\medskip}\n", | |
|
1696 | "\\hline\\noalign{\\medskip}\n", | |
|
1697 | "Text1 & Text2 & Text3\n", | |
|
1698 | "\\\\\\noalign{\\medskip}\n", | |
|
1699 | "\\hline\n", | |
|
1700 | "\\end{longtable}</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><table>\n", | |
|
1701 | "<thead>\n", | |
|
1702 | "<tr class=\"header\">\n", | |
|
1703 | "<th align=\"left\">Left</th>\n", | |
|
1704 | "<th align=\"center\">Center</th>\n", | |
|
1705 | "<th align=\"right\">Right</th>\n", | |
|
1706 | "</tr>\n", | |
|
1707 | "</thead>\n", | |
|
1708 | "<tbody>\n", | |
|
1709 | "<tr class=\"odd\">\n", | |
|
1710 | "<td align=\"left\">Text1</td>\n", | |
|
1711 | "<td align=\"center\">Text2</td>\n", | |
|
1712 | "<td align=\"right\">Text3</td>\n", | |
|
1713 | "</tr>\n", | |
|
1714 | "</tbody>\n", | |
|
1715 | "</table></div></div>" | |
|
1716 | ], | |
|
1717 | "metadata": {}, | |
|
1718 | "output_type": "display_data", | |
|
1719 | "text": [ | |
|
1720 | "<IPython.core.display.HTML at 0x21ac150>" | |
|
1721 | ] | |
|
1722 | }, | |
|
1723 | { | |
|
1724 | "javascript": [ | |
|
1725 | "\n", | |
|
1726 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
1727 | ], | |
|
1728 | "metadata": {}, | |
|
1729 | "output_type": "display_data", | |
|
1730 | "text": [ | |
|
1731 | "<IPython.core.display.Javascript at 0x21ac150>" | |
|
1732 | ] | |
|
1733 | } | |
|
1734 | ], | |
|
1735 | "prompt_number": 20 | |
|
1736 | }, | |
|
1737 | { | |
|
1738 | "cell_type": "markdown", | |
|
1739 | "metadata": {}, | |
|
1740 | "source": [ | |
|
1741 | "Pandoc recognizes cell alignment in simple tables. Since marked.js doesn't recognize ascii tables, it can't render this table." | |
|
1742 | ] | |
|
1743 | }, | |
|
1744 | { | |
|
1745 | "cell_type": "code", | |
|
1746 | "collapsed": false, | |
|
1747 | "input": [ | |
|
1748 | "compare_render(r\"\"\"\n", | |
|
1749 | "Right Aligned Center Aligned Left Aligned\n", | |
|
1750 | "------------- -------------- ------------\n", | |
|
1751 | " Why does this\n", | |
|
1752 | " actually work? Who\n", | |
|
1753 | " knows ...\n", | |
|
1754 | "\"\"\")\n", | |
|
1755 | "\n", | |
|
1756 | "print(\"\\n\"*5)" | |
|
1757 | ], | |
|
1758 | "language": "python", | |
|
1759 | "metadata": {}, | |
|
1760 | "outputs": [ | |
|
1761 | { | |
|
1762 | "javascript": [ | |
|
1763 | "\n", | |
|
1764 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1765 | "mdcell.create_element();\n", | |
|
1766 | "mdcell.set_text('\\nRight Aligned Center Aligned Left Aligned\\n------------- -------------- ------------\\n Why does this\\n actually work? Who\\n knows ...\\n');\n", | |
|
1767 | "mdcell.render();\n", | |
|
1768 | "$(element).append(mdcell.element)\n", | |
|
1769 | ".removeClass()\n", | |
|
1770 | ".css('left', '66%')\n", | |
|
1771 | ".css('position', 'absolute')\n", | |
|
1772 | ".css('width', '30%')\n", | |
|
1773 | "mdcell.element.prepend(\n", | |
|
1774 | " $('<div />')\n", | |
|
1775 | " .removeClass()\n", | |
|
1776 | " .css('background', '#AAAAFF')\n", | |
|
1777 | " .css('width', '100 %')\n", | |
|
1778 | " .html('Notebook Output')\n", | |
|
1779 | "\n", | |
|
1780 | ");\n", | |
|
1781 | "container.show()\n" | |
|
1782 | ], | |
|
1783 | "metadata": {}, | |
|
1784 | "output_type": "display_data", | |
|
1785 | "text": [ | |
|
1786 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
1787 | ] | |
|
1788 | }, | |
|
1789 | { | |
|
1790 | "html": [ | |
|
1791 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\begin{longtable}[c]{@{}lll@{}}\n", | |
|
1792 | "\\hline\\noalign{\\medskip}\n", | |
|
1793 | "Right Aligned & Center Aligned & Left Aligned\n", | |
|
1794 | "\\\\\\noalign{\\medskip}\n", | |
|
1795 | "\\hline\\noalign{\\medskip}\n", | |
|
1796 | "Why & does & this\n", | |
|
1797 | "\\\\\\noalign{\\medskip}\n", | |
|
1798 | "actually & work? & Who\n", | |
|
1799 | "\\\\\\noalign{\\medskip}\n", | |
|
1800 | "knows & \\ldots{} &\n", | |
|
1801 | "\\\\\\noalign{\\medskip}\n", | |
|
1802 | "\\hline\n", | |
|
1803 | "\\end{longtable}</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><table>\n", | |
|
1804 | "<thead>\n", | |
|
1805 | "<tr class=\"header\">\n", | |
|
1806 | "<th align=\"left\">Right Aligned</th>\n", | |
|
1807 | "<th align=\"left\">Center Aligned</th>\n", | |
|
1808 | "<th align=\"left\">Left Aligned</th>\n", | |
|
1809 | "</tr>\n", | |
|
1810 | "</thead>\n", | |
|
1811 | "<tbody>\n", | |
|
1812 | "<tr class=\"odd\">\n", | |
|
1813 | "<td align=\"left\">Why</td>\n", | |
|
1814 | "<td align=\"left\">does</td>\n", | |
|
1815 | "<td align=\"left\">this</td>\n", | |
|
1816 | "</tr>\n", | |
|
1817 | "<tr class=\"even\">\n", | |
|
1818 | "<td align=\"left\">actually</td>\n", | |
|
1819 | "<td align=\"left\">work?</td>\n", | |
|
1820 | "<td align=\"left\">Who</td>\n", | |
|
1821 | "</tr>\n", | |
|
1822 | "<tr class=\"odd\">\n", | |
|
1823 | "<td align=\"left\">knows</td>\n", | |
|
1824 | "<td align=\"left\">...</td>\n", | |
|
1825 | "<td align=\"left\"></td>\n", | |
|
1826 | "</tr>\n", | |
|
1827 | "</tbody>\n", | |
|
1828 | "</table></div></div>" | |
|
1829 | ], | |
|
1830 | "metadata": {}, | |
|
1831 | "output_type": "display_data", | |
|
1832 | "text": [ | |
|
1833 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
1834 | ] | |
|
1835 | }, | |
|
1836 | { | |
|
1837 | "javascript": [ | |
|
1838 | "\n", | |
|
1839 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
1840 | ], | |
|
1841 | "metadata": {}, | |
|
1842 | "output_type": "display_data", | |
|
1843 | "text": [ | |
|
1844 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
1845 | ] | |
|
1846 | }, | |
|
1847 | { | |
|
1848 | "output_type": "stream", | |
|
1849 | "stream": "stdout", | |
|
1850 | "text": [ | |
|
1851 | "\n", | |
|
1852 | "\n", | |
|
1853 | "\n", | |
|
1854 | "\n", | |
|
1855 | "\n", | |
|
1856 | "\n" | |
|
1857 | ] | |
|
1858 | } | |
|
1859 | ], | |
|
1860 | "prompt_number": 21 | |
|
1861 | }, | |
|
1862 | { | |
|
1863 | "cell_type": "heading", | |
|
1864 | "level": 2, | |
|
1865 | "metadata": {}, | |
|
1866 | "source": [ | |
|
1867 | "Images" | |
|
1868 | ] | |
|
1869 | }, | |
|
1870 | { | |
|
1871 | "cell_type": "markdown", | |
|
1872 | "metadata": {}, | |
|
1873 | "source": [ | |
|
1874 | "Markdown images work on both. However, remote images are not allowed in $\\LaTeX$. Maybe add a preprocessor to download these.\n", | |
|
1875 | "The alternate text is displayed in nbviewer next to the image." | |
|
1876 | ] | |
|
1877 | }, | |
|
1878 | { | |
|
1879 | "cell_type": "code", | |
|
1880 | "collapsed": false, | |
|
1881 | "input": [ | |
|
1882 | "compare_render(r\"\"\"\n", | |
|
1883 | "![Alternate Text](http://ipython.org/_static/IPy_header.png)\n", | |
|
1884 | "\"\"\")" | |
|
1885 | ], | |
|
1886 | "language": "python", | |
|
1887 | "metadata": {}, | |
|
1888 | "outputs": [ | |
|
1889 | { | |
|
1890 | "javascript": [ | |
|
1891 | "\n", | |
|
1892 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1893 | "mdcell.create_element();\n", | |
|
1894 | "mdcell.set_text('\\n![Alternate Text](http://ipython.org/_static/IPy_header.png)\\n');\n", | |
|
1895 | "mdcell.render();\n", | |
|
1896 | "$(element).append(mdcell.element)\n", | |
|
1897 | ".removeClass()\n", | |
|
1898 | ".css('left', '66%')\n", | |
|
1899 | ".css('position', 'absolute')\n", | |
|
1900 | ".css('width', '30%')\n", | |
|
1901 | "mdcell.element.prepend(\n", | |
|
1902 | " $('<div />')\n", | |
|
1903 | " .removeClass()\n", | |
|
1904 | " .css('background', '#AAAAFF')\n", | |
|
1905 | " .css('width', '100 %')\n", | |
|
1906 | " .html('Notebook Output')\n", | |
|
1907 | "\n", | |
|
1908 | ");\n", | |
|
1909 | "container.show()\n" | |
|
1910 | ], | |
|
1911 | "metadata": {}, | |
|
1912 | "output_type": "display_data", | |
|
1913 | "text": [ | |
|
1914 | "<IPython.core.display.Javascript at 0x22b6690>" | |
|
1915 | ] | |
|
1916 | }, | |
|
1917 | { | |
|
1918 | "html": [ | |
|
1919 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\begin{figure}[htbp]\n", | |
|
1920 | "\\centering\n", | |
|
1921 | "\\includegraphics{http://ipython.org/_static/IPy_header.png}\n", | |
|
1922 | "\\caption{Alternate Text}\n", | |
|
1923 | "\\end{figure}</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><div class=\"figure\">\n", | |
|
1924 | "<img src=\"http://ipython.org/_static/IPy_header.png\" alt=\"Alternate Text\" /><p class=\"caption\">Alternate Text</p>\n", | |
|
1925 | "</div></div></div>" | |
|
1926 | ], | |
|
1927 | "metadata": {}, | |
|
1928 | "output_type": "display_data", | |
|
1929 | "text": [ | |
|
1930 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
1931 | ] | |
|
1932 | }, | |
|
1933 | { | |
|
1934 | "javascript": [ | |
|
1935 | "\n", | |
|
1936 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
1937 | ], | |
|
1938 | "metadata": {}, | |
|
1939 | "output_type": "display_data", | |
|
1940 | "text": [ | |
|
1941 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
1942 | ] | |
|
1943 | } | |
|
1944 | ], | |
|
1945 | "prompt_number": 22 | |
|
1946 | }, | |
|
1947 | { | |
|
1948 | "cell_type": "markdown", | |
|
1949 | "metadata": {}, | |
|
1950 | "source": [ | |
|
1951 | "HTML Images only work in the notebook." | |
|
1952 | ] | |
|
1953 | }, | |
|
1954 | { | |
|
1955 | "cell_type": "code", | |
|
1956 | "collapsed": false, | |
|
1957 | "input": [ | |
|
1958 | "compare_render(r\"\"\"\n", | |
|
1959 | "<img src=\"http://ipython.org/_static/IPy_header.png\">\n", | |
|
1960 | "\"\"\")" | |
|
1961 | ], | |
|
1962 | "language": "python", | |
|
1963 | "metadata": {}, | |
|
1964 | "outputs": [ | |
|
1965 | { | |
|
1966 | "javascript": [ | |
|
1967 | "\n", | |
|
1968 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
1969 | "mdcell.create_element();\n", | |
|
1970 | "mdcell.set_text('\\n<img src=\"http://ipython.org/_static/IPy_header.png\">\\n');\n", | |
|
1971 | "mdcell.render();\n", | |
|
1972 | "$(element).append(mdcell.element)\n", | |
|
1973 | ".removeClass()\n", | |
|
1974 | ".css('left', '66%')\n", | |
|
1975 | ".css('position', 'absolute')\n", | |
|
1976 | ".css('width', '30%')\n", | |
|
1977 | "mdcell.element.prepend(\n", | |
|
1978 | " $('<div />')\n", | |
|
1979 | " .removeClass()\n", | |
|
1980 | " .css('background', '#AAAAFF')\n", | |
|
1981 | " .css('width', '100 %')\n", | |
|
1982 | " .html('Notebook Output')\n", | |
|
1983 | "\n", | |
|
1984 | ");\n", | |
|
1985 | "container.show()\n" | |
|
1986 | ], | |
|
1987 | "metadata": {}, | |
|
1988 | "output_type": "display_data", | |
|
1989 | "text": [ | |
|
1990 | "<IPython.core.display.Javascript at 0x22b65d0>" | |
|
1991 | ] | |
|
1992 | }, | |
|
1993 | { | |
|
1994 | "html": [ | |
|
1995 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp></xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p><img src=\"http://ipython.org/_static/IPy_header.png\"></p></div></div>" | |
|
1996 | ], | |
|
1997 | "metadata": {}, | |
|
1998 | "output_type": "display_data", | |
|
1999 | "text": [ | |
|
2000 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
2001 | ] | |
|
2002 | }, | |
|
2003 | { | |
|
2004 | "javascript": [ | |
|
2005 | "\n", | |
|
2006 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
2007 | ], | |
|
2008 | "metadata": {}, | |
|
2009 | "output_type": "display_data", | |
|
2010 | "text": [ | |
|
2011 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
2012 | ] | |
|
2013 | } | |
|
2014 | ], | |
|
2015 | "prompt_number": 23 | |
|
2016 | }, | |
|
2017 | { | |
|
2018 | "cell_type": "heading", | |
|
2019 | "level": 2, | |
|
2020 | "metadata": {}, | |
|
2021 | "source": [ | |
|
2022 | "Math" | |
|
2023 | ] | |
|
2024 | }, | |
|
2025 | { | |
|
2026 | "cell_type": "markdown", | |
|
2027 | "metadata": {}, | |
|
2028 | "source": [ | |
|
2029 | "Simple inline and displaystyle maths work fine" | |
|
2030 | ] | |
|
2031 | }, | |
|
2032 | { | |
|
2033 | "cell_type": "code", | |
|
2034 | "collapsed": false, | |
|
2035 | "input": [ | |
|
2036 | "compare_render(r\"\"\"\n", | |
|
2037 | "My equation:\n", | |
|
2038 | "$$ 5/x=2y $$\n", | |
|
2039 | "\n", | |
|
2040 | "It is inline $ 5/x=2y $ here.\n", | |
|
2041 | "\"\"\")" | |
|
2042 | ], | |
|
2043 | "language": "python", | |
|
2044 | "metadata": {}, | |
|
2045 | "outputs": [ | |
|
2046 | { | |
|
2047 | "javascript": [ | |
|
2048 | "\n", | |
|
2049 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
2050 | "mdcell.create_element();\n", | |
|
2051 | "mdcell.set_text('\\nMy equation:\\n$$ 5/x=2y $$\\n\\nIt is inline $ 5/x=2y $ here.\\n');\n", | |
|
2052 | "mdcell.render();\n", | |
|
2053 | "$(element).append(mdcell.element)\n", | |
|
2054 | ".removeClass()\n", | |
|
2055 | ".css('left', '66%')\n", | |
|
2056 | ".css('position', 'absolute')\n", | |
|
2057 | ".css('width', '30%')\n", | |
|
2058 | "mdcell.element.prepend(\n", | |
|
2059 | " $('<div />')\n", | |
|
2060 | " .removeClass()\n", | |
|
2061 | " .css('background', '#AAAAFF')\n", | |
|
2062 | " .css('width', '100 %')\n", | |
|
2063 | " .html('Notebook Output')\n", | |
|
2064 | "\n", | |
|
2065 | ");\n", | |
|
2066 | "container.show()\n" | |
|
2067 | ], | |
|
2068 | "metadata": {}, | |
|
2069 | "output_type": "display_data", | |
|
2070 | "text": [ | |
|
2071 | "<IPython.core.display.Javascript at 0x22b6950>" | |
|
2072 | ] | |
|
2073 | }, | |
|
2074 | { | |
|
2075 | "html": [ | |
|
2076 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>My equation: \\[ 5/x=2y \\]\n", | |
|
2077 | "\n", | |
|
2078 | "It is inline \\$ 5/x=2y \\$ here.</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p>My equation: <span class=\"math\">\\[ 5/x=2y \\]</span></p>\n", | |
|
2079 | "<p>It is inline $ 5/x=2y $ here.</p></div></div>" | |
|
2080 | ], | |
|
2081 | "metadata": {}, | |
|
2082 | "output_type": "display_data", | |
|
2083 | "text": [ | |
|
2084 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
2085 | ] | |
|
2086 | }, | |
|
2087 | { | |
|
2088 | "javascript": [ | |
|
2089 | "\n", | |
|
2090 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
2091 | ], | |
|
2092 | "metadata": {}, | |
|
2093 | "output_type": "display_data", | |
|
2094 | "text": [ | |
|
2095 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
2096 | ] | |
|
2097 | } | |
|
2098 | ], | |
|
2099 | "prompt_number": 24 | |
|
2100 | }, | |
|
2101 | { | |
|
2102 | "cell_type": "markdown", | |
|
2103 | "metadata": {}, | |
|
2104 | "source": [ | |
|
2105 | "If the first \\$ is on a new line, the equation is not captured by md2tex, if both \\$s are on a new line md2html fails (Note the raw latex is dropped) but the notebook renders it correctly." | |
|
2106 | ] | |
|
2107 | }, | |
|
2108 | { | |
|
2109 | "cell_type": "code", | |
|
2110 | "collapsed": false, | |
|
2111 | "input": [ | |
|
2112 | "compare_render(r\"\"\"\n", | |
|
2113 | "$5 \\cdot x=2$\n", | |
|
2114 | "\n", | |
|
2115 | "$\n", | |
|
2116 | "5 \\cdot x=2$\n", | |
|
2117 | "\n", | |
|
2118 | "$\n", | |
|
2119 | "5 \\cdot x=2\n", | |
|
2120 | "$\n", | |
|
2121 | "\"\"\")" | |
|
2122 | ], | |
|
2123 | "language": "python", | |
|
2124 | "metadata": {}, | |
|
2125 | "outputs": [ | |
|
2126 | { | |
|
2127 | "javascript": [ | |
|
2128 | "\n", | |
|
2129 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
2130 | "mdcell.create_element();\n", | |
|
2131 | "mdcell.set_text('\\n$5 \\\\cdot x=2$\\n\\n$\\n5 \\\\cdot x=2$\\n\\n$\\n5 \\\\cdot x=2\\n$\\n');\n", | |
|
2132 | "mdcell.render();\n", | |
|
2133 | "$(element).append(mdcell.element)\n", | |
|
2134 | ".removeClass()\n", | |
|
2135 | ".css('left', '66%')\n", | |
|
2136 | ".css('position', 'absolute')\n", | |
|
2137 | ".css('width', '30%')\n", | |
|
2138 | "mdcell.element.prepend(\n", | |
|
2139 | " $('<div />')\n", | |
|
2140 | " .removeClass()\n", | |
|
2141 | " .css('background', '#AAAAFF')\n", | |
|
2142 | " .css('width', '100 %')\n", | |
|
2143 | " .html('Notebook Output')\n", | |
|
2144 | "\n", | |
|
2145 | ");\n", | |
|
2146 | "container.show()\n" | |
|
2147 | ], | |
|
2148 | "metadata": {}, | |
|
2149 | "output_type": "display_data", | |
|
2150 | "text": [ | |
|
2151 | "<IPython.core.display.Javascript at 0x22b66d0>" | |
|
2152 | ] | |
|
2153 | }, | |
|
2154 | { | |
|
2155 | "html": [ | |
|
2156 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>$5 \\cdot x=2$\n", | |
|
2157 | "\n", | |
|
2158 | "\\$ 5 \\cdot x=2\\$\n", | |
|
2159 | "\n", | |
|
2160 | "\\$ 5 \\cdot x=2 \\$</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p><span class=\"math\">\\(5 \\cdot x=2\\)</span></p>\n", | |
|
2161 | "<p>$ 5 x=2$</p>\n", | |
|
2162 | "<p>$ 5 x=2 $</p></div></div>" | |
|
2163 | ], | |
|
2164 | "metadata": {}, | |
|
2165 | "output_type": "display_data", | |
|
2166 | "text": [ | |
|
2167 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
2168 | ] | |
|
2169 | }, | |
|
2170 | { | |
|
2171 | "javascript": [ | |
|
2172 | "\n", | |
|
2173 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
2174 | ], | |
|
2175 | "metadata": {}, | |
|
2176 | "output_type": "display_data", | |
|
2177 | "text": [ | |
|
2178 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
2179 | ] | |
|
2180 | } | |
|
2181 | ], | |
|
2182 | "prompt_number": 25 | |
|
2183 | }, | |
|
2184 | { | |
|
2185 | "cell_type": "markdown", | |
|
2186 | "metadata": {}, | |
|
2187 | "source": [ | |
|
2188 | "MathJax permits some $\\LaTeX$ math constructs without \\$s, of course these raw $\\LaTeX$ is stripped when converting to html.\n", | |
|
2189 | "Moreove, the & are escaped by the lxml parsing [#4251](https://github.com/ipython/ipython/issues/4251)." | |
|
2190 | ] | |
|
2191 | }, | |
|
2192 | { | |
|
2193 | "cell_type": "code", | |
|
2194 | "collapsed": false, | |
|
2195 | "input": [ | |
|
2196 | "compare_render(r\"\"\"\n", | |
|
2197 | "\\begin{align}\n", | |
|
2198 | "a & b\\\\\n", | |
|
2199 | "d & c\n", | |
|
2200 | "\\end{align}\n", | |
|
2201 | "\n", | |
|
2202 | "\\begin{eqnarray}\n", | |
|
2203 | "a & b \\\\\n", | |
|
2204 | "c & d\n", | |
|
2205 | "\\end{eqnarray}\n", | |
|
2206 | "\"\"\")" | |
|
2207 | ], | |
|
2208 | "language": "python", | |
|
2209 | "metadata": {}, | |
|
2210 | "outputs": [ | |
|
2211 | { | |
|
2212 | "javascript": [ | |
|
2213 | "\n", | |
|
2214 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
2215 | "mdcell.create_element();\n", | |
|
2216 | "mdcell.set_text('\\n\\\\begin{align}\\na & b\\\\\\\\\\nd & c\\n\\\\end{align}\\n\\n\\\\begin{eqnarray}\\na & b \\\\\\\\\\nc & d\\n\\\\end{eqnarray}\\n');\n", | |
|
2217 | "mdcell.render();\n", | |
|
2218 | "$(element).append(mdcell.element)\n", | |
|
2219 | ".removeClass()\n", | |
|
2220 | ".css('left', '66%')\n", | |
|
2221 | ".css('position', 'absolute')\n", | |
|
2222 | ".css('width', '30%')\n", | |
|
2223 | "mdcell.element.prepend(\n", | |
|
2224 | " $('<div />')\n", | |
|
2225 | " .removeClass()\n", | |
|
2226 | " .css('background', '#AAAAFF')\n", | |
|
2227 | " .css('width', '100 %')\n", | |
|
2228 | " .html('Notebook Output')\n", | |
|
2229 | "\n", | |
|
2230 | ");\n", | |
|
2231 | "container.show()\n" | |
|
2232 | ], | |
|
2233 | "metadata": {}, | |
|
2234 | "output_type": "display_data", | |
|
2235 | "text": [ | |
|
2236 | "<IPython.core.display.Javascript at 0x22b6690>" | |
|
2237 | ] | |
|
2238 | }, | |
|
2239 | { | |
|
2240 | "html": [ | |
|
2241 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>\\begin{align}\n", | |
|
2242 | "a & b\\\\\n", | |
|
2243 | "d & c\n", | |
|
2244 | "\\end{align}\n", | |
|
2245 | "\n", | |
|
2246 | "\\begin{eqnarray}\n", | |
|
2247 | "a & b \\\\\n", | |
|
2248 | "c & d\n", | |
|
2249 | "\\end{eqnarray}</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'></div></div>" | |
|
2250 | ], | |
|
2251 | "metadata": {}, | |
|
2252 | "output_type": "display_data", | |
|
2253 | "text": [ | |
|
2254 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
2255 | ] | |
|
2256 | }, | |
|
2257 | { | |
|
2258 | "javascript": [ | |
|
2259 | "\n", | |
|
2260 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
2261 | ], | |
|
2262 | "metadata": {}, | |
|
2263 | "output_type": "display_data", | |
|
2264 | "text": [ | |
|
2265 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
2266 | ] | |
|
2267 | } | |
|
2268 | ], | |
|
2269 | "prompt_number": 26 | |
|
2270 | }, | |
|
2271 | { | |
|
2272 | "cell_type": "markdown", | |
|
2273 | "metadata": {}, | |
|
2274 | "source": [ | |
|
2275 | "There is another lxml issue, [#4283](https://github.com/ipython/ipython/issues/4283)" | |
|
2276 | ] | |
|
2277 | }, | |
|
2278 | { | |
|
2279 | "cell_type": "code", | |
|
2280 | "collapsed": false, | |
|
2281 | "input": [ | |
|
2282 | "compare_render(r\"\"\"\n", | |
|
2283 | "1<2 is true, but 3>4 is false.\n", | |
|
2284 | "\n", | |
|
2285 | "$1<2$ is true, but $3>4$ is false.\n", | |
|
2286 | "\n", | |
|
2287 | "1<2 it is even worse if it is alone in a line.\n", | |
|
2288 | "\"\"\")" | |
|
2289 | ], | |
|
2290 | "language": "python", | |
|
2291 | "metadata": {}, | |
|
2292 | "outputs": [ | |
|
2293 | { | |
|
2294 | "javascript": [ | |
|
2295 | "\n", | |
|
2296 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
2297 | "mdcell.create_element();\n", | |
|
2298 | "mdcell.set_text('\\n1<2 is true, but 3>4 is false.\\n\\n$1<2$ is true, but $3>4$ is false.\\n\\n1<2 it is even worse if it is alone in a line.\\n');\n", | |
|
2299 | "mdcell.render();\n", | |
|
2300 | "$(element).append(mdcell.element)\n", | |
|
2301 | ".removeClass()\n", | |
|
2302 | ".css('left', '66%')\n", | |
|
2303 | ".css('position', 'absolute')\n", | |
|
2304 | ".css('width', '30%')\n", | |
|
2305 | "mdcell.element.prepend(\n", | |
|
2306 | " $('<div />')\n", | |
|
2307 | " .removeClass()\n", | |
|
2308 | " .css('background', '#AAAAFF')\n", | |
|
2309 | " .css('width', '100 %')\n", | |
|
2310 | " .html('Notebook Output')\n", | |
|
2311 | "\n", | |
|
2312 | ");\n", | |
|
2313 | "container.show()\n" | |
|
2314 | ], | |
|
2315 | "metadata": {}, | |
|
2316 | "output_type": "display_data", | |
|
2317 | "text": [ | |
|
2318 | "<IPython.core.display.Javascript at 0x22b6950>" | |
|
2319 | ] | |
|
2320 | }, | |
|
2321 | { | |
|
2322 | "html": [ | |
|
2323 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>14 is false.\n", | |
|
2324 | "\n", | |
|
2325 | "$14$ is false.\n", | |
|
2326 | "\n", | |
|
2327 | "1</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p>1<2 is true, but 3>4 is false.</p>\n", | |
|
2328 | "<p><span class=\"math\">\\(1<2\\)</span> is true, but <span class=\"math\">\\(3>4\\)</span> is false.</p>\n", | |
|
2329 | "<p>1<2 it is even worse if it is alone in a line.</p></div></div>" | |
|
2330 | ], | |
|
2331 | "metadata": {}, | |
|
2332 | "output_type": "display_data", | |
|
2333 | "text": [ | |
|
2334 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
2335 | ] | |
|
2336 | }, | |
|
2337 | { | |
|
2338 | "javascript": [ | |
|
2339 | "\n", | |
|
2340 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
2341 | ], | |
|
2342 | "metadata": {}, | |
|
2343 | "output_type": "display_data", | |
|
2344 | "text": [ | |
|
2345 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
2346 | ] | |
|
2347 | } | |
|
2348 | ], | |
|
2349 | "prompt_number": 27 | |
|
2350 | }, | |
|
2351 | { | |
|
2352 | "cell_type": "heading", | |
|
2353 | "level": 2, | |
|
2354 | "metadata": {}, | |
|
2355 | "source": [ | |
|
2356 | "Listings, and Code blocks" | |
|
2357 | ] | |
|
2358 | }, | |
|
2359 | { | |
|
2360 | "cell_type": "code", | |
|
2361 | "collapsed": false, | |
|
2362 | "input": [ | |
|
2363 | "compare_render(r\"\"\"\n", | |
|
2364 | "some source code\n", | |
|
2365 | "\n", | |
|
2366 | "```\n", | |
|
2367 | "a = \"test\"\n", | |
|
2368 | "print(a)\n", | |
|
2369 | "```\n", | |
|
2370 | "\"\"\")" | |
|
2371 | ], | |
|
2372 | "language": "python", | |
|
2373 | "metadata": {}, | |
|
2374 | "outputs": [ | |
|
2375 | { | |
|
2376 | "javascript": [ | |
|
2377 | "\n", | |
|
2378 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
2379 | "mdcell.create_element();\n", | |
|
2380 | "mdcell.set_text('\\nsome source code\\n\\n```\\na = \"test\"\\nprint(a)\\n```\\n');\n", | |
|
2381 | "mdcell.render();\n", | |
|
2382 | "$(element).append(mdcell.element)\n", | |
|
2383 | ".removeClass()\n", | |
|
2384 | ".css('left', '66%')\n", | |
|
2385 | ".css('position', 'absolute')\n", | |
|
2386 | ".css('width', '30%')\n", | |
|
2387 | "mdcell.element.prepend(\n", | |
|
2388 | " $('<div />')\n", | |
|
2389 | " .removeClass()\n", | |
|
2390 | " .css('background', '#AAAAFF')\n", | |
|
2391 | " .css('width', '100 %')\n", | |
|
2392 | " .html('Notebook Output')\n", | |
|
2393 | "\n", | |
|
2394 | ");\n", | |
|
2395 | "container.show()\n" | |
|
2396 | ], | |
|
2397 | "metadata": {}, | |
|
2398 | "output_type": "display_data", | |
|
2399 | "text": [ | |
|
2400 | "<IPython.core.display.Javascript at 0x22b68d0>" | |
|
2401 | ] | |
|
2402 | }, | |
|
2403 | { | |
|
2404 | "html": [ | |
|
2405 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>some source code\n", | |
|
2406 | "\n", | |
|
2407 | "\\begin{verbatim}\n", | |
|
2408 | "a = \"test\"\n", | |
|
2409 | "print(a)\n", | |
|
2410 | "\\end{verbatim}</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p>some source code</p>\n", | |
|
2411 | "<pre><code>a = "test"\n", | |
|
2412 | "print(a)</code></pre></div></div>" | |
|
2413 | ], | |
|
2414 | "metadata": {}, | |
|
2415 | "output_type": "display_data", | |
|
2416 | "text": [ | |
|
2417 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
2418 | ] | |
|
2419 | }, | |
|
2420 | { | |
|
2421 | "javascript": [ | |
|
2422 | "\n", | |
|
2423 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
2424 | ], | |
|
2425 | "metadata": {}, | |
|
2426 | "output_type": "display_data", | |
|
2427 | "text": [ | |
|
2428 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
2429 | ] | |
|
2430 | } | |
|
2431 | ], | |
|
2432 | "prompt_number": 28 | |
|
2433 | }, | |
|
2434 | { | |
|
2435 | "cell_type": "markdown", | |
|
2436 | "metadata": {}, | |
|
2437 | "source": [ | |
|
2438 | "Language specific syntax highlighting by Pandoc requires additional dependencies to render correctly." | |
|
2439 | ] | |
|
2440 | }, | |
|
2441 | { | |
|
2442 | "cell_type": "code", | |
|
2443 | "collapsed": false, | |
|
2444 | "input": [ | |
|
2445 | "compare_render(r\"\"\"\n", | |
|
2446 | "some source code\n", | |
|
2447 | "\n", | |
|
2448 | "```python\n", | |
|
2449 | "a = \"test\"\n", | |
|
2450 | "print(a)\n", | |
|
2451 | "```\n", | |
|
2452 | "\"\"\")" | |
|
2453 | ], | |
|
2454 | "language": "python", | |
|
2455 | "metadata": {}, | |
|
2456 | "outputs": [ | |
|
2457 | { | |
|
2458 | "javascript": [ | |
|
2459 | "\n", | |
|
2460 | "var mdcell = new IPython.MarkdownCell();\n", | |
|
2461 | "mdcell.create_element();\n", | |
|
2462 | "mdcell.set_text('\\nsome source code\\n\\n```python\\na = \"test\"\\nprint(a)\\n```\\n');\n", | |
|
2463 | "mdcell.render();\n", | |
|
2464 | "$(element).append(mdcell.element)\n", | |
|
2465 | ".removeClass()\n", | |
|
2466 | ".css('left', '66%')\n", | |
|
2467 | ".css('position', 'absolute')\n", | |
|
2468 | ".css('width', '30%')\n", | |
|
2469 | "mdcell.element.prepend(\n", | |
|
2470 | " $('<div />')\n", | |
|
2471 | " .removeClass()\n", | |
|
2472 | " .css('background', '#AAAAFF')\n", | |
|
2473 | " .css('width', '100 %')\n", | |
|
2474 | " .html('Notebook Output')\n", | |
|
2475 | "\n", | |
|
2476 | ");\n", | |
|
2477 | "container.show()\n" | |
|
2478 | ], | |
|
2479 | "metadata": {}, | |
|
2480 | "output_type": "display_data", | |
|
2481 | "text": [ | |
|
2482 | "<IPython.core.display.Javascript at 0x22b6850>" | |
|
2483 | ] | |
|
2484 | }, | |
|
2485 | { | |
|
2486 | "html": [ | |
|
2487 | "<div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #AAFFAA; width: 100%;'>NBConvert Latex Output</div><pre class='prettyprint lang-tex' style='background: #EEFFEE; border: 1px solid #DDEEDD;'><xmp>some source code\n", | |
|
2488 | "\n", | |
|
2489 | "\\begin{Shaded}\n", | |
|
2490 | "\\begin{Highlighting}[]\n", | |
|
2491 | "\\NormalTok{a = }\\StringTok{\"test\"}\n", | |
|
2492 | "\\KeywordTok{print}\\NormalTok{(a)}\n", | |
|
2493 | "\\end{Highlighting}\n", | |
|
2494 | "\\end{Shaded}</xmp></pre></div><div style='display: inline-block; width: 2%;'></div><div style='display: inline-block; width: 30%; vertical-align: top;'><div style='background: #FFAAAA; width: 100%;'>NBViewer Output</div><div style='display: inline-block; width: 100%;'><p>some source code</p>\n", | |
|
2495 | "<pre class=\"sourceCode python\"><code class=\"sourceCode python\">a = <span class=\"st\">"test"</span>\n", | |
|
2496 | "<span class=\"kw\">print</span>(a)</code></pre></div></div>" | |
|
2497 | ], | |
|
2498 | "metadata": {}, | |
|
2499 | "output_type": "display_data", | |
|
2500 | "text": [ | |
|
2501 | "<IPython.core.display.HTML at 0x21ac450>" | |
|
2502 | ] | |
|
2503 | }, | |
|
2504 | { | |
|
2505 | "javascript": [ | |
|
2506 | "\n", | |
|
2507 | " $.getScript(\"https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\");\n" | |
|
2508 | ], | |
|
2509 | "metadata": {}, | |
|
2510 | "output_type": "display_data", | |
|
2511 | "text": [ | |
|
2512 | "<IPython.core.display.Javascript at 0x21ac450>" | |
|
2513 | ] | |
|
2514 | } | |
|
2515 | ], | |
|
2516 | "prompt_number": 29 | |
|
2517 | } | |
|
2518 | ], | |
|
2519 | "metadata": {} | |
|
2520 | } | |
|
2521 | ] | |
|
2522 | } No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now