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

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
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 © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].