##// END OF EJS Templates
Added __html__() method to the HTML class so that other Python modules...
Dan McDougall -
Show More
@@ -38,10 +38,10 b' def _safe_exists(path):'
38
38
39 def _merge(d1, d2):
39 def _merge(d1, d2):
40 """Like update, but merges sub-dicts instead of clobbering at the top level.
40 """Like update, but merges sub-dicts instead of clobbering at the top level.
41
41
42 Updates d1 in-place
42 Updates d1 in-place
43 """
43 """
44
44
45 if not isinstance(d2, dict) or not isinstance(d1, dict):
45 if not isinstance(d2, dict) or not isinstance(d1, dict):
46 return d2
46 return d2
47 for key, value in d2.items():
47 for key, value in d2.items():
@@ -107,7 +107,7 b' def display(*objs, **kwargs):'
107 metadata = kwargs.get('metadata')
107 metadata = kwargs.get('metadata')
108
108
109 from IPython.core.interactiveshell import InteractiveShell
109 from IPython.core.interactiveshell import InteractiveShell
110
110
111 if raw:
111 if raw:
112 for obj in objs:
112 for obj in objs:
113 publish_display_data('display', obj, metadata)
113 publish_display_data('display', obj, metadata)
@@ -337,6 +337,14 b' class HTML(DisplayObject):'
337 def _repr_html_(self):
337 def _repr_html_(self):
338 return self.data
338 return self.data
339
339
340 def __html__(self):
341 """
342 This method exists to inform other HTML-using modules (e.g. Markupsafe,
343 htmltag, etc) that this object is HTML and does not need things like
344 special characters (<>&) escaped.
345 """
346 return self._repr_html_()
347
340
348
341 class Math(DisplayObject):
349 class Math(DisplayObject):
342
350
@@ -559,7 +567,7 b' class Image(DisplayObject):'
559 if self.height:
567 if self.height:
560 height = ' height="%d"' % self.height
568 height = ' height="%d"' % self.height
561 return u'<img src="%s"%s%s/>' % (self.url, width, height)
569 return u'<img src="%s"%s%s/>' % (self.url, width, height)
562
570
563 def _data_and_metadata(self):
571 def _data_and_metadata(self):
564 """shortcut for returning metadata with shape information, if defined"""
572 """shortcut for returning metadata with shape information, if defined"""
565 md = {}
573 md = {}
General Comments 0
You need to be logged in to leave comments. Login now