rendler has asked for the wisdom of the Perl Monks concerning the following question:

I've been trying to use HTML::PrettyPrinter with a little difficulty, it seems that the module inserts tags such as html, body and head automatically which I do not want because the HTML I am wanting to format are only snippets. I've racked my brains going through the man page of the module and of HTML::TreeBuilder and still can't figure out how to stop it from inserting those 'implicit' tags, I've tried messing around with group_remove() but to no avail.

Replies are listed 'Best First'.
•Re: HTML::PrettyPrinter woes
by merlyn (Sage) on Feb 25, 2002 at 23:37 UTC
    If your "snippet" would always appear in the body, you can fake a wrapper of <html><head></head><body>...</body></html> around the text, run the pretty printer, and then strip the wrapper off. Otherwise, there's probably not much else you can do.

    -- Randal L. Schwartz, Perl hacker

      Thanks for that.
Re: HTML::PrettyPrinter woes
by Zaxo (Archbishop) on Feb 26, 2002 at 06:35 UTC

    This isn't the context where we usually say use CGI or die;, but ...

    use CGI::Pretty; print CGI::table(CGI::Tr(CGI::td([A=>B=>C=>])));
    will happily print pretty fragments without worrying about correctness of the entire document.

    After Compline,
    Zaxo

      CGI uurrggg :P I like to generate the HTML by hand, it's easier and more flexible for me.