in reply to Re^3: Testing generated HTML
in thread [Solved] Testing generated HTML

Unfortunately, libxml2's HTML Parser doesn't support HTML5. If you want to use XML::LibXML, you need to switch to XHTML.

Another solution might be to switch to Polyglot Markup. This is valid HTML5 which is also well-formed XML, so you get the best of both worlds. It was all the rage a few years back, but you don't seem to see it mentioned much nowadays

Replies are listed 'Best First'.
Re^5: Testing generated HTML
by davies (Monsignor) on Feb 22, 2016 at 14:01 UTC

    I'm not particularly keen on changing the markup. I needed choroba to tell me that the tools I am using and copying (Dancer2, Template::Toolkit and Bootstrap) are producing HTML5; it's not something I could work out for myself. The purpose of my OP was to get something that would allow me to write tests based on the output of all this. To have a tool in the test framework dictate the content of the page seems to me to be a bad case of the tail wagging the dog. But I'll gladly listen to arguments that I should change.

    Regards,

    John Davies

      My post was just pointing out that you don't have to chose between HTML5 and XHTML - if you use polyglot (which is really just HTML5 with a few simple tweaks) you get valid HTML5 which can also be tested using all those useful XML modules. Anyone wanting to parse the pages you produce will also have an easier job.

      I've written a couple of Dancer2 / Template::Toolkit applications which output Polyglot HTML5 , and it's not really much more work than straight HTML; once you take into account how much more straightforward it is to write tests for XML rather than HTML, it will probably save you time in the long run

      I take your point about the tail wagging the dog, but I just think Polyglot produces 'better' output than straight HTML in any case (others may disagree) - the fact that writing tests becomes a lot easier is a consequence of this, rather than the main reason for changing.