From owner-freebsd-questions@FreeBSD.ORG Thu Nov 26 04:32:45 2009 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 046C0106566B for ; Thu, 26 Nov 2009 04:32:45 +0000 (UTC) (envelope-from kline@thought.org) Received: from aristotle.thought.org (ns1.thought.org [209.180.213.210]) by mx1.freebsd.org (Postfix) with ESMTP id AFBA98FC16 for ; Thu, 26 Nov 2009 04:32:44 +0000 (UTC) Received: from thought.org (tao.thought.org [10.47.0.250]) (authenticated bits=0) by aristotle.thought.org (8.14.2/8.14.2) with ESMTP id nAQ4WHuW033942 for ; Wed, 25 Nov 2009 20:32:18 -0800 (PST) (envelope-from kline@thought.org) Received: by thought.org (nbSMTP-1.00) for uid 1002 kline@thought.org; Wed, 25 Nov 2009 20:32:39 -0800 (PST) Date: Wed, 25 Nov 2009 20:32:39 -0800 From: Gary Kline To: FreeBSD Mailing List Message-ID: <20091126043239.GA70947@thought.org> References: <20091124002920.GA51110@thought.org> <20091124003652.GH11723@hal.rescomp.berkeley.edu> <20091124013934.GA51279@thought.org> <20091124200741.GA1799@guilt.hydra> <20091124211942.GF54631@thought.org> <20091125200839.GA4487@guilt.hydra> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20091125200839.GA4487@guilt.hydra> User-Agent: Mutt/1.4.2.3i X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: With 23 years of service to the Unix community. X-Spam-Status: No, score=-4.4 required=3.6 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on aristotle.thought.org Cc: Subject: Re: need a newline between paragraphs.... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Nov 2009 04:32:45 -0000 On Wed, Nov 25, 2009 at 01:08:39PM -0700, Chad Perrin wrote: > On Tue, Nov 24, 2009 at 01:19:42PM -0800, Gary Kline wrote: > > On Tue, Nov 24, 2009 at 01:07:41PM -0700, Chad Perrin wrote: > > > > precisely. in this case, every paragraph that is not on a > > newline wraps. so anything that has an EOL is a new > > paragraph. > > If I understand you correctly, the following should work for your > purposes (as a naive implementation of the concept): > > my $contents; > > { > undef $/; > open(my $fh, '<', $in_filename) or die $!; > $contents = <$fh>; > } > > $contents =~ s/\n+/\n\n/g; > > { > open(my $fh, '>', $out_filename) or die $!; > print($fh $contents); > } > > That assumes that you want to turn any and all instances of one or more > consecutive newlines into exacty two newlines. More finagling might be > required if there may be other adjacent whitespace, which would need to > account for not only possible adjacent whitespace but also possible > whitespace at the beginning of a line with other text on it. Maybe > something like this: > > $contents =~ s/\s*\n+/\n\n/g; > > . . . though I haven't thought it through in too much depth with regards > to the implications in edge case circumstances (thus the "naive > implementation" comment above). > Turns out that the problem was resolved by the print $fh "$_$/"; or close to that. Since I scrubbed 100% of newlines -- and axing all whitespace before and after lines -- before handing off the large file to OpenOffice, there wasn't any concern about extra whitespace messing stuff up. > > > > > there are a few places that require different formatting; > > these are easily re-done thanks to OOo! > > I'm the kind of guy who would look for a way to automate things so that > re-formatting in OOo wouldn't be necessary, but as long as you're happy, > I guess we win. Good luck! > Hm. Y'know, if *somebody* would just make having vim as an option along with OOo, along with wrapping all the lines, life would be (abs)Perfect. I would nevr complain about anything; not ever. My fingers know vi; I've used vi since BillJoy invented it and handed me the first docs. It only took a couple weeks to learn, and I still don't know all the tricks. But enough to do what I *NEED* to, and with fewer fumbles _(or hurting my arm/shoulder that using the word-processor with mouse + keybd). having scripts to switch between file and file.txt|.odt gets pretty close :-) thanks much, gary > -- > Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] -- Gary Kline kline@thought.org http://www.thought.org Public Service Unix http://jottings.thought.org http://transfinite.thought.org The 7.31a release of Jottings: http://jottings.thought.org/index.php