microformats / microformats-ruby

Ruby gem that parse HTML containing microformats/microformats2 and returns Ruby objects, a Ruby hash or a JSON hash
https://rubygems.org/gems/microformats
Creative Commons Zero v1.0 Universal
100 stars 29 forks source link

No author URL in 4.0.9 (Breaking change) #102

Open Gargron opened 6 years ago

Gargron commented 6 years ago
undefined method `url' for #<Microformats::ParserResult:0x00005556e27ddaa0>

when accessing mf2.entry.comment.author.url in 4.0.9. This is a breaking change from 4.0.7 where it worked fine.

dissolve commented 6 years ago

I was able to reproduce this issue with a random post from your account, and it looks to be caused by the microformats spec having changed the implied u-url rules. Since u-photo exists, it no longer implies a u-url. I realize now that should have been a version bump as that is actually a breaking change.

dissolve commented 6 years ago

Example html to reproduce.

` <div class="h-entry"> <div class="h-cite p-comment"> <a class="statusdisplay-name p-author h-card" rel="noopener" href="https://site.example/@AwesomeUser"> <img width="48" height="48" alt="" class="u-photo accountavatar" src="https://site.example/user-photo.png" /> <strong class="display-name__html p-name emojify">AwesomeUser</strong> </a> </div> </div>

`

Not sure if we should roll back the version at this point @jgarber623 thoughts?

Going forward, I would recommend specifying the u-url as no new parser will get this url value. If you wrap move the classes out of the A tag to a containing tag it will work.

<div class="h-entry"> <div class="h-cite p-comment"> <div class="p-author h-card"> <a class="statusdisplay-name u-url" rel="noopener" href="https://site.example/@AwesomeUser"> <img width="48" height="48" alt="" class="u-photo accountavatar" src="https://site.example/user-photo.png" /> <strong class="display-name__html p-name emojify">AwesomeUser</strong> </a> </div> </div> </div>`