#!/bin/nawk
$0 ~ /'[\/\\]" */ || $1 == "'" { next } # eat [nt]roff comments
# defining macros - eat them
/^\.de.*/ {
getline
while ( $0 !~ "^\.\.$" )
{
getline
}
getline
}
$1 == ".VS" || $1 == ".VE" || $1 == ".AS" { next }
# handle first .SH as special case - .SH NAME
/^.SH *NAME */ {
getline
while ( $0 ~ /\.[a-zA-Z].*/ ) # eat dot-cmd following title
{
getline
}
print "
" $0 ""
print "" $0 "
\n"
next
#-e 's/^.SH *NAME */{N;s#.*\n\(.*\)#\1
#;}' \
}
# Convert .IP Paragraphs upto next .cmd to hanging indents
# using pairs without intervening
/^\.IP */ {
if ( inIP > 0 )
{
print ""
}
inIP = 1
print ""
match($0, /".*"/ )
if ( RSTART > 0 )
{
arg = substr( $0, RSTART+1, RLENGTH-2)
print arg "
"
}
else if ( length( $2 ) > 0 )
{
print $2 "
"
}
next
}
$0 ~ /^\.[a-zA-Z]*/ && inIP > 0 {
inIP = 0
print "
"
}
# Convert
# .TP
# Line1
# line 2 - n
# .Any
#
# to
#
# - Line1
#
- lines 2 - n
#
-
/^\.TP */ {
if ( inTP > 0 )
{
print "
"
}
inTP = 1
print ""
next
}
inTP == 1 && $1 !~ /\.[a-zA-Z]*/ {
print "- " $0
inTP = 2
next
}
inTP == 2 && $1 !~ /\.[a-zA-Z]*/{
print "" # Belt and suspenders
print "
- " $0
inTP = 3
next
}
$0 ~ /^\.[a-zA-Z]*/ && inTP > 0 {
inTP = 0
print "
"
}
$1 == ".AP" {
$1=""
print ""
print "- " $2 "\t\t" $3 "\t\t("$4")"
inTP = 2
next
}
# make a blank line
$1 == ".sp" {
print "
"
next # print "
"
}
$1 == ".ta" { next }
# try and make links ( tk )
# "See the .* manual entry"
/"options"/ {
if ( $0 ~ /^See the .*/ )
sub("\"options\"", " \"options\" ")
}
/"entry"/ {
if ( $0 ~ /^See the .*/ )
sub("\"entry\"", " \"entry\" ")
}
/"button"/ {
if ( $0 ~ /^See the .*/ )
sub("\"button\"", " \"button\" ")
}
/"scrollbar"/ {
if ( $0 ~ /^See the .*/ )
sub("\"scrollbar\"", " \"scrollbar\" ")
}
/"listbox"/ {
if ( $0 ~ /^See the .*/ )
sub("\"listbox\"", " \"listbox\" ")
}
/"canvas"/ {
if ( $0 ~ /^See the .*/ )
sub("\"canvas\"", " \"canvas\" ")
}
/"text"/ {
if ( $0 ~ /^See the .*/ )
sub("\"text\"", " \"text\" ")
}
/"license.terms"/ {
if ( $0 ~ /^See the .*/ )
sub("\"license\".terms", " license.\"terms\" ")
}
/"buttonbox"/ {
if ( $0 ~ /^See the .*/ )
sub("\"buttonbox\"", " \"buttonbox\" ")
}
/"combobox"/ {
if ( $0 ~ /^See the .*/ )
sub("\"combobox\"", " \"combobox\" ")
}
/"dialog"/ {
if ( $0 ~ /^See the .*/ )
sub("\"dialog\"", " \"dialog\" ")
}
/"dialogshell"/ {
if ( $0 ~ /^See the .*/ )
sub("\"dialogshell\"", " \"dialogshell\" ")
}
/"entryfield"/ {
if ( $0 ~ /^See the .*/ )
sub("\"entryfield\"", " \"entryfield\" ")
}
/"fileselectionbox"/ {
if ( $0 ~ /^See the .*/ )
sub("\"fileselectionbox\"", " \"fileselectionbox\" ")
}
/"fileselectiondialog"/ {
if ( $0 ~ /^See the .*/ )
sub("\"fileselectiondialog\"", " \"fileselectiondialog\" ")
}
/"labeledwidget"/ {
if ( $0 ~ /^See the .*/ )
sub("\"labeledwidget\"", " \"labeledwidget\" ")
}
/"messagedialog"/ {
if ( $0 ~ /^See the .*/ )
sub("\"messagedialog\"", " \"messagedialog\" ")
}
/"optionmenu"/ {
if ( $0 ~ /^See the .*/ )
sub("\"optionmenu\"", " \"optionmenu\" ")
}
/"panedwindow"/ {
if ( $0 ~ /^See the .*/ )
sub("\"panedwindow\"", " \"panedwindow\" ")
}
/"promptdialog"/ {
if ( $0 ~ /^See the .*/ )
sub("\"promptdialog\"", " \"promptdialog\" ")
}
/"pushbutton"/ {
if ( $0 ~ /^See the .*/ )
sub("\"pushbutton\"", " \"pushbutton\" ")
}
/"scrolledcanvas"/ {
if ( $0 ~ /^See the .*/ )
sub("\"scrolledcanvas\"", " \"scrolledcanvas\" ")
}
/"scrolledframe"/ {
if ( $0 ~ /^See the .*/ )
sub("\"scrolledframe\"", " \"scrolledframe\" ")
}
/"scrolledlistbox"/ {
if ( $0 ~ /^See the .*/ )
sub("\"scrolledlistbox\"", " \"scrolledlistbox\" ")
}
/"scrolledtext"/ {
if ( $0 ~ /^See the .*/ )
sub("\"scrolledtext\"", " \"scrolledtext\" ")
}
/"selectionbox"/ {
if ( $0 ~ /^See the .*/ )
sub("\"selectionbox\"", " \"selectionbox\" ")
}
/"selectiondialog"/ {
if ( $0 ~ /^See the .*/ )
sub("\"selectiondialog\"", " \"selectiondialog\" ")
}
/"spindate"/ {
if ( $0 ~ /^See the .*/ )
sub("\"spindate\"", " \"spindate\" ")
}
/"spinint"/ {
if ( $0 ~ /^See the .*/ )
sub("\"spinint\"", " \"spinint\" ")
}
/"spinner"/ {
if ( $0 ~ /^See the .*/ )
sub("\"spinner\"", " \"spinner\" ")
}
/"spintime"/ {
if ( $0 ~ /^See the .*/ )
sub("\"spintime\"", " \"spintime\" ")
}
/^Name: */ {
print $1 " " $2
next
}
/^Class: */ {
print $1 " " $2
next
}
/^Bret A. Schuhmacher*/ {
print "" $0 ""
next
}
/^John S. Sigler*/ {
print "" $0 ""
next
}
/^Mark L. Ulferts*/ {
print "" $0 ""
next
}
/^Alfredo Jahn*/ {
print "" $0 ""
next
}
/^Sue Yockey*/ {
print "" $0 ""
next
}
# just pass everything else on
{ print $0 }