######################################################################## # # # This software is part of the ast package # # Copyright (c) 1996-2012 AT&T Intellectual Property # # and is licensed under the # # Eclipse Public License, Version 1.0 # # by AT&T Intellectual Property # # # # A copy of the License is available at # # http://www.eclipse.org/org/documents/epl-v10.html # # (with md5 checksum b35adb5213ca9657e911e9befb180842) # # # # Information and Software Systems Research # # AT&T Research # # Florham Park NJ # # # # Glenn Fowler # # # ######################################################################## : mm2html - convert mm/man/mandoc subset to html # it keeps going and going ... # # \h'0*\w"URL"'HOT-TEXT\h'0' link goto with alternate url # \h'0*1'HOT-TEXT\h'0' link goto # \h'0/\w"LABEL"'TEXT\h'0' local link label with alternate text # \h'0/1'LABEL\h'0' local link label # # .xx faq .VL is a FAQ list with all but current answer hidden # .xx meta.NAME="CONTENT" # .xx label="LABEL" local link label request # .xx link="URL\tHOT-TEXT" link goto with url request # .xx linkframe="URL\tHOT-TEXT" link goto with url request (no target=_top) # .xx link="HOT-TEXT" link goto request # .xx linkframe="HOT-TEXT" link goto request (no target=_top) # .xx ref="URL\tMIME-TYPE" head link hint # .xx begin=internal begin internal text # .xx end=internal end internal text # .xx index=0|1 stop|reset header index # .xx noFOO .xx FOO=0 # # .sn file like .so but text copied to output command=mm2html version='mm2html (AT&T Research) 2012-01-11' # NOTE: repeated in USAGE LC_NUMERIC=C case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in 0123) ARGV0="-a $command" USAGE=$' [-? @(#)$Id: mm2html (AT&T Research) 2012-02-29 $ ] '$USAGE_LICENSE$' [+NAME?mm2html - convert mm/man/mandoc subset to html] [+DESCRIPTION?\bmm2html\b is a \bsed\b(1)/\bksh\b(1) script (yes!) that converts input \bmm\b(1) or \bman\b(1) documents to an \bhtml\b document on the standard output. If \afile\a is omitted then the standard input is read. \btroff2html\b(1) is similar but does a full \btroff\b(1) parse. \adir\a operands and directory components of \afile\a operands are added to the included file search list.] [f:frame?Generate framed HTML files in:]:[name] { [+man documents] { [+\aname\a\b.html?The parent frame page.] [+\aname\a\b-toc.html?The table of contents (link) frame.] [+\aname\a\b-man.html?The (also standalone) man page frame.] } [+other documents] { [+\aname\a\b.html?The main body.] [+\aname\a\b-index.html?The frame index (if \b--index\b specified).] [+\aname\a\b-temp.html?Temporary frame goto labels.] } } [g:global-index?Generate a standalone \bindex.html\b for framed HTML.] [h:html?Read html options from \afile\a. Unknown options are silently ignored. See the \b.xx\b request below for a description of the options. The file pathname may be followed by URL style \aname=value\a pairs that are evaluated as if they came from \afile.\a]:[file[??name=value;...]]] [l:license?Read license identification options from \afile\a. Unknown options are silently ignored. See the \b.xx\b request below for a description of the options. The file pathname may be followed by URL style \aname=value\a pairs that are evaluated as if they came from \afile\a.]:[file[??name=value;...]]] [o:option?Sets a space or \b,\b separated list of \b--license\b options. Option values with embedded spaces must be quoted.]:[[no]]name=value] [t:top?Open non-local urls in the top frame.] [x:index?Generate a standalone \aname\a\b-index.html\b for framed HTML where \aname\a is specified by \b--frame\b.] [ [ dir | file ] ... ] [+EXTENSIONS?\b.xx\b \aname\a[=\avalue\a]] is a special \bmm2html\b request that handles program tracing, \bhtml\b extensions and \atroff\a macro package magic. Supported operations are:] { [+author=text?Specifies the contact information for the document HEAD section.] [+background=URL?Specifies the document background URL.] [+logo=URL?Specifies the logo/banner image URL that is centered at the top of the document.] [+mailto=address?Sets the email \aaddress\a to send comments and suggestions.] [+meta.name?Emits the \bhtml\b tag \b\b.] [+package=text?\atext\a is prepended to the \bhtml\b document title.] [+title=text?Sets the document title.] } [+?Local URL links are generated for all top level headings. These can be referenced by embedding the benign (albeit convoluted) \atroff\a construct \\h'\'$'0*\\w\"label\"'\'$'text\\h'\'$'0'\'$', where \alabel\a is the local link label and \atext\a is the hot link text. If \alabel\a and \atext\a are the same then use \\h'\'$'0*1'\'$'text\\h'\'$'0'\'$'.] [+?\bman\b(1) links are generated for bold or italic identifiers that are immediately followed by a parenthesized number.] [+FILES] { [+$HOME/.2html?Default rendering info.] } [+SEE ALSO?\btroff2html\b(1), \bhtml2rtf\b(1)] ' ;; *) ARGV0="" USAGE='f:gh:l:o:tx [ file ... ]' ;; esac set -o noglob integer count row n s ndirs=0 nfiles=0 last_level=0 IN=2 IS=2 man_SY=0 integer fd=0 head=2 line=0 lists=0 nest=0 peek=0 pp=0 so=0 soff=4 faq=0 integer labels=0 mark=4 reference=1 ident=0 ce=0 nf=0 augment=0 tbl_ns=0 tbl_no=1 tbl_fd=1 typeset -Z2 page=01 typeset -u upper typeset -l OP typeset -A ds map nr outline set tr typeset cond dirs files fg frame label level prev text trailer typeset license html meta nl mm index authors vg header references ss typeset mm_AF mm_AF_cur mm_AF_old mm_AU tr_chars typeset An_sep=-line Rs_sep='' Sh='' mm_H1='

' typeset -a list type nl=$'\n' license=( author= ) html=( BODY=( bgcolor=#ffffff ) TABLE=( bgcolor=#ffd0d0 border=0 bordercolor=#ffffff frame="void" rules="none" ) H1=( align=center ) FRAMESET=( rows=80,* border=0 frameborder=0 framespacing=0 ) home=( href= ) ident=1 index=( left= top= ) labels=0 logo=( src= ) magic=( plain='' frame='' ) width=96% ) code=0 figure=1 file= font= frame= framebody= framelink= framerefs= hung= ifs=${IFS-$'\n\t'} inch=" " macros= variant= pd= pm= primary=".BL|.IX" redirect_old= redirect_new= ss="verdana,arial,helvetica,geneva,sans-serif" top= vg_ps=20 function setmacros { case $1 in man) mark=6 [[ ${set[html.labels]} ]] || html.labels=0 ;; *) mark=4 ;; esac macros=$1 variant=$2 } function options { typeset i o q v IFS="${IFS}," set $OPTARG IFS=$ifs for i do case $q in '') o=${i%%=*} v=${i#*=} case $v in \'*) q=\'; v=${v#?}; continue ;; \"*) q=\"; v=${v#?}; continue ;; esac ;; *) v="$v $i" case $i in *$q) v=${v%?} ;; *) continue ;; esac ;; esac case $o in no*) o=${o#no} unset $o ;; *) case $v in "") v=1 ;; esac case $o in *.*|[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*) eval $o="'$v'" ;; *) eval license.$o="'$v'" ;; esac ;; esac set[$o]=1 done } if [[ -f $HOME/.2html ]] then . $HOME/.2html fi usage() { OPTIND=0 getopts $ARGV0 "$USAGE" OPT '-?' exit 2 } while getopts $ARGV0 "$USAGE" OPT do case $OPT in f) frame=$OPTARG ;; g) index=global ;; h) case $OPTARG in *\?*) . ${OPTARG%%\?*} || exit 1 eval "html+=( ${OPTARG#*\?} )" ;; *) . $OPTARG || exit 1 ;; esac ;; l) case $OPTARG in *\?*) . ${OPTARG%%\?*} || exit 1 eval "license+=( ${OPTARG#*\?} )" ;; *) path=$PATH [[ $OPTARG == */* ]] && PATH=${OPTARG%/*}:$PATH . $OPTARG || exit 1 PATH=$path ;; esac ;; o) options "$OPTARG" ;; t) top=1 ;; x) index=local ;; *) usage ;; esac done shift OPTIND-1 case $# in 1) file=$1 if [[ ! -f $file ]] then print -u2 $command: $file: cannot read exit 1 fi x="-m $file" ;; *) x= ;; esac HTMLPATH= for i in $HOME ${PATH//:/ } do d=${i%/bin}/lib/html if [[ -d $d ]] then if [[ -w $d || -x $i/$command ]] then HTMLPATH=$HTMLPATH:$d if [[ -x $i/$command ]] then break fi fi fi done HTMLPATH=${HTMLPATH#:} ds[Cr]='©' ds[Dt]=$(date -f "%B %d, %Y" $x) ds[Rf]="[$reference]" ds[Rg]='®' ds[CM]='©' ds[RM]='®' ds[SM]='SM' ds[TM]='TM' map[.Bd]=.EX map[.Bsx]=.Ix map[.Ce]=.EE map[.Cs]=.EX map[.Ed]=.EE map[.Sh]=.SH map[.Ss]=.SS map[.Tp]=.TP map[.TQ]=.TP H=H$(( head + 1 )) function warning { print -u2 "$command: warning: ${file:+"$file: "}line $line:" "$@" } function getfiles { sed \ -e 's%\\".*%%' \ -e 's%\\\.%.%g' \ -e 's%\\:%%g' \ -e 's%\\(>=%>=%g' \ -e 's%\\(<=%<=%g' \ -e 's%&%\&%g' \ -e $'s%\xA2%\\¢%g' \ -e $'s%\xA3%\\£%g' \ -e $'s%\xA7%\\§%g' \ -e $'s%\xA9%\\©%g' \ -e $'s%\xAE%\\®%g' \ -e $'s%\xB6%\\¶%g' \ -e 's%<%\<%g' \ -e 's%>%\>%g' \ -e 's%\[%\[%g' \ -e 's%\]%\]%g' \ -e 's%\\&%%g' \ -e 's%\\'\''%'\''%g' \ -e 's%\\`%`%g' \ -e 's%\\-%\-%g' \ -e 's%\\+%+%g' \ -e 's%\\0%\ %g' \ -e 's%\\|%\ %g' \ -e 's%\\\^%\ %g' \ -e 's%\\ %\ %g' \ -e 's%\\(+-%\±%g' \ -e 's%\\(-%=%g' \ -e 's%\\(ap%~%g' \ -e 's%\\(bu%\·%g' \ -e 's%\\(bv%|%g' \ -e 's%\\(co%\©%g' \ -e 's%\\(dg%\§%g' \ -e 's%\\(fm%'\''%g' \ -e 's%\\(rg%\®%g' \ -e 's%\\(sq%\¤%g' \ -e 's%\\(\*\([*`'\'']\)%\1%g' \ -e 's%\\\*\([*`'\'']\)%\1%g' \ -e 's%\\d\([^\\]*\)\\u%\1%g' \ -e 's%\\u\([^\\]*\)\\d%\1%g' \ -e 's%\\v\(.\)-\([^\\]*\)\1\(.*\)\\v\1+*\2\1%\3%g' \ -e 's%\\v\(.\)+*\([^\\]*\)\1\(.*\)\\v\1-\2\1%\3%g' \ -e 's%\\h'\''0\*\\w"\([abcdefghijklmnopqrstuvwxyz]*:[^"]*\)"'\''\([^'\'']*\)\\h'\''0'\''%\2%g' \ -e 's%\\h'\''0\*\\w"\(/[^"]*\)"'\''\([^'\'']*\)\\h'\''0'\''%\2%g' \ -e 's%\\h'\''0\*\\w"\([^"]*\)"'\''\([^'\'']*\)\\h'\''0'\''%\2%g' \ -e 's%\\h'\''0\*1'\''\([^:/'\'']*\)\\h'\''0'\''%\1%g' \ -e 's%\\h'\''0\*1'\''\([abcdefghijklmnopqrstuvwxyz]*:[^'\'']*\)\\h'\''0'\''%\1%g' \ -e 's%\\h'\''0\*1'\''\(/[^'\'']*\)\\h'\''0'\''%\1%g' \ -e 's%\\h'\''0\*1'\''\([^'\'']*\)\\h'\''0'\''%\1%g' \ -e 's%\\h'\''0/\\w"\([^"]*\)"'\''\([^'\'']*\)\\h'\''0'\''%\2%g' \ -e 's%\\h'\''0/1'\''\([^'\'']*\)\\h'\''0'\''%\1%g' \ -e 's%\\s+\(.\)\([^\\]*\)\\s-\1%\2%g' \ -e 's%\\s+\(.\)\([^\\]*\)\\s0%\2%g' \ -e 's%\\s-\(.\)\([^\\]*\)\\s+\1%\2%g' \ -e 's%\\s-\(.\)\([^\\]*\)\\s0%\2%g' \ -e 's%\\f(\(..\)\([^\\]*\)%<\1>\2%g' \ -e 's%\\f[PR]%\\fZ%g' \ -e 's%\\f\(.\)\([^\\]*\)%<\1>\2%g' \ -e 's%<\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789][-._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*@[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.]*\)>%\<\1\>%g' \ -e 's%\[[ABCDEFGHIJKLMNOPQRSTUVWXYZ][ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]*[0123456789][0123456789][abcdefghijklmnopqrstuvwxyz]*]%&%g' \ -e 's%%%g' \ -e 's%<[146789]>%%g' \ -e 's%%%g' \ -e 's%<2>%%g' \ -e 's%%%g' \ -e 's%<3>%%g' \ -e 's%%%g' \ -e 's%<5>%%g' \ -e 's%%%g' \ -e 's%%%g' \ -e 's%%%g' \ -e 's%%%g' \ -e 's%%%g' \ -e 's%%%g' \ -e 's%%%g' \ -e 's%%%g' \ -e 's%%%g' \ -e 's%%%g' \ -e 's%%%g' \ -e 's%\([^<]*\)(\([0123456789][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*\))%\1(\2)%g' \ -e 's%\([^<]*\)(\([0123456789][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*\))%\1(\2)%g' \ -e 's%\([^<]*\)(\([0123456789][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*\))%\1(\2)%g' \ -e 's%\\s+\(.\)\(.*\)\\s-\1%\2%g' \ -e 's%\\s-\(.\)\(.*\)\\s+\1%\2%g' \ -e 's%\\c%%g' \ -e 's%\\e%\\%g' \ -e 's,@MAN\([^@]\)EXT@,\1,g' \ -e '/^'\''[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]\>/s%.%.%' \ -e '/^\..*".*\\/s%\\[^\*][^(]%\\&%g' \ "$@" } function getline { integer i n typeset data a c d q v x y z if (( peek )) then (( peek = 0 )) trap 'set -- "${text[@]}"' 0 return fi while : do data= while : do IFS= read -r -u$fd a || { if (( so > 0 )) then eval exec "$fd>&-" if (( --so )) then (( fd = so + soff - 1 )) else (( fd = 0 )) fi file=${so_file[so]} line=${so_line[so]} continue fi return 1 } (( line++ )) case $a in *\\) x=${a%%+(\\)} a=${a#"$x"} if (( ! ( ${#a} & 1 ) )) then data=$data$x$a break fi data=$data$x${a%?} ;; *\\\}) data=$data${a%??} break ;; *) data=$data$a break ;; esac done case $data in *\\[n\*]*) a= i=0 while : do c=${data:i++:1} case $c in "") break ;; \\) x=${data:i:1} case $x in [n\*]) (( i++ )) c=${data:i++:1} case $c in \() c=${data:i:2} (( i += 2 )) ;; \[) c=${data:i} c=${c%%]*} (( i += ${#c} + 1 )) x='*' ;; esac case $x in n) a=$a${nr[$c]} ;; *) a=$a${ds[$c]} ;; esac continue ;; \\) a=$a$c while : do c=${data:i++:1} case $c in \\) ;; *) break ;; esac a=$a$c done ;; esac ;; esac a=$a$c done data=$a ;; esac case $data in .tr*) set -A text -- $data ;; .?*) case $data in *[\"]*) unset v a= i=0 n=0 q= while : do c=${data:i++:1} case $c in "") break ;; esac case $c in $q) q= case $c in \>) ;; *) continue ;; esac ;; [\"\<]) case $q in "") case $c in \<) q=\> ;; *) q=$c continue ;; esac ;; esac ;; \ |\ ) case $q in "") case $a in ?*) v[n++]=$a a= ;; esac continue ;; esac ;; esac a=$a$c done case $a in ?*) v[n++]=$a ;; esac set -A text -- "${v[@]}" ;; *) set -A text -- $data ;; esac case ${text[0]} in .el|.ie|.if) set -- "${text[@]}" shift x=$1 shift case ${text[0]} in .e*) if (( nest <= 0 )) then warning "unmatched ${text[0]}" n=0 else n=$(( ! ${cond[nest--]} )) fi ;; .i*) case $x in !*) x=${x#?} n=1 ;; *) n=0 ;; esac case $x in t|\'@(*)\'\1\'|+([\-+0123456789])=\1) (( n = ! n )) ;; +([\-+0123456789])=+([\-+0123456789])) ;; [0123456789]*[0123456789]) (( n = $x )) ;; esac case ${text[0]} in .ie) cond[++nest]=$n ;; esac ;; esac if (( ! n )) then case $@ in \\\{*|\{*) while read -r -u$fd data do (( line++ )) case $data in *\\\}|*\}) break ;; esac done ;; esac continue fi IFS=' ' set -A text -- $@ IFS=$ifs case ${text[0]} in \\\{*) text[0]=${text[0]#??} ;; \{*) text[0]=${text[0]#?} ;; esac ;; .so) x=${text[1]} for d in "${dirs[@]}" do if [[ -f "$d$x" ]] then (( fd = so + soff )) tmp=/tmp/m2h$$ getfiles "$d$x" > $tmp eval exec "$fd< $tmp" rm $tmp so_file[so]=$file file=$d$x so_line[so]=$line (( line = 0 )) (( so++ )) continue 2 fi done warning "$x: $op cannot read" continue ;; .xx) data= set -- "${text[@]}" shift while : do case $# in 0) break ;; esac nam=${1%%=*} case $nam in no?*) nam=${nam#no} val=0 ;; *) case $1 in *=*) val=${1#*=} [[ $val ]] || val=1 ;; *) val=1 ;; esac ;; esac shift case $nam in begin|end) set -- $val case $nam in begin) upper=$1 ;; end) upper=/$1 ;; esac shift case $# in 0) val="" ;; *) val="" ;; esac if (( ident )) then print -r -- "$val" else meta="$meta$nl$val" fi ;; faq) (( faq = val )) ;; index) case $val in 0) labels=-1 ;; *) labels=0 ;; esac ;; label|link*|ref) case $val in *' '*) url=${val%%' '*} txt=${val#*' '} ;; *'\\t'*) url=${val%%'\\t'*} txt=${val#*'\\t'} ;; *) url=$val txt=$val ;; esac case $url in *[:/.]*) pfx= ;; *) pfx='#' ;; esac case $url in *'${html.'*'}'*) eval url=\"$url\" ;; esac case $nam in label) if (( labels >= 0 )) then nam=name txt=${txt%%*([-.,])} level[label]=$last_level label[labels++]=$txt print -r -- "$txt" fi ;; link*) tar= case $nam in link) case $frame$top$vg in ?*) case $url in *([abcdefghijklmnopqrstuvwxyz]):*|/*) tar=" target=_top" ;; esac ;; esac ;; esac nam=href if [[ $frame != '' && $title == '' ]] then [[ -f $framebody ]] && rm $framebody framelink=$pfx$url else [[ $data ]] && data+=$'\t' data+="$txt" fi ;; ref) case $txt in $url) x="" ;; *) x="" ;; esac case $framelink in '') meta+="$nl$x" ;; *) framerefs+="$nl$x" ;; esac ;; esac ;; logo) eval html.$nam.src='$'val ;; meta.*) meta="$meta$nl" ;; ident|labels|logo*|title|[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*) eval html.$nam='$'val ;; text) [[ $data ]] && data+=$'\t' data+=$val ;; *) eval license.$nam='$'val ;; esac done case $data in '') continue ;; esac set -A text -- "$data" break ;; esac case ${text[0]} in @($primary)) : primary macros take precedence ;; .[BILMRUX]?([BILMRUX])|.CW|.F|.FR|.MW|.RF) case $macros:${text[0]} in mm:.LI)break ;; mm:.RF) break ;; man:.UR)break ;; esac typeset font1 font2 op set -- "${text[@]}" op=$1 shift case $op in .[BIL]R)case $#:$2 in 2':('[0123456789]*')'*([,.?!:;])) x=${2#'('*')'} y=${2%$x} z=${y#'('} z=${z%')'} case $op in .B*) font1=STRONG ;; .L*) font1=TT ;; *) font1=EM ;; esac case $macros in man) set -A text -- "<$font1>$1$y$x" ;; *) set -A text -- "<$font1>$1$y$x" ;; esac break ;; esac ;; .CW|.F) op=.L ;; .FR) op=.LR ;; .MW) op=.L ;; .RF) op=.RL ;; esac case $#:$macros:$op in 0:*) ;; *:man:.?) set -- "$*" ;; esac case $# in 0) getline set -- "$*" ;; esac case $font in "") data= ;; ?*) data="" font= ;; esac font1=${op#.} case $font1 in ?) font2=R ;; *) font2=${font1#?} font1=${font1%?} ;; esac case $font1 in B) font1=STRONG ;; I) font1=EM ;; [LMX]) font1=TT ;; R) font1= ;; esac case $font2 in B) font2=STRONG ;; I) font2=EM ;; [LMX]) font2=TT ;; R) font2= ;; esac font=$font2 while : do case $# in 0) break ;; esac case $font in $font2) font=$font1 ;; *) font=$font2 ;; esac case $1 in "") ;; *"""$@""" ;; .SG) continue ;; .SM) set -- "${text[@]}" shift case $# in 0) getline ;; esac set -A text -- """$@""" ;; *) x=${map[${text[0]}]} case $x in ?*) text[0]=$x ;; esac ;; esac ;; *) set -A text -- "$data" ;; esac break done if [[ $tr_chars && ${text[0]} != .tr && ${text[@]} == *[$tr_chars]* ]] then for a in ${!tr[@]} do z=${tr[$a]} for (( i = 0; i < ${#text[@]}; i++)) do if [[ $a == \\* ]] then text[i]=${text[i]//\\$a/$z} else text[i]=${text[i]//$a/$z} fi done done fi trap 'set -- "${text[@]}"' 0 } function ident { ident=1 case $frame in '') print -r -- "${html.magic.plain}" ;; *) print -r -- "${html.magic.frame}" ;; esac print -r -- "" print -r -- "" print -r -- "${meta}" } indexed= function index { if [[ ! $indexed ]] then indexed=1 if [[ ! $frame && ${html.labels} != 0 ]] then redirect_old=9 redirect_new=8 eval "exec $redirect_old>&1" t=/tmp/m2hl$$ eval "exec 1>$t" eval "exec $redirect_new<$t" rm -f $t else print -r -- "" fi fi } function title { ident case $header in ?*) print -r -- "$header" ;; esac print -r -- "" $* "" case ${license.author} in ?*) print -r -- "" ;; esac case $vg in ?*) print -r -- "" case $pages in ?*) print -r -- "" ;; esac print -r -- " " return ;; esac if (( faq )) then print -r -- '' fi print -r -- " " case ${html.heading} in ?*) case ${html.heading} in ?*) html.toolbar= hit= if [[ -f ${html.heading} ]] then hit=${html.heading} elif [[ -f $HOME/${html.heading} ]] then hit=$HOME/${html.heading} else IFS=: set "" $HOME $PATH IFS=$ifs for i do if [[ -f ${i%/bin}/lib/${html.heading} ]] then hit=${i%/bin}/lib/${html.heading} break fi done fi case $hit in "") print -u2 "$command: ${html.heading}: cannot read" code=1 ;; *) eval "cat <" case $macros:${html.width} in man:*|*:) ;; ?*) case ${html.width} in *%) x="align=center " ;; *) x="" ;; esac print -r -- "$nl
" trailer="$nl
$nl$trailer" ;; esac case $frame in '') logo=${html.logo/'('@(*)')'/\1} case ${html.ident}:${logo} in *:*"src=''"*|*:) ;; 1:?*) case ${html.home.href} in ?*) html.home.href=${html.home.href%/*.html}/ print -r -- "" ;; *) print -r -- "" ;; esac ;; esac ;; esac if [[ $macros != man ]] then index fi ;; esac case $pm in ?*) print -r "$pm" trailer="$pm$nl$trailer" ;; esac trailer="${trailer}${nl}" } function heading { typeset op=$1 i o options beg end txt lnlnk integer count shift case $op in .H) case $# in 0) count=1 ;; *) count=$1; shift ;; esac if (( $# == 2 )) && [[ $2 == link=* ]] then lnk=${2#link=} set -- "$1" fi options= ;; .H*|.AS)count=1 options=" align=center" ;; *) count=2 options=" align=center" ;; esac case "$op $count" in ".H"*" 1") print -n -r -- "$mm_H1" mm_H1="


" ;; esac case $* in "") print -r -- "

" ;; *) eval o='$'{html.H$count} for i in $o do case $i in align=center) beg="$beg

" end="
$end" ;; color=*|face=*) beg="$beg" end="$end" ;; esac done (( count += head )) print -nr -- "$beg" txt=$* txt=${txt%%*([-,.])} txt=${txt//' '/' '} txt=${txt//'&'/!!!AMP!!!} txt=${txt//\&+([^\;])\;/} txt=${txt//!!!AMP!!!/'&'} if [[ $lnk ]] then print -nr -- "$txt" else print -nr -- "$txt" fi if (( labels >= 0 && count < mark )) then last_level=$count level[labels]=$count label[labels++]=$txt fi print -r -- "$end" ;; esac } function tbl_attributes { typeset d f i u x typeset -F0 w case $1 in [aAcC]*)a="$a align=center" ;; [lL]*) a="$a align=left" ;; [nN]*) a="$a align=right char=." ;; [rR]*) a="$a align=right" ;; esac case $i in *[wW]\(+([0-9.])*\)*) x=${i##*[wW]\(} x=${x%%\)*} u=${x##+([0-9.])} x=${x%$u} case $u in c) (( w=x*75/2.54 )) ;; i) (( w=x*75 )) ;; m) (( w=x*75*12/72 )) ;; n) (( w=x*75*12/72/2 )) ;; p) (( w=x*75/72 )) ;; P) (( w=x*75/6 )) ;; *) (( w=x*75*12/72/2 )) ;; esac a="$a width=$w" ;; esac case $i in *[bB]*) b="$b" e="$e" ;; esac case X$i in *[!0-9.][iI]*) b="$b" e="$e" ;; esac } typeset Sm=" " function mandoc { typeset op sp=$Sm nsp t o a c p cmp msc ver op=$1 shift while (( $# )) do case $1 in Ns) sp="" shift continue ;; Po|Xo) c=.${1%o}c shift p=$* while getline do if [[ $p ]] then set -- $p "$@" p= fi if (( $# )) then o=$1 shift case $o in $c) break ;; .[[:upper:]][[:lower:]]) o=${o#.} mandoc _mandoc_ $o "$@" a=$_mandoc_ [[ $t && $a && $a != [[:punct:]] ]] && t+=$sp t+=$a ;; esac fi done case $c in .Po) t="($t)" ;; esac continue ;; esac o=$1 shift nsp=$Sm if (( ! $# )) || [[ $o == @([DFOPQ][co]|Ta) ]] then a="" nsp="" elif [[ $o != [[:upper:]][[:lower:]] ]] then a="" elif [[ $1 == [[:upper:]][[:lower:]] ]] then # NOTE: local 'a' should work here -- might not be possible with nameref # mandoc _mandoc_ "$@" a=$_mandoc_ shift $# else a=$1 shift while (( $# )) && [[ $1 != @([[:punct:]]|[[:upper:]][[:lower:]]) ]] do a+="$sp$1" shift done fi [[ $t && $a && $a != [[:punct:]] ]] && t+=$sp case $o in Ac) t+="$a>" ;; Ad) t+="$a" ;; Ao) t+="<$a" ;; Aq) t+="<$a>" ;; Ar) t+="$a" ;; At) t+="AT&T UNIX" ;; Bc) t+="$a]" ;; Bo) t+="[$a" ;; Bq) t+="[$a]" ;; Bx) t+="BSD" ;; Cd) t+="$a" ;; Cm) t+="$a" ;; Dc) t+="$a''" ;; Do) t+="\`\`$a" ;; Dq) t+="\`\`$a''" ;; Dv) t+="$a" ;; Dx) t+="DragonFly" ;; Em) t+="$a" ;; Er) t+="$a" ;; Ev) t+="$a" ;; Ex) t+="$a" ;; Fa) t+="$a" ;; Fc) t+="$a)" ;; Fd) t+="$a" ;; Fl) t+="-$a" ;; Fn) t+="$a" ;; Fo) t+="$a(" ;; Ft) t+="$a" ;; Fx) t+="FreeBSD" ;; Ic) t+="$a" ;; In) [[ $Sh == SYNOPSIS ]] && t+="#include "; t+="<$a>" ;; Ix) t+="BSDI BSD/OS" ;; Lb) t+="$a" ;; Li) t+="$a" ;; No) t+="$a" ;; Nx) t+="NetBSD" ;; Oc) t+="]$a" ;; Oo) t+="[$a" ;; Op) t+="$sp[$a]$sp" ;; Ox) t+="OpenBSD" ;; Pa) t+="$a" ;; Pc) t+="$a)" ;; Po) t+="($a" ;; Pq) t+="($a)" ;; Qc) t+="$a“" ;; Ql) t+="\`$a'" ;; Qo) t+="“$a" ;; Qq) t+="“$a“" ;; Rv) t+="$a" ;; Sq) t+="\`$a'" ;; St) t+="$a" ;; Sy) t+="$a" ;; Ta) t+=$'\t' ;; Tn) typeset -u A=$a; t+="$A" ;; Ux) t+="UNIX" ;; Va) t+="$a" ;; Vt) t+="$a" ;; [[:upper:]][[:lower:]]) t+="$a" ;; *) t+="$o" ;; esac sp=$nsp done case $op in -line) if [[ $sp ]] then sp="" t+="
" else sp="n" fi print -${sp}r "$t" ;; -space) print -nr "$t$Sm" ;; -*) print -nr "$t" ;; *) nameref ret=$op ret=$t ;; esac } function nohang { if (( ! faq )) then typeset a=${1//'<'*([^'>'])'>'/} a=${a//'&'*([^';'])';'/X} (( ${#a} >= 5 )) && print "
" fi } if [[ $frame != '' ]] then framebody=$frame.html exec > $framebody || exit fi dirs[++ndirs]="" for i do if [[ -d $i ]] then dirs[++ndirs]=$i/ else files[++nfiles]=$i if [[ $i == */* ]] then dirs[++ndirs]=${i%/*}/ fi fi done document="${files[@]}" getfiles "${files[@]}" | while : do getline || { [[ $title != '' ]] && break set -- .TL } case $1 in .) : comment ;; .*) op=$1 shift case $op in .AC) : ignore $op ;; .AE) : ignore $op ;; .AF) case $mm_AF_cur in "") mm_AF_cur="

$*" ;; *) mm_AF_cur="${mm_AF_cur}
$*" ;; esac ;; .AL|.VL)type[++lists]=.AL list[lists]=DIV print -r -- "

" case $op in .AL) case $1 in '') type[++lists]=.al list[lists]=OL print -r -- "
    " ;; [0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]) type[++lists]=.al list[lists]=OL print -r -- "
      " ;; esac ;; .VL) case $1 in ?*) type[++lists]=.al list[lists]=DL print -r -- "
      " ;; esac ;; esac ;; .AS|.H|.HU|.SH|.SS|.ce|.CE) if ((nf)) then nf=0 print -r -- "" fi if ((ce)) then ce=0 print -r -- "" fi if (( lists > pp )) then case ${type[@]:0:lists} in *.[Aa][Ll]*|*.[IiTt][Pp]*) while : do case ${type[lists]} in .[Aa][Ll]|.[IiTt][Pp]) print -rn -- "" case ${type[lists]} in .AL|.IP|.TP)break ;; esac ;; *) break ;; esac done ;; esac fi (( pp = lists )) print -r -- "

      " end= case ${mm.title} in ?*) mm_H1="


      " case ${mm_AU}${mm.author}${mm.keywords} in ?*) print -r -- "
      " ;; esac for i in ${html.H1} do case $i in align=center) beg="$beg
      " end="
      $end" ;; color=*|face=*) beg="$beg" end="$end" ;; esac done print -r -- "<$H>$beg${mm.title}$end" mm.title= case ${mm.author} in ?*) IFS=: set -- ${mm.author#:} : "$@" IFS=$ifs while : do case $# in 0) break ;; esac x=$1 shift case $x in :) break ;; esac print -r -- "$x
      " done ;; esac case $mm_AU in ?*) print -r -- "$mm_AU" case $mm_AF_cur in ?*) mm_AF="${mm_AF_cur}
      " ;; esac case $mm_AF in ?*) print -r -- "$mm_AF" ;; esac ;; esac case ${mm_AU}${mm.author}${mm.keywords} in ?*) print -r -- "
      " ;; esac ;; esac case $op in .AS) print -r -- "

      " heading $op Abstract ;; .ce) case $# in 0) count=1 ;; *) count=$1 ;; esac print -r -- "

      " while (( count-- > 0 )) && read -r data do print -r -- "$data
      " done print -r -- "
      " ;; .CE) if [[ $1 != 0 ]] then ce=1 print -r -- "
      " fi ;; .S[HS]) setmacros man while (( lists > 0 )) do [[ $op == .SS && ${type[lists]} == .[IRS][EH] ]] && break print -r -- "" [[ ${type[lists--]} == $op ]] && break done type[++lists]=$op list[lists]=DIV n=IN i=FI case $op in .SH) Sh=$* if [[ $macros == man && $* == DESCRIPTION && ${html.labels} != 0 ]] then index fi heading .H 2 "$@" if [[ $* == SYNOPSIS ]] then i=HI fi ;; *) heading .H 3 "$@" ;; esac print -r -- "
      " [[ $op == .SH && $* == NAME ]] && print -nr "" ;; *) heading $op "$@" ;; esac ;; .AT) : ignore $op ;; .AU) case $mm_AF_cur in ?*) case $mm_AF in ?*) case $mm_AU in ?*) mm_AU="${mm_AU}${mm_AF}" ;; esac ;; esac mm_AF="${mm_AF_cur}" mm_AF_cur="" ;; esac mm_AU="${mm_AU}
      $1" ;; .BL|.bL|.sL) i= for ((n = 1; n <= lists; n++)) do i=$i${list[n]} done case $i in *UL*UL*)i=disc ;; *UL*) i=circle ;; *) i=square ;; esac type[++lists]=.AL list[lists]=UL print -r -- "
        " ;; .BP) center=0 unset parm while [[ $1 == *=* ]] do if [[ $1 == align=center ]] then center=1 else eval parm+="( ${1%%=*}='${1#*=}' )" fi shift done unset oparm oparm=$parm i=$1 if [[ $i == *.@(gif|png) ]] then if (( center )) then print "
        " fi for i do f= for d in "${dirs[@]}" do if [[ -f "$d$i" ]] then f=$d$i break fi done if [[ ! $f ]] then print -u2 "$command: warning: $i: data file not found" fi if [[ ! ${oparm.alt} ]] then u=${i##*/} u=${i%.*} parm=( alt=$u ) fi if [[ ! ${oparm.title} ]] then u=${i##*/} u=${i%.*} if [[ ${parm.category} ]] then u="${parm.category} $u" elif [[ ${oparm.category} ]] then u="${oparm.category} $u" fi parm=( title=$u ) fi print -r -- "" done if (( center )) then print "
        " fi else i=${i%.*}.gif case $frame in ?*) [[ -f $frame-$i ]] && i=$frame-$i ;; esac f= for d in "${dirs[@]}" do if [[ -f "$d$1" ]] then f=$d$1 break fi done if [[ ! $f ]] then print -u2 "$command: $1: data file not found" elif [[ $f -nt $i ]] then ps2gif $f $i fi print -r -- "
        " fi ;; .CT) : ignore $op ;; .DE|.dE|.fi) if ((nf)) then nf=0 print -r -- "" fi ;; .DF|.DS|.dS|.nf) if ((!nf)) then nf=1 print -r -- "
        "
        			fi
        			;;
        		.DT)	case $macros in
        			man)	;;
        			*)	print -r -- "${ds[Dt]}" ;;
        			esac
        			;;
        		.EE|.eE)while	(( lists > 0 ))
        			do	print -r -- ""
        				case ${type[lists--]} in
        				.EX)	break ;;
        				esac
        			done
        			if	((nf))
        			then	nf=0
        				print -r -- "
        " fi if [[ $fg ]] then print -r -- "

        $fg

        " fi ;; .EQ|.EN): ignore $op : ;; .EX|.eX)type[++lists]=.EX list[lists]=DIV print -r -- "
        " if ((!nf)) then nf=1 print -r -- "
        "
        			else	print "
        " fi case $# in 2) fg="Figure $1: $2" ;; *) fg= ;; esac ;; .FE) print -r -- ' ] ' ;; .FG) print -r -- "

        Figure $figure: $*

        " (( figure++ )) ;; .FS) print -r -- ' [ ' ;; .FT) : ignore $op : ;; .H[01234]) if [[ $macros == man ]] then : optget --nroff : .Hlevel label : n=${op#.H} while [[ ${type[lists]} == .H[01234] ]] do m=${type[lists]#.H} (( m <= n )) && break print -r -- "" done if [[ ${type[lists]} != $op ]] then type[++lists]=$op list[lists]=DL print -r -- "
        " fi print -r -- "
        $*
        "$(nohang "$*") else warning "$op: unknown op" fi ;; .HP|.LP|.P|.PP) if (( lists > pp )) then case ${type[@]:0:lists} in *.[Aa][Ll]*|*.[IiTt][Pp]*) while : do case ${type[lists]} in .[Aa][Ll]|.[IiTt][Pp]) print -rn -- "" case ${type[lists]} in .AL|.IP|.TP)break ;; esac ;; *) break ;; esac done ;; esac fi (( pp = lists )) print -r -- "

        " ;; .HY) : ignore $op ;; .IP|.LI|.TF|.TP|.bI|.sI) case $macros:$op in mm:.TP) continue ;; esac case $op in .IP|.LP|.TF|.TP) if [[ ${type[lists]} != $op ]] then type[++lists]=$op list[lists]=DL print -r -- "

        " fi case $op in .IP|.LP|.TF) set -- "$*" ;; .TP) getline ;; esac ;; esac case ${list[lists]} in "") warning "$op: no current list" ;; DL) case $# in 0) getline ;; esac if [[ ${pd} && ! ${hung} ]] then print -rn -- "${pd}" fi hung=$(nohang "$*") print -r -- "
        $*
        $hung" ;; *) case $op in .bI|.sI)print -r -- "

        " ;; esac print -r -- "

      • $*" ;; esac ;; .[IR]S) case $macros:$op in mm:.RS) references="$references$nl
        [$reference]
        "$(nohang "[$reference]") while getline do case $1 in .RF) break ;; esac references="$references$nl$*" done (( reference++ )) ds[Rf]="[$reference]" continue ;; esac type[++lists]=${op%S}E list[lists]=DIV print -r -- "
        " ;; .[IR]E) while (( lists > 0 )) do print -r -- "" case ${type[lists--]} in $op) break ;; esac done print "
        " ;; .IX) : ignore $op ;; .LE|.bE|.sE|.El) case ${type[@]} in *.[Aa][Ll]*) while (( lists > 0 )) do print -r -- "" case ${type[lists--]} in .AL) break ;; esac done ;; *) warning "$op: no current list type" ;; esac ;; .LX) : ignore $op ;; .ME) if [[ $macros == man ]] then print -r -- "
        " fi ;; .MT) if [[ $macros == man ]] then x="$*" getline print -nr -- "$*" "$x" else setmacros mm fi ;; .ND|.Dd)ds[Dt]=$* ;; .NL) type[++lists]=.AL list[lists]=OL print -r -- "
          " ;; .OK) mm.keywords="$*" ;; .OP) case $macros in man) if (( man_SY )) then : .OP flag [value] : print -nr -- " [$1" if (( $# > 1 )) then shift print -nr -- " $*" fi print -nr -- "]" else : optget --nroff : .OP flag long types argument : while [[ ${type[lists]} == .H[01234] ]] do print -r -- "" done if [[ ${type[lists]} != $op ]] then type[++lists]=$op list[lists]=DL print -r -- "
          " fi x="" if [[ $1 != - ]] then x="$x-$1" fi if [[ $2 != - ]] then if [[ $1 != - ]] then x="$x, " fi x="$x--$2" if [[ $4 != - ]] then if [[ $3 == *optional* ]] then x="$x[=$4]" else x="$x=$4" fi fi elif [[ $4 != - ]] then if [[ $3 == *optional* ]] then x="$x [$4]" else x="$x $4" fi fi x="
          $x
          "$(nohang "$x") fi ;; *) : .OP opt arg arg-append arg-prepend x="$4-$1$2" case $3 in '[]') x="[ $x ]" ;; ?*) x="$x$3" ;; esac ;; esac print -r -- "$x" ;; .PM|.pM)case ${html.company} in '') pm= ;; *) pm="${html.company//\&/\&\;} " ;; esac case $1 in '') pm= ;; C|NDA) pm="${pm}CONFIDENTIAL" ;; RG) pm="${pm}PROPRIETARY (REGISTERED)" ;; RS) pm="${pm}PROPRIETARY (RESTRICTED)" ;; *) pm="${pm}PROPRIETARY" ;; esac case $pm in ?*) case $op in .pM) pm="
          ${pm}
          " ;; *) pm="
          <$H>${pm}
          " ;; esac ;; esac ;; .PU) : ignore $op ;; .SA) : ignore $op ;; .SU) : ignore $op ;; .SY) if [[ $macros == man ]] then man_SY=1 print -nr -- "$1 " fi ;; .TH|.TL|.Dt) : .TL junk junk : .TH item section foot_center foot_left head_center : .Dt item section volume case $macros:$op in :.TL) setmacros mm ;; :.TH) setmacros man ;; :.Dt) setmacros man mandoc ;; esac case ${html.title} in ?*) title=${html.title} ;; *) case $title in '') title="$document $macros document" ;; esac title="$package $title" ;; esac title $title case $op in .TH|.Dt)case $3 in ?*) dc[++dcs]=$3 ;; esac case $4 in ?*) dl[++dls]=$4 ;; esac case $5 in '') sec=$(set --'???'MAN=$2 2>&1) sec=$ver$msc$cmp$sec ;; *) sec=$5 ;; esac if [[ $frame ]] then TOP="target=_top " else TOP= fi MAN="$1($2)" print -r -- "" print -r -- "

          $MAN$sec$MAN

          " print -r -- "
          " ;; .TL) getline || break case ${html.title} in '') mm.title=$* ;; esac ;; esac ;; .TM) : ignore $op ;; .TS) # undent ... case $1 in H) tbl_tmp=/tmp/m2h$$tbl (( tbl_fd=3 )) trap "rm -f $tbl_tmp" 0 1 2 3 eval exec "$tbl_fd>$tbl_tmp" ;; esac unset opts eval "opts=${html.TABLE}" unset opts.width opts.align tbl_ns=3 tbl_sp='  ' tab=$'\t' (( augment=0 )) while : do (( row=0 )) while getline do set -- ${@//[-\|_=]/ } case $# in 0) continue ;; esac case $1 in '.T&'*) continue ;; .TE) if (( tbl_fd != 1 )) then warning ".TS H without .TH" eval "exec $tbl_fd>&-" (( tbl_fd=1 )) rm -f $tbl_tmp tbl_tmp= trap - 0 1 2 3 if (( augment )) then print -r -u$tbl_fd -- "" fi fi continue 3 ;; esac (( row++ )) tbl[row]=${@//..*/.} case $* in *";"*) (( row=0 )) for i in ${@//[,\;]/ } do case $i in center) opts.align=center ;; expand) opts.align=center opts.width="99%" ;; allbox) opts.border=1 opts.frame="box" opts.rules="all" ;; box) opts.border= opts.frame="void" opts.rules="none" ;; doublebox) opts.border=2 opts.frame="box" opts.rules="none" ;; linesize'('*')') opts.border=${i//*'('@(*)')'*/\1} ;; tab'('*')'*) tab=${i//*'('@(*)')'*/\1} ;; tab'(') case $* in *'tab(,'*) tab=',' ;; *'tab(;'*) tab=';' ;; *'tab( '*) tab=' ' ;; *) tab=$'\t' ;; esac ;; esac done ;; *".") break ;; esac done case ${opts.border} in 0) opts.cellpadding=0 opts.cellspacing=0 unset opts.bgcolor ;; *) case ${opts.cellpadding} in '') opts.cellpadding=2 ;; esac case ${opts.cellspacing} in '') opts.cellspacing=2 ;; esac ;; esac case ${opts.border} in '') opts.border=0 ;; esac if ((!augment)) then (( augment=1 )) print -r -- "

          " else print -r -u$tbl_fd -- "" fi fi for ((n = 1; n < row; n++)) do getline || break case $1 in [_=]*) ((n--)); continue ;; esac print -rn -u$tbl_fd -- "" IFS=$tab set -- $* IFS=$ifs set -A Q ${tbl[n]} (( q=0 )) (( s=1 )) while : do i=${Q[q++]} case $i in ''|.) break ;; *[0-9]*)x=${i//[pvw]*([()0-9.inm])/} x=${i//[[:alpha:]]/} case $x in +([0-9])) if (( $x > tbl_ns )) then tbl_ns=$x tbl_sp='' for ((m=(tbl_ns+1)/2; m>0; m--)) do tbl_sp=${tbl_sp}' ' done fi esac ;; esac a= case $q in 1) b='' ;; *) b=$tbl_sp ;; esac case ${Q[q]}:$# in :*|*:[01]) e='' ;; *) e=$tbl_sp ;; esac case $i in [sS]*) (( s++ )); continue ;; esac tbl_attributes "$i" while [[ ${Q[q]} == *s* ]] do (( s++ )) (( q++ )) done if (( s > 1 )) then a="$a colspan=$s" (( s=1 )) fi v=$1 case $i in *'*'*) case $v in *'=>'*) v="'}\">${v%'=>'}" ;; *) v="$v" ;; esac esac print -rn -u$tbl_fd -- "$b$v$e" case $# in 0|1) break ;; esac shift done print -r -u$tbl_fd -- "" done prev= set -A Q ${tbl[n]} while getline do case $1 in '.T&'*) (( augment=1 )) continue 2 ;; .TH*) if (( tbl_fd != 1 )) then print -r -u$tbl_fd -- "" if (( tbl_no == 1 || $# == 1 )) || [[ $2 != N ]] then cat $tbl_tmp fi eval "exec $tbl_fd>&-" (( tbl_fd=1 )) rm -f $tbl_tmp tbl_tmp= trap - 0 1 2 3 fi print -r -u$tbl_fd -- "" continue ;; .TE) (( tbl_no++ )) if (( tbl_fd != 1 )) then warning ".TS H without .TH" eval "exec $tbl_fd>&-" (( tbl_fd=1 )) rm -f $tbl_tmp tbl_tmp= trap - 0 1 2 3 print -r -u$tbl_fd -- "" fi break ;; esac IFS=$tab set -- $* IFS=$ifs case $* in *"\\") prev=$prev$'\n'${*/"\\"/} ;; *) print -rn -u$tbl_fd -- "" IFS=$'\t' set -- $prev$'\n'$* IFS=$ifs case $* in $'\n_') rule=1 set -- '_' ;; $'\n=') rule=1 set -- '=' ;; *) rule=0 ;; esac (( q=0 )) while : do i=${Q[q++]} case $i in ''|.) break ;; *[0-9]*)x=${i//[pvw]*([()0-9.inm])/} x=${i//[[:alpha:]]/} case $x in +([0-9])) if (( $x > tbl_ns )) then tbl_ns=$x tbl_sp='' for ((m=(tbl_ns+1)/2; m>0; m--)) do tbl_sp=${tbl_sp}' ' done fi esac ;; esac a= case $q in 1) b='' ;; *) b=$tbl_sp ;; esac case ${Q[q]}:$# in :*|*:[01]) e='' ;; *) e=$tbl_sp ;; esac case $1 in $'\n_'|'_') print -rn -u$tbl_fd -- "" ;; $'\n='|'=') print -rn -u$tbl_fd -- "" ;; *) tbl_attributes "$i" print -rn -u$tbl_fd -- "$b$1$e" ;; esac ((rule)) && continue case $# in 0|1) break ;; esac shift done print -r -u$tbl_fd -- "" prev= ;; esac done break done print -r -- "
          $nl" if (( tbl_fd == 3 )) then print -r -u$tbl_fd -- "


          " # ... indent ;; .TX) : ignore $op ;; .UC) : ignore $op ;; .UE) if [[ $1 ]] then getline fi print -r -- "$*" ;; .UR) x="$*" getline print -nr -- "$*" "$x" ;; .VE) : ignore $op ;; .VS) : ignore $op ;; .YS) if (( man_SY )) then man_SY=0 getline print -r -- "$*" fi ;; .ad) : ignore $op ;; .al) : ignore $op ;; .bd) : ignore $op ;; .br|.) if [[ $Sh == SYNOPSIS ]] then print "

          " else print "
          " fi ;; .cp) : ignore $op ;; .cs) : ignore $op ;; .da|.di)x=$1 t= while getline do case $1:$2 in $op:) break ;; esac t=$t$nl$* done if [[ $op == .di || ! ${ds[$x]} ]] then ds[$x]=${t#?} else ds[$x]=${ds[$x]}$t fi ;; .de|.am|.ig) end=.. case $#:$op in 0:*) ;; *:.ig) end=$1 ;; esac : ignore $op to $end while getline do case $1 in $end) break ;; esac done ;; .do) : ignore $op ;; .ds) op=$1 shift ds[$op]=$* ;; .ec) : ignore $op ;; .eo) : ignore $op ;; .f[tBILPR]) case $op in .f[BILPR]) set -- ${op#.f} ;; esac case $1 in 5|TT) font=TT print -n -r -- "<$font>" ;; [BI]) font=$1 print -n -r -- "<$font>" ;; *) case $font in ?*) print -n -r -- "" font= ;; esac ;; esac ;; .fc) : ignore $op ;; .fp) : ignore $op ;; .hc) : ignore $op ;; .hw) : ignore $op ;; .hy) : ignore $op ;; .in) case $1 in -*|"") while (( lists > 0 )) do print -r -- "" case ${type[lists--]} in .in) break ;; esac done ;; +*) type[++lists]=$op list[lists]=DIV print -r -- "

          " ;; esac print "
          " ;; .lf) : ignore $op ;; .ll) : ignore $op ;; .na) : ignore $op ;; .ne) : ignore $op ;; .nh) : ignore $op ;; .nr) op=$1 shift nr[$op]=$* ;; .ns) : ignore $op ;; .pl) : ignore $op ;; .ps|.pS)case $1 in [-+][0123456789]) print -r -- "" ;; esac ;; .rn) : ignore $op ;; .sh) case $HTMLPATH in '') ;; *) (( fd = so + soff )) file=/tmp/m2h$$ #( eval PATH=$HTMLPATH "$*" ) > $file $SHELL -c "PATH=$HTMLPATH $*" > $file eval exec "$fd< $file" rm $file so_file[so]=$file file=$1 so_line[so]=$line (( line = 0 )) (( so++ )) ;; esac ;; .sn) for d in "${dirs[@]}" do if [[ -f "$d$1" ]] then cat "$d$1" continue 2 fi done warning "$1: $op cannot read" ;; .sp|.SP|.Sp) while [[ ${type[lists]} == .H[01234] ]] do print -r -- "" done case $1 in [0123456789]*) count=$1 while (( count >= 0 )) do (( count-- )) print -r -- "
          " done ;; *) print -r -- "

          " ;; esac ;; .ta) : ignore $op ;; .ti) : ignore $op ;; .tr) x=$1 while [[ $x ]] do if [[ $x == '\('??* ]] then f=${x:0:4} x=${x#????} else f=${x:0:1} x=${x#?} fi i=${x#?} t=${x%$i} x=$i tr[$f]=${t:-' '} tr_chars+=\\$f done ;; .ul) : ignore $op ;; .vs) : ignore $op ;; .vG) vg=$1 inch=" " set +o noglob rm -f [0123456789][0123456789].html index.html outline.html set -o noglob exec > $page.html outline[$page]=$2 header='' title "${2//\<*([!>])\>/}" print "" print "${pm}

          " print "

          $2


          " case $# in 0|1|2) ;; *) shift 2 for name do [[ $name == "-" ]] && name="" print -- "
          $name" done ;; esac print "
          " print "

          " ;; .vH) print -r -- "


          $1


          " ;; .vP) while (( lists > 0 )) do print -r -- "" done print -r -- "${trailer} " ((page++)) exec > $page.html outline[$page]=$1 trailer= title "${1//\<*([!>])\>/}" print "" print "${pm}
          " print "

          $1

          " print "
          " print "

          " ;; .nS) print -r -- "

          " ;; .tS) print -r -- "
          " ;; .nE|.tE)print -r -- "
          " ;; .A[cdoqrt]|.B[coqx]|.C[dm]|.D[coqvx]|.E[mrvx]|.F[acdlnotx]|.I[cnx]|.L[bi]|.N[ox]|.Ox|.P[acfoq]|.Q[cloq]|.Rv|.S[coqty]|.T[an]|.Ux|.V[at]|.Xo) mandoc -space ${op#.} "$@" ;; .An) case $1 in -split) An_sep=-line ;; -nosplit) An_sep=-space ;; -*) ;; *) if (( $# >= 2 )) then print -nr -- "$1 $2 " shift 2 mandoc $An_sep "$@" else print -r -- "$1" fi ;; esac ;; .Bk) : mandoc : ;; .Bl) i= for o do case $o in -bullet) i="type=disc" ;; -dash|-hyphen) i="type=box" ;; -enum) i=OL ;; esac done case $i in OL) type[++lists]=.AL list[lists]=OL print -r -- "
            " ;; *=*) type[++lists]=.AL list[lists]=UL print -r -- "
              " ;; *) type[++lists]=.AL list[lists]=DIV print -r -- "
              " type[++lists]=.al list[lists]=DL print -r -- "
              " ;; esac ;; .D1) (( $# )) || getline print -r -- "
              $*
              " ;; .Dl) (( $# )) || getline print -r -- "
              $*
              " ;; .Ek) : mandoc : ;; .Id) meta="$meta$nl" ;; .It) if (( $# )) then mandoc label "$@" set -A text -- .LI "$label" elif [[ ${list[lists]} == DL ]] then getline if [[ $1 == .[[:upper:]][[:lower:]] ]] then x=$1 shift set -- "${x#.}" "$@" fi mandoc label "$@" set -A text -- .LI "$label" else set -A text -- .LI fi peek=1 ;; .Nd) print -nr -- "-" "$@" "" ;; .Nm) [[ $1 ]] && ds[Nm]=$1 [[ $Sh == SYNOPSIS ]] && print "
              " print -nr -- "${ds[Nm]} " ;; .Oo) mandoc -space ${op#.} "$@" ;; .O[cp]) mandoc - ${op#.} "$@" ;; .Os) : mandoc : ;; .Pp) print -r -- "

              " ;; .Re) print -r -- ".

              " ;; .Rs) print -r -- "

              " Rs_sep='' ;; .Sm) case $1 in on) Sm=" " ;; off) Sm="" ;; *) case $Sm in " ") Sm="" ;; "") Sm=" " ;; esac ;; esac ;; .Sx) print -r -- "$1$2" ;; .Xr) print -r -- "$1($2)$3" ;; .%A) print -nr -- "$Rs_sep$*" Rs_sep=", " ;; .%D) print -nr -- "$Rs_sep$*" Rs_sep=", " ;; .%N) print -nr -- "$Rs_sep$*" Rs_sep=", " ;; .%O) print -nr -- "$Rs_sep$*" Rs_sep=", " ;; .%T) print -nr -- "$Rs_sep$*" Rs_sep=", " ;; *) warning "$op: unknown op" ;; esac ;; [\ \ ]*) case $macros in man) leading=1 prefix="

              "
              			blank=
              			while	:
              			do	case $1 in
              				*([\ \	]))
              					case $leading in
              					1)	leading= ;;
              					*)	blank=$'\n' ;;
              					esac
              					;;
              				[\ \	]*)
              					print -r -- "$prefix$blank$inch$*"
              					blank=
              					leading=
              					prefix=
              					;;
              				*)	(( peek = 1 ))
              					break
              					;;
              				esac
              				getline || break
              			done
              			case $prefix in
              			"")	print -r -- "
              " ;; esac ;; *) print -r -- "$*" ;; esac ;; "") case $macros in man) print -r -- "

              " ;; *) print -r -- "$*" ;; esac ;; *) print -r -- "$*" ;; esac done while (( lists > 0 )) do print -r -- "" done case $references in ?*) heading .H 1 References print "

              " print "

              " print -r -- "$references" print "
              " ;; esac if (( faq )) then print -r "
              show all answers hide all answers
              " fi print -r -- "

              " print -r -- "


              " print -r -- "" integer dls=0 dcs=0 drs=0 typeset d dl dc dr case ${html.ident} in 1) case ${license.author} in ?*) IFS=',+' set -- ${license.author} IFS=$ifs d="" sp="" for a do v=${contributor[$a]} case $v in ?*) a=$v ;; esac IFS='<>' set -- $a IFS=$ifs case $2 in ?*) d="$d$sp" sp=", " set -- $1 d="$d$*" ;; esac done [[ $d ]] && dr[++drs]=$d ;; *) case ${html.MAILTO} in ?*) dr[++drs]="${html.MAILTO}" ;; esac ;; esac for i in "${license.organization}" "${license.corporation} ${license.company}" "${license.address}" "${license.location}" "${license.phone}" do case $i in ''|' ') ;; *) dr[++drs]="${i//\&/\&\;}" ;; esac done ;; esac dr[++drs]="${ds[Dt]}" (( drs < dls )) && (( drs = dls )) for (( dls = 1; dls <= drs; dls++ )) do print -r -- "$nl$nl$nl$nl" done print -r -- "
              ${dl[dls]}${dc[dls]}${dr[dls]}
              " print -r -- "

              " case ${html.footing} in ?*) html.toolbar= hit= if [[ -f ${html.footing} ]] then hit=${html.footing} elif [[ -f $HOME/${html.footing} ]] then hit=$HOME/${html.footing} else IFS=: set "" $HOME $PATH IFS=$ifs for i do if [[ -f ${i%/bin}/lib/${html.footing} ]] then hit=${i%/bin}/lib/${html.footing} break fi done fi case $hit in "") print -u2 "$command: ${html.footing}: cannot read" code=1 ;; *) eval "cat <" print -r -- "$trailer" case $frame in ?*) if [[ ! $framelink && ${html.labels} != 0 ]] && (( labels > 1 )) then if [[ $macros == man ]] then mv $framebody $frame-man.html frameref=${frame##*/} { ident print -r -- "$file table of contents" [[ ${html.menu.style} ]] && print -r -- "${html.menu.style}" [[ ${html.menu.script} ]] && print -r -- "${html.menu.script}" print -r -- "" print -r -- "" [[ ${html.menu.id} ]] && print -r -- "

              " print -r -- "
                " (( lev = level[0] )) for ((n = 0; n < labels; n++)) do while (( lev < level[n] )) do (( lev++ )) print -r -- "
                  " done while (( lev > level[n] )) do (( lev-- )) print -r -- "
                " done print -r -- "
              • ${label[n]}" done while (( lev > level[0] )) do (( lev-- )) print -r -- "
              " done print -r -- "
            " [[ ${html.menu.id} ]] && print -r -- "
          " print -r -- "" print -r -- "" } > $frame-toc.html { ident print -r -- "$file frame sets$nl" print -r -- "" print -r -- "" print -r -- "" print -r -- "" print -r -- "" print -r -- "" print -r -- "" } > $framebody else exec > $frame-temp.html || exit print -r -- "" print -r -- "" for ((n = 0; n < labels; n++)) do print -r -- "" done print -r -- "
          ${label[n]}
          " print -r -- "
          " exec > /dev/null || exit ed $framebody </r $frame-temp.html w q ! rm $frame-temp.html fi fi case $index in ?*) case $index in local) exec > $frame-index.html || exit ;; global) exec > index.html || exit ;; esac unset html.FRAMESET.rows html.FRAMESET.cols ident case $framelink in '') framelink=$frame.html ;; esac print -r -- "$title$framerefs " if [[ ${html.frameindex} && -f ${html.frameindex} ]] then sed "s,\${INDEX},${framelink}," ${html.frameindex} else print -r -- " " fi print -r -- "" ;; esac ;; *) if [[ $redirect_old ]] then eval "exec 1>&$redirect_old $redirect_old>&-" fi if [[ ${html.labels} != 0 ]] && (( labels > 1 )) then if [[ ${html.labels} != +([0-9]) || ${html.labels} == 1 ]] then html.labels=7 fi print -r -- "" print -r -- "" print -r -- "" for ((n = 0; n < labels; n++)) do print -r -- "" if (( (n + 1) < labels && !( (n + 1) % ${html.labels} ) )) then print -r -- "" fi done print -r -- "
          ${label[n]}
          " print -r -- "
          " print -r -- "" fi if [[ $redirect_new ]] then eval "cat <&$redirect_new" fi ;; esac case $vg in ?*) frame=$vg trailer= pages=${page#0} exec > index.html title "${outline[01]//\<*([!>])\>/}" print -r -- " " exec > outline.html title "${title} outline" print -r -- " ${pm}

          outline

          " for ((page=1; page <= pages; page++)) do print "" done print "
          ${outline[$page]}

          " ;; esac exit $code