On Sat, Mar 30, 2002 at 02:31:06PM -0600, dman wrote: > On Sun, Mar 31, 2002 at 02:41:31AM +0800, csj wrote: > | What's the fastest way to reformat a mutt-friendly text file into > | something a WYSIWYG word processor would love? > | > | Let's take this email as an example. When I use the linewrap command in > | Sylpheed, the text of my email is broken into shorter lines. But when I > | cut and paste these selfsame lines into Abiword or KWord, they appear as > | a series of short individual paragraphs (as indicated by the reverse "P" > | sign in AbiWord or the Enter key symbol in KWord). > > Yeah, mailers put linefeeds in so that they won't exceed the 1000 > character SMTP limit on line length. (I recently saw a web based > mailer fail to do that, and each "paragraph" that was too long was > truncated)
You could use fmt(1), then. It has a bug where it segfaults when given a very long line length (#94207), but 'fmt -w1000' isn't long enough to trigger this. > #!/usr/bin/env python > > import sys > p = [] > for line in sys.xreadlines() : > l = line.strip() # strip all leading and trailing whitespace > if l : > p.append( l ) > else : > print " ".join( p ) > # uncomment the next line if you want a blank line in between > paragraphs. > #print > p = [] You'll probably miss the last paragraph that way, although I haven't tested yours either. :) (Do you mean sys.stdin.xreadlines()?) -- Colin Watson [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]