Skip to content

Commit

Permalink
Merge pull request ipython#3250 from liftoff/master
Browse files Browse the repository at this point in the history
Added a simple __html__() method to the HTML class
  • Loading branch information
ellisonbg committed May 1, 2013
2 parents e900db8 + 35069d6 commit 74565c6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions IPython/core/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def _safe_exists(path):

def _merge(d1, d2):
"""Like update, but merges sub-dicts instead of clobbering at the top level.
Updates d1 in-place
"""

if not isinstance(d2, dict) or not isinstance(d1, dict):
return d2
for key, value in d2.items():
Expand Down Expand Up @@ -107,7 +107,7 @@ def display(*objs, **kwargs):
metadata = kwargs.get('metadata')

from IPython.core.interactiveshell import InteractiveShell

if raw:
for obj in objs:
publish_display_data('display', obj, metadata)
Expand Down Expand Up @@ -337,6 +337,14 @@ class HTML(DisplayObject):
def _repr_html_(self):
return self.data

def __html__(self):
"""
This method exists to inform other HTML-using modules (e.g. Markupsafe,
htmltag, etc) that this object is HTML and does not need things like
special characters (<>&) escaped.
"""
return self._repr_html_()


class Math(DisplayObject):

Expand Down Expand Up @@ -559,7 +567,7 @@ def _repr_html_(self):
if self.height:
height = ' height="%d"' % self.height
return u'<img src="%s"%s%s/>' % (self.url, width, height)

def _data_and_metadata(self):
"""shortcut for returning metadata with shape information, if defined"""
md = {}
Expand Down

0 comments on commit 74565c6

Please sign in to comment.