Not only can tidy fix things, it can tell you what went wrong:
Tidy has a great markup parser which intelligently corrects a wide range of errors:

Displaying the error buffer
<?php
    $tidy 
tidy_parse_file("intro2_ex1.html");
    
tidy_clean_repair($tidy);
    echo 
tidy_get_error_buffer($tidy);
?>
Result
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 1 column 11 - Warning: replacing unexpected i by </i>
line 1 column 27 - Warning: replacing unexpected u by </u>
line 1 column 49 - Warning: discarding unexpected </b>
line 1 column 1 - Warning: inserting missing 'title' element