Tuesday, 24 December 2019

IPython `display` to string

I am trying to use the IPython.display module to convert objects to Markdown. However, there does not seem to be a good way to export this Markdown as a string.

Behaviour:

>>> from IPython.display import *
>>> from numpy import *
>>> display_markdown(eye(3))
[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]

Wanted behaviour:

>>> display_markdown_string(eye(3))
"$$\left( ... \right)$$"

Is there a good way to achieve this? It seems to me that this functionality has to present somewhere in IPython, since it can be done in the Notebooks.



from IPython `display` to string

No comments:

Post a Comment