git-annex/Build/mdwn2man

59 lines
853 B
Text
Raw Normal View History

#!/usr/bin/env perl
# Warning: hack
my $prog=shift;
2015-03-23 16:24:20 +00:00
$prog=~s/\.\d+$//;
$prog=~s/man\///;
my $section=shift;
print ".TH $prog $section\n";
while (<>) {
s{(\\?)\[\[([^\s\|\]]+)(\|[^\s\]]+)?\]\]}{$1 ? "[[$2]]" : $2}eg;
2013-09-12 16:59:53 +00:00
s/\`([^\`]*)\`/\\fB$1\\fP/g;
s/\`//g;
s/^\s*\./\\&./g;
if (/^#\s/) {
s/^#\s/.SH /;
<>; # blank;
}
s/^[ \n]+//;
s/^\t/ /;
s/-/\\-/g;
2015-04-20 20:04:09 +00:00
s/git\\-annex/git-annex/g;
s/^Warning:.*//g;
s/^$/.PP\n/;
s/^\*\s+(.*)/.IP "$1"/;
next if $_ eq ".PP\n" && $skippara;
if (/^.IP /) {
$inlist=1;
$spippara=0;
}
2013-09-12 17:17:25 +00:00
elsif (/^.SH/) {
$skippara=0;
$inlist=0;
}
elsif (/^\./) {
$skippara=1;
}
else {
$skippara=0;
}
if ($inlist && $_ eq ".PP\n") {
$_=".IP\n";
}
if ($inNAME) {
# make lexgrog happy
s/^git-annex (\w)/git-annex-$1/;
}
if ($_ eq ".SH NAME\n") {
$inNAME=1;
}
else {
$inNAME=0;
}
print $_;
}