Changeset 92

Show
Ignore:
Timestamp:
12/26/2006 21:07:03 (2 years ago)
Author:
why
Message:
  • lib/hpricot/tag.rb: basic img tag in to_plain_text.
  • lib/hpricot/traverse.rb: node_position is the index among all sibling nodes, while position is the position among children of identical type.
Location:
trunk/lib/hpricot
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/hpricot/tag.rb

    r91 r92  
    6060      elsif self.name == 'a' and self.has_attribute?('href') 
    6161        "#{super} [#{self['href']}]" 
     62      elsif self.name == 'img' and self.has_attribute?('src') 
     63        "[img:#{self['src']}]" 
    6264      else 
    6365        super 
  • trunk/lib/hpricot/traverse.rb

    r91 r92  
    103103    def to_plain_text 
    104104      if respond_to? :children 
    105         children.map { |x| x.to_plain_text }.join.strip 
     105        children.map { |x| x.to_plain_text }.join.strip.gsub(/\n{2,}/, "\n\n") 
    106106      end 
    107107    end 
     
    183183        p 
    184184      end 
     185    end 
     186 
     187    def node_position 
     188      parent.children.index(self) 
    185189    end 
    186190