Show More
@@ -1,52 +1,52 b'' | |||
|
1 | 1 | """Simple magics for display formats""" |
|
2 | 2 | #----------------------------------------------------------------------------- |
|
3 | 3 | # Copyright (c) 2012 The IPython Development Team. |
|
4 | 4 | # |
|
5 | 5 | # Distributed under the terms of the Modified BSD License. |
|
6 | 6 | # |
|
7 | 7 | # The full license is in the file COPYING.txt, distributed with this software. |
|
8 | 8 | #----------------------------------------------------------------------------- |
|
9 | 9 | |
|
10 | 10 | #----------------------------------------------------------------------------- |
|
11 | 11 | # Imports |
|
12 | 12 | #----------------------------------------------------------------------------- |
|
13 | 13 | |
|
14 | 14 | # Our own packages |
|
15 | 15 | from IPython.core.display import display, Javascript, Latex, SVG, HTML |
|
16 | 16 | from IPython.core.magic import ( |
|
17 | 17 | Magics, magics_class, cell_magic |
|
18 | 18 | ) |
|
19 | 19 | |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | # Magic implementation classes |
|
22 | 22 | #----------------------------------------------------------------------------- |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | @magics_class |
|
26 | 26 | class DisplayMagics(Magics): |
|
27 | 27 | """Magics for displaying various output types with literals |
|
28 | 28 | |
|
29 |
Defines javascript/latex cell magics for writing |
|
|
30 | to be rendered in the frontend. | |
|
29 | Defines javascript/latex/svg/html cell magics for writing | |
|
30 | blocks in those languages, to be rendered in the frontend. | |
|
31 | 31 | """ |
|
32 | 32 | |
|
33 | 33 | @cell_magic |
|
34 | 34 | def javascript(self, line, cell): |
|
35 | 35 | """Run the cell block of Javascript code""" |
|
36 | 36 | display(Javascript(cell)) |
|
37 | 37 | |
|
38 | 38 | |
|
39 | 39 | @cell_magic |
|
40 | 40 | def latex(self, line, cell): |
|
41 | 41 | """Render the cell as a block of latex""" |
|
42 | 42 | display(Latex(cell)) |
|
43 | 43 | |
|
44 | 44 | @cell_magic |
|
45 | 45 | def svg(self, line, cell): |
|
46 | 46 | """Render the cell as an SVG literal""" |
|
47 | 47 | display(SVG(cell)) |
|
48 | 48 | |
|
49 | 49 | @cell_magic |
|
50 | 50 | def html(self, line, cell): |
|
51 |
"""Render the cell as a |
|
|
51 | """Render the cell as a block of HTML""" | |
|
52 | 52 | display(HTML(cell)) |
General Comments 0
You need to be logged in to leave comments.
Login now