> Strictly speaking, the spec would probably consider these invalid for
> that reason, but the internet really just being a bunch of typing, I
> bet this kind of thing happens all the time and so was wondering if
> there was we could make attributes case insensitive, i.e. calling
> one :album in your Microformat sub-class would find elements with
> class "album" as well as class "Album".
Great question, and idea. This is sorta an Hpricot issue -- we need
to find a way to make Hpricot searches case insensitive.
Observe the current, case sensitive behavior:
>> require 'hpricot'
=> true
>> require 'open-uri'
=> true
>> url = 'http://openmediaweb.org/index.php/2008/01/13/publishing-my-workout-music-in-haudio/'
=> "http://openmediaweb.org/index.php/2008/01/13/publishing-my-workout-music-in-haudio/"
>> doc = Hpricot open(url)
=> #<Hpricot::Doc {doctype BUNCH OF CRAP}>
>> doc/'.album'
=> #<Hpricot::Elements[]>
>> doc/'.Album'
=> #<Hpricot::Elements[{elem BUNCH OF CRAP}]>
The issue is brought up in the Hpricot FAQ:
http://code.whytheluckystiff.net/hpricot/wiki/HpricotChallenge#IgnoringCase
Maybe we can use one of those solutions? Anyone Hpricot users have an
opinion? I definitely agree with you -- Album and album should both
be valid. The spec be damned!
> I looked a bit into figuring out what would be necessary for this but
> the dark black magic heart of microformat.rb makes me think this might
> be an easy change for someone with more familiarity with it to make
> with more confidence than I would as lowly visitor.
It is the blackest of magic hearts. The result of sleeping too little
and dreaming too big.
--
Chris Wanstrath
http://errfree.com // http://errtheblog.com
http://github.com // http://famspam.com
doc/"[@class=Album]|[@class=album]"
This being code by _why, of course the pipe works.
Again, I'm swinging blind through the cloud of black magic here, but
it seems to me like making microformat.rb205 into:
capitalized_key = key.no_bang.to_s.gsub('_','-').capitalize
found = doc/"[@class=#{capitalized_key}]|
[@class=#{capitalized_key.downcase}]"
might do the trick.
Whaddya think?
-- Greg
> How about this?
>
> doc/"[@class=Album]|[@class=album]"
What about class="ALBUM" ? :)
- Chris
After digging around a bit in the hpricot internals, I'm convinced
there's some way to do this by over-riding some regexp-related methods
on the string you pass in to doc/ or doc.search, but I haven't quite
got it yet (if you think your code has a dark heart...I mean jeez!).
-- Greg