# Path: breadability/_compat.py
# PY3 = version_info[0] == 3
# def unicode_compatible(cls):
# def to_string(object):
# def to_bytes(object):
# def to_unicode(object):
# def instance_to_bytes(instance):
# def instance_to_unicode(instance):
# 
# Path: breadability/utils.py
# def cached_property(getter):
#     """
#     Decorator that converts a method into memoized property.
#     The decorator works as expected only for classes with
#     attribute '__dict__' and immutable properties.
#     """
#     def decorator(self):
#         key = "_cached_property_" + getter.__name__
# 
#         if not hasattr(self, key):
#             setattr(self, key, getter(self))
# 
#         return getattr(self, key)
# 
#     decorator.__name__ = getter.__name__
#     decorator.__module__ = getter.__module__
#     decorator.__doc__ = getter.__doc__
# 
#     return property(decorator)
# 
# @contextmanager
# def ignored(*exceptions):
#     try:
#         yield
#     except tuple(exceptions):
#         pass


import logging
import re
import chardet
from lxml.etree import ParserError, XMLSyntaxError, tounicode
from lxml.html import HTMLParser, document_fromstring
from ._compat import to_bytes, to_unicode, unicode, unicode_compatible
from .utils import cached_property, ignored
    def __init__(self, html, url=None):
        self._html = html
        self._url = url

    @property
    def url(self):
        """Source URL of HTML document."""
        return self._url

    def __unicode__(self):
        """Renders the document as a string."""
        return tounicode(self.dom)

    @cached_property
    def dom(self):
        """Parsed HTML document from the input."""
        html = self._html
        if not isinstance(html, unicode):
            html = decode_html(html)

        html = convert_breaks_to_paragraphs(html)
        document = build_document(html, self._url)

        return document

    @cached_property
    def links(self):
        """Links within the document."""
        return self.dom.findall(".//a")


# Path: breadability/_compat.py
# PY3 = version_info[0] == 3
# def unicode_compatible(cls):
# def to_string(object):
# def to_bytes(object):
# def to_unicode(object):
# def instance_to_bytes(instance):
# def instance_to_unicode(instance):
# 
# Path: breadability/utils.py
# def cached_property(getter):
#     """
#     Decorator that converts a method into memoized property.
#     The decorator works as expected only for classes with
#     attribute '__dict__' and immutable properties.
#     """
#     def decorator(self):
#         key = "_cached_property_" + getter.__name__
# 
#         if not hasattr(self, key):
#             setattr(self, key, getter(self))
# 
#         return getattr(self, key)
# 
#     decorator.__name__ = getter.__name__
#     decorator.__module__ = getter.__module__
#     decorator.__doc__ = getter.__doc__
# 
#     return property(decorator)
# 
# @contextmanager
# def ignored(*exceptions):
#     try:
#         yield
#     except tuple(exceptions):
#         pass


# Path: breadability/document.py
import logging
import re
import chardet
from lxml.etree import ParserError, XMLSyntaxError, tounicode
from lxml.html import HTMLParser, document_fromstring
from ._compat import to_bytes, to_unicode, unicode, unicode_compatible
from .utils import cached_property, ignored

    def __init__(self, html, url=None):
        self._html = html
        self._url = url

    @property
    def url(self):
        """Source URL of HTML document."""
        return self._url

    def __unicode__(self):
        """Renders the document as a string."""
        return tounicode(self.dom)

    @cached_property
    def dom(self):
        """Parsed HTML document from the input."""
        html = self._html
        if not isinstance(html, unicode):
            html = decode_html(html)

        html = convert_breaks_to_paragraphs(html)
        document = build_document(html, self._url)

        return document

    @cached_property
    def links(self):
        """Links within the document."""
        return self.dom.findall(".//a")


    @cached_property