title: IPython `display` to string
body: <p>I am trying to use the <code>IPython.display</code> module to convert objects to Markdown. However, there does not seem to be a good way to export this Markdown as a string.</p>
  
  <p>Behaviour:</p>
  
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; from IPython.display import *
  &gt;&gt;&gt; from numpy import *
  &gt;&gt;&gt; display_markdown(eye(3))
  [[1. 0. 0.]
   [0. 1. 0.]
   [0. 0. 1.]]
  </code></pre>
  
  <p>Wanted behaviour:</p>
  
  <pre><code>&gt;&gt;&gt; display_markdown_string(eye(3))
  "$$\left( ... \right)$$"
  </code></pre>
  
  <p>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.</p>