class Hpricot::Elem

def attributes

def attributes
  if raw_attributes
    raw_attributes.inject({}) do |hsh, (k, v)|
      hsh[k] = Hpricot.uxs(v)
      hsh
    end
  end
end

def empty?; @children.empty? end

def empty?; @children.empty? end

def initialize(stag, children=nil, etag=nil)

def initialize(stag, children=nil, etag=nil)
  @stag, @etag = stag, etag
  @children = children ? children.each { |c| c.parent = self }  : []
end

def output(out, opts = {})

def output(out, opts = {})
  if empty? and ElementContent[@stag.name] == :EMPTY
    @stag.output(out, opts.merge(:style => :empty))
  else
    @stag.output(out, opts)
    @children.each { |n| n.output(out, opts) }
    if @etag
      @etag.output(out, opts)
    elsif !opts[:preserve]
      ETag.new(@stag.name).output(out, opts)
    end
  end
  out
end

def pathname; self.name end

def pathname; self.name end

def pretty_print(q)

def pretty_print(q)
  if empty?
    q.group(1, '{emptyelem', '}') {
      q.breakable; q.pp @stag
    }
  else
    q.group(1, "{elem", "}") {
      q.breakable; q.pp @stag
      if @children
        @children.each {|elt| q.breakable; q.pp elt }
      end
      if @etag
        q.breakable; q.pp @etag
      end
    }
  end
end

def to_plain_text

def to_plain_text
  if self.name == 'br'
    "\n"
  elsif self.name == 'p'
    "\n\n" + super + "\n\n"
  elsif self.name == 'a' and self.has_attribute?('href')
    "#{super} [#{self['href']}]"
  elsif self.name == 'img' and self.has_attribute?('src')
    "[img:#{self['src']}]"
  else
    super
  end
end