Plan 9 from Bell Labs’s /usr/web/sources/contrib/alltom/para

Copyright © 2009 Alcatel-Lucent.
Distributed under the Lucent Public License version 1.02.
Download the Plan 9 distribution.


#!/bin/rc
# para - add paragraph tags to text
# (if a paragraph begins with an HTML tag, skip it

awk '
/^<[^\/]/ { html += 1; }
/./ { line(); if(last_line) print last_line; last_line = $0 }
/^$/ { newpara(); last_line = $0; print "" }
END { newpara() }
/^<\// { html -= 1; }

function newpara() {
	printf("%s", last_line);
	if(!html && inpara) print "</p>";
	else print "";
	inpara = 0;
}

function line() {
	if(!html && !inpara) {
		printf("<p>");
		inpara = 1;
	}
}
' $*

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2009 Alcatel-Lucent. All Rights Reserved.
Comments to webmaster@plan9.bell-labs.com.