Date: Wed, 25 Nov 2009 20:32:39 -0800 From: Gary Kline <kline@thought.org> To: FreeBSD Mailing List <freebsd-questions@FreeBSD.ORG> Subject: Re: need a newline between paragraphs.... Message-ID: <20091126043239.GA70947@thought.org> In-Reply-To: <20091125200839.GA4487@guilt.hydra> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20091126043239.GA70947>