Out of curiosity, why do you say that the problem has not been solved?

Prior to your claim that "this problem is not solved in both end", I posted to both forums (here at PerlMonks and here at Stack Overflow) a suggestion to check out HTML::Valid.

According to the documentation of HTML::Tidy, you need to have tidyp installed first and tidyp appears to be a fork of tidy and that site indicates that it is the "HTML Tidy Legacy Website". The HTML::Valid module is based on the HTML Tidy project and it does support HTML5.

And I'll take it a bit further. Here's a demonstration of HTML::Valid on the OP's posted HTML/XHTML data.

I created a test.html file with the following content (from the OP):

<?xml version="1.0" encoding="utf-8"?><html xmlns:svg="http://www.w3.o +rg 2000/svg" xmlns="http://www.w3.org/1999/xhtml" xmlns:m="http://www +.w3.org 1998/Math/MathML" xml:lang="en" lang="en"> <head> <link rel="stylesheet" type="text/css" title="day" href="../css/main.c +ss"/> <title>Electric Potential and Electric Potential Energy</title> <meta charset="UTF-8"/> <meta name="dcterms.conformsTo" content="PXE 1.39 ProductLevelReuse"/> <meta name="generator" content="PXE Tools version 1.39.69"/> </head> <body> <section class="chapter" ><header><h1 class="title"><span class="numbe +r">20</span> Electric Potential and Electric Potential Energy</h1></h +eader> <section class="frontmatter"> <section class="listgroup"><header><h1 class="title">Big Ideas</h1></h +eader> <ol> <li><p>Electric potential energy is similar to gravitational potential + energy.</p></li> </ol> </section> </section> </body> </html>

And here's the Perl code that uses HTML::Valid to check that file:

use strict; use warnings; use feature 'say'; use HTML::Valid; use Path::Tiny; my $file = 'test.html'; my $content = path($file)->slurp; my $validate = HTML::Valid->new(); my ($output,$errors) = $validate->run($content); say "Output:\n$output\n"; say "Errors:\n$errors";

And here's the output of that script:

Output: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html> <html xmlns:svg="http://www.w3.org 2000/svg" xmlns= "http://www.w3.org/1999/xhtml" xmlns:m= "http://www.w3.org 1998/Math/MathML" xml:lang="en" lang="en"> <head> <meta name="generator" content= "HTML Tidy for HTML5 for Windows version 5.0.0" /> <link rel="stylesheet" type="text/css" title="day" href= "../css/main.css" /> <title>Electric Potential and Electric Potential Energy</title> <meta charset="UTF-8" /> <meta name="dcterms.conformsTo" content= "PXE 1.39 ProductLevelReuse" /> <meta name="generator" content="PXE Tools version 1.39.69" /> </head> <body> <section class="chapter"> <header> <h1 class="title"><span class="number">20</span> Electric Potential and Electric Potential Energy</h1> </header> <section class="frontmatter"> <section class="listgroup"> <header> <h1 class="title">Big Ideas</h1> </header> <ol> <li> <p>Electric potential energy is similar to gravitational potential energy.</p> </li> </ol> </section> </section> </section> </body> </html> Errors: line 1 column 39 - Warning: missing <!DOCTYPE> declaration line 10 column 1 - Warning: missing </section> line 1 column 39 - Warning: <html> proprietary attribute "xmlns:svg" line 1 column 39 - Warning: <html> proprietary attribute "xmlns:m" Info: Document content looks like XHTML5 4 warnings, 0 errors were found!

That shows that HTML::Valid is not having issues dealing with <section> tags and that is also provides line numbers and column numbers as the OP stated here as something that was needed. Unfortunately it looks like HTML::Valid does not have an ignore method that was in the OP's code had that used HTML::Tidy, so the OP may need to write a little bit more code to parse out the messages concerning tags that the OP wants to ignore.

Unless I totally misunderstood what the "problem" was, it looks like HTML::Valid "solves" the "problem".


In reply to Re^3: How to parse HTML5? by dasgar
in thread How to parse HTML5? by NRan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.