New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes to the display system #370
Conversation
To answer your question: "Should the latex representation include the wrapping $ or $$?", meaning (I think), the result of repr_latex should include the dollar signs, I would advocate for "yes". The matplotlib mathtext parser supports text outside of math mode, eg.: r"Result of expression: Also, if one ever wanted to use a "call out to the real LaTeX" approach to this, there's all kinds of text layout features in LaTeX outside of math mode that one might want to use. |
Quick sanity check also: Is the LaTeX inline display not yet working? I see how I can get it to display LaTeX for Sympy objects, but what about an arbitrary object with a repr_latex method? |
The repr_latex method does work, but the qtconsole does not have native latex rendering. The htmlnotebook we are working on does have native latex support, but it is not all wired up in the Javascript yet. Not sure how to get qt to handle latex (without rendering to png like we do for sympy currently). |
It still may be useful (if not perfect) to have LaTeX -> PNG supported in Mike On Fri, Apr 15, 2011 at 12:36 PM, ellisonbg <
Michael Droettboom |
At point point I started to look into latex->svg generation using
But we would love to have better support for all of this and any ideas you It still may be useful (if not perfect) to have LaTeX -> PNG supported in
Brian E. Granger |
Yeah -- the mathtext stuff in matplotlib is still a subset of what a standard LaTeX distribution has. It's reasonably complete wrt to TeX, on which it is based, but it's missing most of the macros that LaTeX layers on top. You could use dvipng and real LaTeX to generate the equation images if LaTeX is available. It adds a really heavy dependency, but it's the only thing I'm aware of that is as complete as LaTeX (because it is!). The Sphinx mathpng extension is a good concise example of using dvipng to get a LaTeX image. There is dvi parsing code in matplotlib, but it is complicated by the fact that it deals with scalable fonts etc. -- something you wouldn't necessary want to do for an interactive console. |
I've added a function to matplotlib master that converts a math expression alone to any of the image formats that matplotlib supports. See this pull request: Since that function won't exist in a released matplotlib for a while, you may want to copy it into IPython and use it when it isn't available in matplotlib -- it uses things that have been stable for quite some time. |
On Mon, Apr 11, 2011 at 8:38 PM, ellisonbg
I'd like to hear @rkern's feedback on this one, seeing as much of our
We also had the alternative of
I think encoding should be the responsibility of the zmq layer, not
It should, because those are semantically meaningful (they indicate
Is there a valid usecase for the raw data? I just don't know... If |
It should definitely exclude the script tag, because the tag is HTML, and it would no longer be a valid javascript representation if you include it. The use case is javascript-based frontends. If the frontend wants to do any handling on the data, it would have to strip the tags before parsing. It's more trivial to add tags in frontends that just want to echo into HTML than it is to strip tags for frontends that want to look at the data. |
OK, I am going to make |
Sure. |
Please don't include |
@minrk: OK, I understand your logic here and I think I agree with you. |
The IPython formatters use special methods to compute the format of objects. These special methods have names like "__html__", but with this commit these have been changed to "_repr_html_". I have also added a Javascript formatter and fixed a bug in pylab tools in getfigs.
* Throughout the codebase, __pretty__ has been changed to _repr_pretty_ to match general convention for special method names. * The logic in pretty.py now matches that in formatters.py in that formatters that are callables are tried first and then special methods are used.
* PNG base64 encoding is now done at the ZMQ level, not in the display formatter itself. * All formatters are documented as to the exact nature of their return value. PNGs are not base64 encoded, LaTeX must include $/$$, Javascript should not have the <script> tags, etc. * Updated the Circle display example in docs/examples/core. * Renamed the sympy printing extension to sympyprinting.py.
The IPython formatters use special methods to compute the format
of objects. These special methods have names like
__html__
, butwith this commit these have been changed to
_repr_html_
.I have also added a Javascript formatter and fixed a bug in
pylab tools in getfigs.
Some remaining questions:
__pretty__
. Do we want to update pretty.py as well and use_repr_pretty_
?_repr_png_
return the raw png data or base64 encoded data (required for sending over json). Currently we base64 encode.<script>
tag pair.