Show More
@@ -16,6 +16,7 b' from IPython.core.display import display, Javascript, Latex, SVG, HTML, Markdown' | |||||
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 | from IPython.core import magic_arguments | |||
19 |
|
20 | |||
20 | #----------------------------------------------------------------------------- |
|
21 | #----------------------------------------------------------------------------- | |
21 | # Magic implementation classes |
|
22 | # Magic implementation classes | |
@@ -33,7 +34,7 b' class DisplayMagics(Magics):' | |||||
33 | @cell_magic |
|
34 | @cell_magic | |
34 | def js(self, line, cell): |
|
35 | def js(self, line, cell): | |
35 | """Run the cell block of Javascript code |
|
36 | """Run the cell block of Javascript code | |
36 |
|
37 | |||
37 | Alias of `%%javascript` |
|
38 | Alias of `%%javascript` | |
38 | """ |
|
39 | """ | |
39 | self.javascript(line, cell) |
|
40 | self.javascript(line, cell) | |
@@ -59,12 +60,23 b' class DisplayMagics(Magics):' | |||||
59 | """Render the cell as an SVG literal""" |
|
60 | """Render the cell as an SVG literal""" | |
60 | display(SVG(cell)) |
|
61 | display(SVG(cell)) | |
61 |
|
62 | |||
|
63 | @magic_arguments.magic_arguments() | |||
|
64 | @magic_arguments.argument( | |||
|
65 | '--isolated', action='store_true', default=False, | |||
|
66 | help="""Annotate the cell as 'isolated'. | |||
|
67 | Isolated cells are rendered inside their own <iframe> tag""" | |||
|
68 | ) | |||
62 | @cell_magic |
|
69 | @cell_magic | |
63 | def html(self, line, cell): |
|
70 | def html(self, line, cell): | |
64 | """Render the cell as a block of HTML""" |
|
71 | """Render the cell as a block of HTML""" | |
65 | display(HTML(cell)) |
|
72 | args = magic_arguments.parse_argstring(self.html, line) | |
66 |
|
73 | html = HTML(cell) | ||
67 | @cell_magic |
|
74 | if args.isolated: | |
|
75 | display(html, metadata={'text/html':{'isolated':True}}) | |||
|
76 | else: | |||
|
77 | display(html) | |||
|
78 | ||||
|
79 | @cell_magic | |||
68 | def markdown(self, line, cell): |
|
80 | def markdown(self, line, cell): | |
69 | """Render the cell as Markdown text block""" |
|
81 | """Render the cell as Markdown text block""" | |
70 | display(Markdown(cell)) |
|
82 | display(Markdown(cell)) |
General Comments 0
You need to be logged in to leave comments.
Login now