#!/usr/bin/perl # html_indenting2.pl perl html_indenting2.pl HTML indenting with Perl. # From http://stackoverflow.com/questions/8225194/html-indenting-with-perl best answer use strict; use warnings; use HTML::HTML5::Parser qw(); use HTML::HTML5::Writer qw(); use XML::LibXML::PrettyPrint qw(); print HTML::HTML5::Writer->new( start_tags => 'force', end_tags => 'force', )->document( XML::LibXML::PrettyPrint->new_for_html( indent_string => "\t" )->pretty_print( HTML::HTML5::Parser->new->parse_string( q[ ] ) ) ); # This prints: # #
# # # # # __END__