diff --git a/branca/element.py b/branca/element.py index 5c08857..b624f1b 100644 --- a/branca/element.py +++ b/branca/element.py @@ -7,10 +7,10 @@ """ import base64 +from html import escape import json import warnings from collections import OrderedDict -import urllib.parse from urllib.request import urlopen from uuid import uuid4 @@ -320,43 +320,26 @@ def render(self, **kwargs): return self._template.render(this=self, kwargs=kwargs) def _repr_html_(self, **kwargs): - """Displays the Figure in a Jupyter notebook. - - Percent-encoded HTML is stored in data-html attribute, which is used to populate - the iframe. This approach does not encounter the 2MB limit in Chrome for storing - the HTML in the src attribute with a data URI. The alternative of using a srcdoc - attribute is not supported in Microsoft Internet Explorer and Edge. - - """ - html = urllib.parse.quote(self.render(**kwargs)) - onload = ( - 'this.contentDocument.open();' - 'this.contentDocument.write(' - ' decodeURIComponent(this.getAttribute(\'data-html\'))' - ');' - 'this.contentDocument.close();' - ) - + """Displays the Figure in a Jupyter notebook.""" + html = escape(self.render(**kwargs)) if self.height is None: iframe = ( '