docs: def linkify(text, attrs={}):
      """
      Convert URL-like and email-like strings into links.
      """
      def separate_parentheses(s):
          start = re_find(r'^\(*', s)
          end = re_find(r'\)*$', s)
          n = min(len(start), len(end))
          if n:
              return s[:n], s[n:-n], s[-n:]
          else:
              return '', s, ''
  
      def link_repl(url, proto='http://'):
          opening, url, closing = separate_parentheses(url)
  
          punct = re_find(punct_re, url)
          if punct:
              url = url[:-len(punct)]
  
          if re.search(proto_re, url):
              href = url
          else:
              href = proto + url
          href = escape_url(href)
  
          repl = u'{0!s}<a href="{1!s}"{2!s}>{3!s}</a>{4!s}{5!s}'
          return repl.format(opening,
                             href, attrs_text, url, punct,
                             closing)
  
      def repl(match):
          matches = match.groupdict()
          if matches['url']:
              return link_repl(matches['url'])
          else:
              return link_repl(matches['email'], proto='mailto:')
  
      # Prepare attrs
      attr = ' {0!s}="{1!s}"'
      attrs_text = ''.join(starmap(attr.format, attrs.items()))
  
      # Make replaces
      return re.sub(combined_re, repl, force_unicode(text))