Files
kewt/awk/paragraphs.awk
N0\A 3075719963
All checks were successful
Lint / shellcheck (push) Successful in 21s
Release Standalone Builder / build (release) Successful in 33s
Release Standalone Builder / publish-aur (release) Successful in 36s
Release Standalone Builder / publish-homebrew (release) Successful in 7s
feat: might be actually feature-complete by now
2026-03-26 13:16:34 +01:00

44 lines
686 B
Awk

BEGIN {
in_p = 0
in_pre = 0
}
{
if ($0 ~ /^<pre>/) in_pre = 1
if (in_pre) {
if (in_p) { print "</p>"; in_p = 0 }
print
if ($0 ~ /<\/pre>/) in_pre = 0
next
}
if ($0 ~ /^<\/?(div|table|p|[ou]l|h[1-6]|[bh]r|blockquote|li|hr|section|article|nav|aside|header|footer|dl|dt|dd)/) {
if (in_p) {
print "</p>"
in_p = 0
}
print
next
}
if ($0 == "") {
if (in_p) {
print "</p>"
in_p = 0
}
print
next
}
if (!in_p) {
print "<p>"
in_p = 1
}
print
}
END {
if (in_p) print "</p>"
}