# File lib/feedparser/textconverters.rb, line 40
  def text2html(feed)
    text = self.clone
    realhtml = text.html?
    eschtml = text.escaped_html?
    # fix for RSS feeds with both real and escaped html (crazy!):
    # we take the first one
    if (realhtml && eschtml)
      if (realhtml < eschtml)
        eschtml = nil
      else
        realhtml = nil
      end
    end
    if realhtml
      # do nothing
    elsif eschtml
      text = text.unescape_html
    else
      # paragraphs
      text.gsub!(/\A\s*(.*)\Z/m, '<p>\1</p>')
      text.gsub!(/\s*\n(\s*\n)+\s*/, "</p>\n<p>")
      # uris
      text.gsub!(/([^'"])(#{URI::regexp(['http','ftp','https'])})/,
          '\1<a href="\2">\2</a>')
    end
    # Handle broken hrefs in <a> and <img>
    if feed and feed.link
      text.gsub!(/(\s(src|href)=['"])([^'"]*)(['"])/) do |m|
        begin
          first, url, last = $1, $3, $4
          if (url =~ /^\s*\w+:\/\//) or (url =~ /^\s*\w+:\w/)
            m
          elsif url =~ /^\//
            (first + feed.link.split(/\//)[0..2].join('/') + url + last)
          else
            t = feed.link.split(/\//)
            if t.length == 3 # http://toto with no trailing /
              (first + feed.link + '/' + url + last)
            else
              if feed.link =~ /\/$/
                (first + feed.link + url + last)
              else
                (first + t[0...-1].join('/') + '/' + url + last)
              end
            end
          end
        rescue
          m
        end
      end
    end
    text
  end