##// END OF EJS Templates
Precise that %%js is an alias of %%javascript
Matthias Bussonnier -
Show More
@@ -1,62 +1,65 b''
1 """Simple magics for display formats"""
1 """Simple magics for display formats"""
2 #-----------------------------------------------------------------------------
2 #-----------------------------------------------------------------------------
3 # Copyright (c) 2012 The IPython Development Team.
3 # Copyright (c) 2012 The IPython Development Team.
4 #
4 #
5 # Distributed under the terms of the Modified BSD License.
5 # Distributed under the terms of the Modified BSD License.
6 #
6 #
7 # The full license is in the file COPYING.txt, distributed with this software.
7 # The full license is in the file COPYING.txt, distributed with this software.
8 #-----------------------------------------------------------------------------
8 #-----------------------------------------------------------------------------
9
9
10 #-----------------------------------------------------------------------------
10 #-----------------------------------------------------------------------------
11 # Imports
11 # Imports
12 #-----------------------------------------------------------------------------
12 #-----------------------------------------------------------------------------
13
13
14 # Our own packages
14 # Our own packages
15 from IPython.core.display import display, Javascript, Latex, SVG, HTML
15 from IPython.core.display import display, Javascript, Latex, SVG, HTML
16 from IPython.core.magic import (
16 from IPython.core.magic import (
17 Magics, magics_class, cell_magic
17 Magics, magics_class, cell_magic
18 )
18 )
19
19
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21 # Magic implementation classes
21 # Magic implementation classes
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23
23
24
24
25 @magics_class
25 @magics_class
26 class DisplayMagics(Magics):
26 class DisplayMagics(Magics):
27 """Magics for displaying various output types with literals
27 """Magics for displaying various output types with literals
28
28
29 Defines javascript/latex/svg/html cell magics for writing
29 Defines javascript/latex/svg/html cell magics for writing
30 blocks in those languages, to be rendered in the frontend.
30 blocks in those languages, to be rendered in the frontend.
31 """
31 """
32
32
33 @cell_magic
33 @cell_magic
34 def js(self, line, cell):
34 def js(self, line, cell):
35 """Run the cell block of Javascript code"""
35 """Run the cell block of Javascript code
36
37 Alias of `%%javascript`
38 """
36 self.javascript(line, cell)
39 self.javascript(line, cell)
37
40
38 @cell_magic
41 @cell_magic
39 def javascript(self, line, cell):
42 def javascript(self, line, cell):
40 """Run the cell block of Javascript code"""
43 """Run the cell block of Javascript code"""
41 display(Javascript(cell))
44 display(Javascript(cell))
42
45
43
46
44 @cell_magic
47 @cell_magic
45 def latex(self, line, cell):
48 def latex(self, line, cell):
46 """Render the cell as a block of latex
49 """Render the cell as a block of latex
47
50
48 The subset of latex which is support depends on the implementation in
51 The subset of latex which is support depends on the implementation in
49 the client. In the Jupyter Notebook, this magic only renders the subset
52 the client. In the Jupyter Notebook, this magic only renders the subset
50 of latex defined by MathJax
53 of latex defined by MathJax
51 [here](https://docs.mathjax.org/en/v2.5-latest/tex.html)."""
54 [here](https://docs.mathjax.org/en/v2.5-latest/tex.html)."""
52 display(Latex(cell))
55 display(Latex(cell))
53
56
54 @cell_magic
57 @cell_magic
55 def svg(self, line, cell):
58 def svg(self, line, cell):
56 """Render the cell as an SVG literal"""
59 """Render the cell as an SVG literal"""
57 display(SVG(cell))
60 display(SVG(cell))
58
61
59 @cell_magic
62 @cell_magic
60 def html(self, line, cell):
63 def html(self, line, cell):
61 """Render the cell as a block of HTML"""
64 """Render the cell as a block of HTML"""
62 display(HTML(cell))
65 display(HTML(cell))
General Comments 0
You need to be logged in to leave comments. Login now