# Path: airy/utils/html.py
# def strip_tags(value):
#     """Returns the given HTML with all tags stripped."""
#     return re.sub(r'<[^>]*?>', '', force_unicode(value))
# 
# Path: airy/utils/encoding.py
# def smart_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Returns a unicode object representing 's'. Treats bytestrings using the
#     'encoding' codec.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     if isinstance(s, Promise):
#         # The input is the result of a gettext_lazy() call.
#         return s
#     return force_unicode(s, encoding, strings_only, errors)


import copy
import logging
import re
    import lxml.html
from airy.utils.html import strip_tags
from airy.utils.encoding import smart_unicode
        from airy.core import sanitizer
        link = best_match.group(0)
        end = best_match.end()
        if link.endswith('.') or link.endswith(','):
            # These punctuation marks shouldn't end a link
            end -= 1
            link = link[:-1]
        prev_text = text[:best_match.start()]
        if links:
            assert not links[-1].tail
            links[-1].tail = prev_text
        else:
            assert not leading_text
            leading_text = prev_text
        anchor = factory('a')
        anchor.set('href', link)
        body = best_match.group('body')
        if not body:
            body = link
        if body.endswith('.') or body.endswith(','):
            body = body[:-1]
        anchor.text = body
        if extra_params:
            anchor.attrib.update(extra_params)
        links.append(anchor)
        text = text[end:]
    return leading_text, links


def _autolink(el, link_regexes=_link_regexes,
             avoid_elements=_avoid_elements,

# Path: airy/utils/html.py
# def strip_tags(value):
#     """Returns the given HTML with all tags stripped."""
#     return re.sub(r'<[^>]*?>', '', force_unicode(value))
# 
# Path: airy/utils/encoding.py
# def smart_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Returns a unicode object representing 's'. Treats bytestrings using the
#     'encoding' codec.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     if isinstance(s, Promise):
#         # The input is the result of a gettext_lazy() call.
#         return s
#     return force_unicode(s, encoding, strings_only, errors)


# Path: airy/core/markup.py
import copy
import logging
import re
    import lxml.html
from airy.utils.html import strip_tags
from airy.utils.encoding import smart_unicode
        from airy.core import sanitizer

        link = best_match.group(0)
        end = best_match.end()
        if link.endswith('.') or link.endswith(','):
            # These punctuation marks shouldn't end a link
            end -= 1
            link = link[:-1]
        prev_text = text[:best_match.start()]
        if links:
            assert not links[-1].tail
            links[-1].tail = prev_text
        else:
            assert not leading_text
            leading_text = prev_text
        anchor = factory('a')
        anchor.set('href', link)
        body = best_match.group('body')
        if not body:
            body = link
        if body.endswith('.') or body.endswith(','):
            body = body[:-1]
        anchor.text = body
        if extra_params:
            anchor.attrib.update(extra_params)
        links.append(anchor)
        text = text[end:]
    return leading_text, links


def _autolink(el, link_regexes=_link_regexes,
             avoid_elements=_avoid_elements,

             avoid_hosts=_avoid_hosts,