From j.m.f@netcologne.de Mon Oct 26 21:11:31 1998 Path: fu-berlin.de!RRZ.Uni-Koeln.DE!news.netcologne.de!gibson.localdomain!not-for-mail From: "Jens M. Felderhoff" Newsgroups: comp.editors Subject: Re: One Newline per Paragraph Date: 24 Oct 1998 13:33:04 +0100 Organization: A small InterNetNews site Lines: 55 Sender: j.m.f@netcologne.de Distribution: inet Message-ID: <87r9vyjg1r.fsf@gibson.localdomain> References: <873e8fvv95.fsf@gibson.localdomain> NNTP-Posting-Host: dial1-6.netcologne.de X-Server-Date: 24 Oct 1998 12:33:05 GMT X-Newsreader: Gnus v5.5/XEmacs 20.4 - "Emerald" Xref: fu-berlin.de comp.editors:34158 "Jens M. Felderhoff" writes: [removing newlines from paragraphs] > Assuming that the very last line of your file is an empty one, you > may try (using vi) > > :v/^$/.,/^$/-1j > > Which means: join all lines from the current position to the next line > before an empty line. This command is performed on all non-empty > lines. > > If the last line is *not* an empty line, a range error will be > reported and the last paragraph retains its newlines. I came up with another, universal, method to remove the newlines using the stream editor sed. You create a sed script, say, join.sed, that contains the following instructions: /^$/!H /^$/{ x s/^\n// s/\n/ /g a\ p d } ${ g s/^\n// s/\n/ /g p } Then you invoke sed with sed -n -f join.sed < oldfile.txt > newfile.txt where oldfile.txt is the original file with newline-separated lines and newfile.txt is the reformatted one. This solution works regardless of the last line being empty or not. Tschuess Jens -- Jens M. Felderhoff home : j.m.f@netcologne.de office: fe@cosa.de From gabor@vmunix.com Mon Oct 26 21:11:35 1998 Path: fu-berlin.de!cyclone.news.idirect.com!island.idirect.com!news1.tor.metronet.ca!nnrp1.tor.metronet.ca!flint.sentex.net!gabor From: gabor@vmunix.com (Gabor) Newsgroups: comp.editors Subject: Re: One Newline per Paragraph Date: 24 Oct 1998 14:22:38 GMT Organization: /dev/null Lines: 48 Message-ID: References: NNTP-Posting-Host: 209.112.4.230 X-No-Archive: yes X-Archive: no X-Newsreader: slrn (0.9.5.2 UNIX) Xref: fu-berlin.de comp.editors:34156 In comp.editors, Paul O Bartlett wrote : # This is sort of an editing question, so I'll post it. # # I subscribe to a small magazine edited and printed in Europe. The # editor cheerfully accepts submissions by email (he might even prefer # them if there are no illustrations). However, this morning on a # somewhat-related mailing list, he announced that he will not accept # submissions in which there is a newline at the end of each line of # text. Apparently he thinks that all the world -- or at least anyone # worth paying attention to -- uses Windooozy or Macinslosh with # Nut$crape or Internut Exploder. Every paragraph is to be a single unit # of text. # # Suppose I were to write an article for this magazine. For a reason # I would compose it under DOS (where I have my dictionary and reference # files -- it's not in English) and then upload to my unix shell account # (SunOS 4.1.4) and email (Pine 3.96). My primary editor under DOS is # SLED, although I have a DOS port of joe, elvis 2.0 (which I have never # learned), and RE 1.12b. On the unix system I use joe. Emacs (19.34.1) # and vi are also available on the unix box, although I don't know emacs # at all, and not much more about vi. # # Somehow I would need to convert every paragraph of the text to a # single long line to satisfy the magazine editor's requirement. joe on # either system would probably not work, as I have not been able to set a # right margin >256 and then reformat paragraphs. I could probably do it # on DOS with SLED, but it would be very tedious, and I don't know # whether the comm link to unix might choke on a, say, 1200-character # wide line. (I've never tried.) # # So apparently I would need to reformat the text on the unix box. # Anyone have any suggestions? I admit that I am not a unix wizard. # # Please reply by email _as_well_as_ posting, because my news feed # is sometimes a little flaky, and I might miss a posted-only reply. # Thanks very much. How about this Perl filter. It only works with Perl5.005 but hey... #!/usr/local/bin/perl require 5.005; $/=undef; while(<>) { s/(?