#!/usr/bin/sed -f # # Somehow convert -mandoc to -man format; # useful for reading OpenSSH and BIND docs on non-groff environments # # $Id: mandoc2man,v 1.13 2014-12-25 15:38:31+09 kabe Exp $ s/^\.Dd \(.*\)/.ds %D \1/ s/^\.Dt \("[^"]*"\) \(.*\)/.TH \1 \2 "\\*(%D"/ s/^\.Dt \([^ ]*\) \([^ ]*\) \(.*\)/.TH \1 "\2" "\\*(%D"/ s/^\.Dt \([^ ]*\) \(.*\)/.TH \1 \2 "\\*(%D"/ s/^\.Sh \("[^"]*"\)/.SH \1/ s/^\.Sh \(.*\)/.SH "\1"/ s/^\.Cd \("[^"]*"\)/.B \1\ .br/ s/^\.Cd \(.*\)/.B \1\ .br/ # using macro for .SH NAME entry screws up mkwhatis # .br for ssh-keygen uses .Nm multiple times without .Pp (uncommon?) s/^\.Nm \.$/.B \\*(%R\\|./ s/^\.Nm \([^ ]*\) *\(.*\)/.ds %R \1\ .br\ .B \1\ \\\&\2/ s/^\.Nm$/.B \\*(%R/ s/^\.Nd /\\- / /^\... /{ s/ Xo / / s/ Xc / / s/ Ta / /g s/ Ar \([^ ]*\)/ \\fI\\\&\1\\fP/g s/ Fl \([^ ]*\)/ \\fB\\-\1\\fP/g s/ Cm \([^ ]*\)/ \\fB\\\&\1\\fP/g s/ Dv \([^ ]*\)/ \\fB\\\&\1\\fP/g s/ Ic "\([^"]*\)"/ \\fB\\\&\1\\fP\\|/g #s/ Ic \([^ ,]*\) *\(,\{0,1\}\)/ \\fB\\\&\1\\fP\\|\2/g s/ Ic \([^ ,]*\)/ \\fB\\\&\1\\fP/g s/ Op *\([^ ]*\)/ [\1]/ s/ Li "\([^"]*\)"/ \\fB\\\&\1\\fP/g s/ Li \([^ ]*\)/ \\fB\\\&\1\\fP/g s/ Pa \([^ ]*\)/ \\fB\1\\fP/g s/ Ev \([^ ]*\)/ \\fB\1\\fP/g s/ Tn \([^ ]*\)/ \\s-2\1\\s+2/g s/ Ql \([^ ]*\) */ `\\fB\1\\fP'/ s/ Ns / /g ;#incorrect s/ Oo /[/g s/ Oo$/[/ s/ Oc /]/g s/ Oc$/]/ s/ Xo$// ;#cannot preserve these s/ Xc$// ;#cannot preserve these } s/^\.Op \(.*\)/[\1]/ s/^\.Ss /.PP\ .I / s/^\.Pp/.PP/ s/^\.Xr \([^ ]*\) \([^ ]*\)/\\fB\\\&\1\\fP(\2)/ s/^\.Bl.*/.RS/ s/^\.El.*/.RE/ s/^\.Bd.*/\ .RS\ .nf/ s/^\.Ed.*/.fi\ .RE/ s/^\.It /.TP\ / s/^\.It$/.TP/ ;# generated by stray "\.It Xo" # ssh.1: .Ar hostname . -> _hostname_. s/^\.Ar \([^ ]*\) *\(.*\)/\\fI\1\\fP\2/ s/^\.Fl \(.*\)/\\fB\\-\1\\fP/ s/^\.Cm /.B / #s/^\.Ic \(.*\)/\\fB\\\&\1\\fP/ s/^\.Ic \([^ ]*\) *\(.*\)/\\fB\\\&\1\\fP\2/ #s/^\.Tn \(.*\)/\\s-2\1\\s+2/ s/^\.Tn /.SM / s/^\.Ql \([^ ]*\) *\(.*\)$/`\\fB\1\\fP'\2/ s/^\.Pq \([^ ]*\) *\(.*\)$/\\|(\\|\1\\|)\\|\2/ s/^\.Dq \([^ ]*\) *\(.*\)$/``\1''\2/ s/^\.Li /.B / s/^\.Pa /.B / /^\.Ev [^ ]*$/s/^.Ev/.B/ s/^\.Ev \([^ ]*\) \([^ ]*\)$/.BR \1 \2/ s/^\.Ev \([^ ]*\) \(.*\)/\\fB\1\\fP\2/ # .Ss Section reference s/^\.Sx /.B / s/^\.Oo */[/ s/^\.Oc */]/ /^\.Xo$/d /^\.Xc$/d