Skip to content

Commit

Permalink
Merge pull request #11112 from ipython/auto-backport-of-pr-11106
Browse files Browse the repository at this point in the history
Backport PR #11106 on branch 6.x
  • Loading branch information
takluyver committed May 4, 2018
2 parents 329cd16 + 6eab9ad commit 377e86a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 8 additions & 5 deletions IPython/core/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def _repr_pretty_(self, pp, cycle):
class HTML(TextDisplayObject):

def _repr_html_(self):
return self.data
return self._data_and_metadata()

def __html__(self):
"""
Expand All @@ -681,20 +681,23 @@ def __html__(self):
class Markdown(TextDisplayObject):

def _repr_markdown_(self):
return self.data
return self._data_and_metadata()


class Math(TextDisplayObject):

def _repr_latex_(self):
s = self.data.strip('$')
return "$$%s$$" % s
s = "$$%s$$" % self.data.strip('$')
if self.metadata:
return s, deepcopy(self.metadata)
else:
return s


class Latex(TextDisplayObject):

def _repr_latex_(self):
return self.data
return self._data_and_metadata()


class SVG(DisplayObject):
Expand Down
4 changes: 4 additions & 0 deletions IPython/core/tests/test_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ def test_video_embedding():
html = v._repr_html_()
nt.assert_in('src="data:video/xyz;base64,YWJj"',html)

def test_html_metadata():
s = "<h1>Test</h1>"
h = display.HTML(s, metadata={"isolated": True})
nt.assert_equal(h._repr_html_(), (s, {"isolated": True}))

def test_display_id():
ip = get_ipython()
Expand Down

0 comments on commit 377e86a

Please sign in to comment.