Re: [dev] ssam rocks! unwrapping paragraphs

From: Viktor Grigorov <vlg_AT_tutamail.com>
Date: Tue, 22 Mar 2022 21:41:09 +0100 (CET)

Assuming you have a script named lorem that outputs lines with first 10 paragraphs of Cicero's lorem ipsum book/speech, separated by 2 new lines, the below returns 0.

[[ $(lorem | fmt -w 16 | perl -pe 'BEGIN{undef$/}s/(\S ?$)\n\h*(\S)/\1 \2/gm') == $(lorem) ]]



Mar 22, 2022, 21:56 by list_AT_speedpost.net:

> Hello. I downloaded a text file from Project Gutenberg and the paragraphs were hard wrapped, aka filled in Emacs jargon. I want the lines to wrap to whatever window width I am using of course, so I want them to be un-wrapped in the text file. I tried all sorts of sed/awk/grep/perl ways to unwrap the paragraphs (that were complicated), but nothing worked well. Then I did:
>
> ssam -e 'x/\n+/ v/\n\n+/ c/ /'
>
> Bingo! So elegant, so effective. Would you consider adding ssam to 9base? It is a simple script in the Plan9Port project.
>
> I challenge you, if you are interested, to come up with another way of unwrapping the paragraphs that sucks less than the ssam command above.
>
Received on Tue Mar 22 2022 - 21:41:09 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 22 2022 - 21:48:07 CET