ankane / ahoy_email

First-party email analytics for Rails
MIT License
1.11k stars 137 forks source link

Allow parsing with HTML5 #162

Open jesseduffield opened 3 months ago

jesseduffield commented 3 months ago

Fixes https://github.com/ankane/ahoy_email/issues/58 Fixed https://github.com/ankane/ahoy_email/issues/148 (at least I assume that OP was using tables)

Nokogiri is on the path to parsing with HTML5 by default: https://github.com/sparklemotion/nokogiri/issues/2331

But, there are some things they still need to do. For those of us who want to opt-in to HTML5 parsing, I've added an option for it. This will prevent the gem from messing with the structure of the html (specifically, prematurely closing tags that wrapped table elements.

I've made sure to leave the gem completely unchanged for those who do not opt-in.

ankane commented 2 months ago

Hi @jesseduffield, thanks for the PR (including tests)! Looks really great overall. I think we should have nil be the default (and use Nokogiri::HTML), and have false use Nokogiri::HTML4.