| 428 | |
| 429 | |
| 430 | class HTML(TextDisplayObject): |
| 431 | |
| 432 | def __init__(self, data=None, url=None, filename=None, metadata=None): |
| 433 | def warn(): |
| 434 | if not data: |
| 435 | return False |
| 436 | |
| 437 | # |
| 438 | # Avoid calling lower() on the entire data, because it could be a |
| 439 | # long string and we're only interested in its beginning and end. |
| 440 | # |
| 441 | prefix = data[:10].lower() |
| 442 | suffix = data[-10:].lower() |
| 443 | return prefix.startswith("<iframe ") and suffix.endswith("</iframe>") |
| 444 | |
| 445 | if warn(): |
| 446 | warnings.warn("Consider using IPython.display.IFrame instead") |
| 447 | super(HTML, self).__init__(data=data, url=url, filename=filename, metadata=metadata) |
| 448 | |
| 449 | def _repr_html_(self): |
| 450 | return self._data_and_metadata() |
| 451 | |
| 452 | def __html__(self): |
| 453 | """ |
| 454 | This method exists to inform other HTML-using modules (e.g. Markupsafe, |
| 455 | htmltag, etc) that this object is HTML and does not need things like |
| 456 | special characters (<>&) escaped. |
| 457 | """ |
| 458 | return self._repr_html_() |
| 459 | |
| 460 | |
| 461 | class Markdown(TextDisplayObject): |
no outgoing calls
searching dependent graphs…