fixed duplicate elements bug

This commit is contained in:
Shane Becker 2011-06-28 19:00:56 -07:00
parent b35a24becc
commit 0903ac0fab
3 changed files with 375 additions and 19 deletions

View file

@ -10,9 +10,12 @@ module Microformats2
def self.parse(html)
raise LoadError, "argument must be a String or File" unless [String, File].include?(html.class)
html = html.read if IO === html
doc = Nokogiri::HTML(html)
microformats = Hash.new{|hash, key| hash[key] = Array.new}
doc.css("*[class^=h-]").each do |microformat|
doc.css("*[class|=h]").each do |microformat|
constant_name = classify(microformat.attribute("class").to_s.gsub("-","_"))
if Object.const_defined?(constant_name)
@ -33,7 +36,7 @@ module Microformats2
microformats[constant_name.downcase.to_sym] << obj
end
return microformats
microformats
end
def self.add_method(obj, method_name)