diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-10-21 21:41:34 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-10-21 21:41:34 +0000 |
commit | a5fdebc5f6375078ec1763850a4ca23ec7fe6458 (patch) | |
tree | bcf0a25c3d45a209a6e3ac37b233a4812f29c732 /bin/man2html1.awk | |
download | ATCD-a5fdebc5f6375078ec1763850a4ca23ec7fe6458.tar.gz |
Initial revision
Diffstat (limited to 'bin/man2html1.awk')
-rw-r--r-- | bin/man2html1.awk | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/bin/man2html1.awk b/bin/man2html1.awk new file mode 100644 index 00000000000..a780ab70c9f --- /dev/null +++ b/bin/man2html1.awk @@ -0,0 +1,139 @@ +#!/bin/nawk + + +# defining macros - eat them +/^\.de.*/ { + getline + while ( $0 !~ "^\.\.$" ) + { + getline + } + getline + } + +# eat [nt]roff comments +$0 ~ /['.][\/\\]"/ || $1 == "'" { next } + +# remove sidebar macros +$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 "<TITLE>" $0 "</TITLE>" + print "<H1>" $0 "</H1>\n" + next + +#-e 's/^.SH *NAME */{N;s#.*\n\(.*\)#<H1>\1</H1>#;}' \ + } + + +# Convert .IP Paragraphs upto next .cmd to hanging indents +# using <DL></DL> pairs without intervening <LI> + +/^\.IP */ { + if ( inIP > 0 ) + { + print "</DL>" + } + inIP = 1 + startIP = 1 + print "<DL>" + match($0, /".*"/ ) + if ( RSTART > 0 ) + { + arg = substr( $0, RSTART+1, RLENGTH-2) + + print "<DT> " arg + } + else if ( length( $2 ) > 0 ) + { + print "<DT> " $2 + } + next + } + +$0 ~ /^\.[a-zA-Z]*/ && inIP > 0 { + inIP = 0 + print "</DL>" + } + +# Convert +# .TP +# Line1 +# line 2 - n +# .Any +# +# to +# <DL> +# <DT> Line1 +# <DD> lines 2 - n +# <DT> + +/^\.TP */ { + if ( inTP > 0 ) + { + print "</DL>" + } + inTP = 1 + print "<DL>" + next + } + +inTP == 1 && $1 !~ /\.[a-zA-Z]*/ { + print "<DT> " $0 + inTP = 2 + next + } + +inTP == 2 && $1 !~ /\.[a-zA-Z]*/{ + print "</I></B>" # Belt and suspenders + print "<DD> " $0 + inTP = 3 + next + } + +$0 ~ /^\.[a-zA-Z]*/ && inTP > 0 { + inTP = 0 + print "</DL>" + } + + + +$1 == ".AP" { + $1="" + print "<DL >" + print "<DT> " $2 "\t\t" $3 "\t\t("$4")" + inTP = 2 + next + } + +# make a blank line +$1 == ".sp" { + print "<BR>" + next # print "<BR>" + } + + +$1 == ".ta" { next } + +# just pass everything else on + + { + if ( startIP > 0 ) + { + print "<DD> " $0 + startIP = 0 + } + else + { + print $0 + } + } + + |