No such thing as a small change | |
PerlMonks |
Rewrapping Net::NNTP outputby hacker (Priest) |
on Feb 24, 2005 at 14:50 UTC ( [id://434084]=perlquestion: print w/replies, xml ) | Need Help?? |
hacker has asked for the wisdom of the Perl Monks concerning the following question: Lately, I've been spending a lot of time getting very familiar with XML, specifically with RSS, RDF, and Atom feeds. To that end, I've written a script that uses Net::NNTP to fetch news articles and creates an RSS feed out of them. From there, I can convert that feed to HTML, which I then convert to a format suitable for display on a Palm handheld device, using Plucker. I do this in two formats because I specifically need it in both RSS and HTML formats simultaneously. So far, so good. My question is.. how do I take the body of the news article I receive, and "rewrap" the text, so it fits within a known width? I know about Text::Wrap, but this would require a bit more thinking to get right with the quoted material (custom regexes?). The body of an article generally has quoted material buried somewhere within it, with '>' at the beginning of the quoted lines. This becomes a problem when the lines are quoting quoted material, like this:
What I'd like to figure out, is how to rewrap this text, keeping the same kind of aspect, based on the width of the target device (which I will know before I convert it). For example, wrapping the text to a maximum width of 320 pixels, or a maximum width of 160 pixels, and so on.
Back to
Seekers of Perl Wisdom
|
|