summaryrefslogtreecommitdiff
path: root/doc/mdwn2man
diff options
context:
space:
mode:
authorJoey Hess2014-11-22 12:09:53 -0400
committerJoey Hess2014-11-22 12:13:38 -0400
commit57ec60d6f307dbf3e237b924e635b90ba889af18 (patch)
tree3655b8befb6e905f903903887974a1a976cfd0bf /doc/mdwn2man
parente0c2d6a73af01f138a50b80a6885718ed0b9dad1 (diff)
mdwn man page and more complete docs
Diffstat (limited to 'doc/mdwn2man')
-rwxr-xr-xdoc/mdwn2man44
1 files changed, 44 insertions, 0 deletions
diff --git a/doc/mdwn2man b/doc/mdwn2man
new file mode 100755
index 00000000..aadb13cd
--- /dev/null
+++ b/doc/mdwn2man
@@ -0,0 +1,44 @@
+#!/usr/bin/env perl
+# Warning: hack
+
+my $prog=shift;
+my $section=shift;
+
+print ".TH $prog $section\n";
+
+while (<>) {
+ s{(\\?)\[\[([^\s\|\]]+)(\|[^\s\]]+)?\]\]}{$1 ? "[[$2]]" : $2}eg;
+ s/\`([^\`]*)\`/\\fB$1\\fP/g;
+ s/\`//g;
+ s/^\s*\./\\&./g;
+ if (/^#\s/) {
+ s/^#\s/.SH /;
+ <>; # blank;
+ }
+ s/^[ \n]+//;
+ s/^\t/ /;
+ s/-/\\-/g;
+ s/^Warning:.*//g;
+ s/^$/.PP\n/;
+ s/^\*\s+(.*)/.IP "$1"/;
+ next if $_ eq ".PP\n" && $skippara;
+ if (/^.IP /) {
+ $inlist=1;
+ $spippara=0;
+ }
+ elsif (/^.SH/) {
+ $skippara=0;
+ $inlist=0;
+ }
+ elsif (/^\./) {
+ $skippara=1;
+ }
+ else {
+ $skippara=0;
+ }
+ if ($inlist && $_ eq ".PP\n") {
+ $_=".IP\n";
+ }
+
+ print $_;
+}