[IPython-User] Printing a string and latex together in a notebook

Aaron Meurer asmeurer@gmail....
Mon Nov 19 02:07:03 CST 2012


On Mon, Nov 19, 2012 at 12:46 AM, Matthias BUSSONNIER <
bussonniermatthias@gmail.com> wrote:

>
> > I mean, objects can define their own rich printing types in the
> notebook.  Latex() renders LaTeX because it's output type is LaTeX.  I am
> suggesting to create Markdown(), whose output type is markdown rendered
> text (if one does not already exist).
>
> I understand better now.
> This could be a good project for json plugin.
>
> > And we are also working on having the ability to do
> >
> > the value of x is ::x::
> > in a markdown cell,
> > where ::x:: will be replace by the actual repr of x in the kernel.
> > Still thinking on the best syntax and how to choose between
> tex/html/.../ repr.
> > --
> > Matthias
> >
> > That would also work, though obviously for non-trivial string
> manipulations, it would be better to do it directly in code (for example,
> appending "s" to the end of a word iff a certain variable is greater than
> 1).
>
> Good point.
>
> > Also, would this allow arbitrary code to be executed, or just variable
> names?
>
> To make it work with any code could be done easily.
> Though I would like to avoid side effect, and nothing prevent you from
> precomputing part of the string in the previous code-cell.
>

Arbitrary code vs. variables has nothing to do with side-effects.  str(obj)
(i.e., obj.__str__) already allows arbitrary code execution.  I think it
matters more from a parsing side, and also from a conceptual side.  If you
really want to avoid side-effects, you could require that the variable be a
str. If you do that, you might even be able to do some smart caching to
avoid additional calls to the kernel.

By the way, if x changes, would ::x:: update automatically, or only when
the Markdown cell is "reexecuted"?  If you want the former without
side-effects, again you will want to restrict to str objects only.

Aaron Meurer

--
> Matthias
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20121119/a2f2188a/attachment.html 


More information about the IPython-User mailing list