Prettify / Beautify HTML in Perl -


i have html output sitting in variable prettify / beautify struggling make sense out of results of web searches.

most of options have found such perltidy (not sure correct option) appear assume html in file in case, has been put in perl script , stored in variable , wanted fix removing excess line breaks , indenting , saving variable before sending output.

looking along lines of

$output= someperlmodule::prettify($html); 

which can jut add exiting script.

a bonus if can remove orphaned end tags. basically, have end tags such without start tags , while browsers seem able deal this, nice strip these out.

is there such module?

html::tidy that:

#!/usr/bin/perl use strict; use warnings;  use html::tidy;  $str = '<div><p>text<h2>heading</h2>'; $tidy = 'html::tidy'->new; print $tidy->clean($str); 

output

<!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <meta name="generator" content="tidyp linux (v1.04), see www.w3.org"> <title></title> </head> <body> <div> <p>text</p> <h2>heading</h2> </div> </body> </html> 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -