A limited solution (no table or frame support) is the Cookbook's Recipe 20.5:
use strict; use HTML::FormatText; use HTML::Parse; my $data = do {local $/;<DATA>}; my $html = parse_html($data); my $formatter = HTML::FormatText->new( leftmargin => 0, rightmargin => 50, ); my $ascii = $formatter->format($html); print "$ascii\n"; __DATA__ <p class="fol">Here's some text that goes in the body of the article. It has some list items like this:</p> <ul> <li>List item one</li> <li>List item two</li> </ul>
This generates the following output:
Here's some text that goes in the body of the
article. It has some list items like this:

  * List item one

  * List item two

I have found that converting HTML to text is hard, and the best free tool i have found so far is lynx -dump. Of course, the most optimal solution is to never mix presentation with data! :)

Update: in case you are wondering where that extra bullet came from, it is the result of the closing li tags. Looks like HTML::FormatText could use an upgrade to support XHTML. -- good catch Hero Zzyzzx! ;) I fixed this typo since hacker requested i fix the original. For historical purposes, the first list item looked like so: <li>List item one<li>.

jeffa

Remember kids, just say no to mixing data and presentation!

In reply to (jeffa) Re: HTML input to PDF output by jeffa
in thread HTML input to PDF output by hacker

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.