[IPython-dev] magics and metadata

Jonathan Taylor jonathan.taylor at stanford.edu
Tue Jun 19 04:18:12 EDT 2012

With the addition of cell-level metadata in cells in ipython/master it
would be nice to be able to easily add metadata to cells, say, through
a cell magic? I can't see a way that this is possible in the current
cell_magic api as the cell_magic gives you the input of the cell but not a
cell itself, i.e. not an instance of NotebookNode.

I can see there are some downsides in giving the cell_magics a NotebookNode
as the cell argument over a string:
one obvious problem is that, unconstrained, one could have a magic that
modifies "cell_type" from "code" to "markdown".
Maybe this is a bad thing, but I can imagine a case where I might want to
do that. Another obvious downside
is that users who write cell_magics have to return NotebookNode instances
(which doesn't seem too difficult).

This question might also fit into the discussion of composing or iterating
cell magics. If a cell magic returned a NotebookNode and took
a NotebookNode as its cell argument, then there is a natural way to compose

%%magic1 line1
%%magic2 line2

would return the NotebookNode

magic1(line1, magic2(line2, cell_text))

Jonathan Taylor
Dept. of Statistics
Sequoia Hall, 137
390 Serra Mall
Stanford, CA 94305
Tel:   650.723.9230
Fax:   650.725.8977
Web: http://www-stat.stanford.edu/~jtaylo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20120619/ea2837ac/attachment.html>

More information about the IPython-dev mailing list