Re: need a newline between paragraphs....
- From: Gary Kline <kline@xxxxxxxxxxx>
- Date: Wed, 25 Nov 2009 20:32:39 -0800
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@xxxxxxxxxxx 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
_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"
- References:
- need a newline between paragraphs....
- From: Gary Kline
- Re: need a newline between paragraphs....
- From: Chris Cowart
- Re: need a newline between paragraphs....
- From: Gary Kline
- Re: need a newline between paragraphs....
- From: Chad Perrin
- Re: need a newline between paragraphs....
- From: Gary Kline
- Re: need a newline between paragraphs....
- From: Chad Perrin
- need a newline between paragraphs....
- Prev by Date: SAME: Re: need help; cacti fails to build on 7.2-R, p4....
- Next by Date: MUA questions
- Previous by thread: Re: need a newline between paragraphs....
- Next by thread: Interested in Advertising On freebsd.org
- Index(es):
Relevant Pages
|