Date: Wed, 25 Nov 2009 13:08:39 -0700 From: Chad Perrin <perrin@apotheon.com> To: Gary Kline <kline@thought.org> Cc: FreeBSD Mailing List <freebsd-questions@FreeBSD.ORG> Subject: Re: need a newline between paragraphs.... Message-ID: <20091125200839.GA4487@guilt.hydra> In-Reply-To: <20091124211942.GF54631@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>
next in thread | previous in thread | raw e-mail | index | archive | help
--r5Pyd7+fXNt84Ff3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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: >=20 > 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 =3D <$fh>; } $contents =3D~ 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 =3D~ s/\s*\n+/\n\n/g; =2E . . 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). >=20 > there are a few places that require different formatting;=20 > 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! --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --r5Pyd7+fXNt84Ff3 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) iEYEARECAAYFAksNjscACgkQ9mn/Pj01uKV7XwCfbJqyZ5H+tvsxcUj9ah+e2+bB vTkAn0i3aVtyRwY3xUNnRtTvW4QiGMw5 =zMsO -----END PGP SIGNATURE----- --r5Pyd7+fXNt84Ff3--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20091125200839.GA4487>