##// END OF EJS Templates
Backport PR #11106: Display objects should emit metadata when it exists
Matthias Bussonnier -
Show More
@@ -667,7 +667,7 b' class Pretty(TextDisplayObject):'
667 class HTML(TextDisplayObject):
667 class HTML(TextDisplayObject):
668
668
669 def _repr_html_(self):
669 def _repr_html_(self):
670 return self.data
670 return self._data_and_metadata()
671
671
672 def __html__(self):
672 def __html__(self):
673 """
673 """
@@ -681,20 +681,23 b' class HTML(TextDisplayObject):'
681 class Markdown(TextDisplayObject):
681 class Markdown(TextDisplayObject):
682
682
683 def _repr_markdown_(self):
683 def _repr_markdown_(self):
684 return self.data
684 return self._data_and_metadata()
685
685
686
686
687 class Math(TextDisplayObject):
687 class Math(TextDisplayObject):
688
688
689 def _repr_latex_(self):
689 def _repr_latex_(self):
690 s = self.data.strip('$')
690 s = "$$%s$$" % self.data.strip('$')
691 return "$$%s$$" % s
691 if self.metadata:
692 return s, deepcopy(self.metadata)
693 else:
694 return s
692
695
693
696
694 class Latex(TextDisplayObject):
697 class Latex(TextDisplayObject):
695
698
696 def _repr_latex_(self):
699 def _repr_latex_(self):
697 return self.data
700 return self._data_and_metadata()
698
701
699
702
700 class SVG(DisplayObject):
703 class SVG(DisplayObject):
@@ -275,6 +275,10 b' def test_video_embedding():'
275 html = v._repr_html_()
275 html = v._repr_html_()
276 nt.assert_in('src="data:video/xyz;base64,YWJj"',html)
276 nt.assert_in('src="data:video/xyz;base64,YWJj"',html)
277
277
278 def test_html_metadata():
279 s = "<h1>Test</h1>"
280 h = display.HTML(s, metadata={"isolated": True})
281 nt.assert_equal(h._repr_html_(), (s, {"isolated": True}))
278
282
279 def test_display_id():
283 def test_display_id():
280 ip = get_ipython()
284 ip = get_ipython()
General Comments 0
You need to be logged in to leave comments. Login now