diff --git a/README.md b/README.md index d47bbdf..3986f1f 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ Generic Microformats 2 Extractor * parses and extracts [Microformats 2](http://microformats.org/wiki/microformats-2) syntax * needs more test cases * needs better docs +* needs to deal with nested microformats +* needs to deal with class-value pattern ## SYNOPSIS diff --git a/lib/microformats2.rb b/lib/microformats2.rb index 75f0f9f..f74fbc7 100644 --- a/lib/microformats2.rb +++ b/lib/microformats2.rb @@ -72,7 +72,13 @@ module Microformats2 class Date def transform(property) - DateTime.parse((property.attribute("title") || property.text).to_s) + value = (property.attribute("title") || property.text).to_s + + if value[0..0] =~ /[a-zA-Z]/ + value + else + DateTime.parse(value) + end end end @@ -100,6 +106,10 @@ module Microformats2 css_class = css_class[2..-1].gsub("-","_") method_name = css_class.gsub("-","_") value = trans.transform(property) + + if method_name == "class" + method_name = "klass" + end add_method(obj, method_name) populate_method(obj, method_name, value) diff --git a/test/hcalendar.html b/test/hcalendar.html index 7c33616..1de7334 100644 --- a/test/hcalendar.html +++ b/test/hcalendar.html @@ -36,7 +36,7 @@