]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - mdwn2man
Merge branch 'master' of ssh://git.ikiwiki.info
[git.ikiwiki.info.git] / mdwn2man
index 57c41c86590042f9f6a8a89a64ec569fd07348ba..ad6d3c6026400660e87b67367133ce2e4a78fb81 100755 (executable)
--- a/mdwn2man
+++ b/mdwn2man
@@ -1,15 +1,24 @@
 #!/usr/bin/perl
 # Warning: hack
 
-print ".TH ikiwiki 1\n";
+my $prog=shift;
+my $section=shift;
+
+print ".TH $prog $section\n";
 
 while (<>) {
-       s{(\\?)\[\[([^\s\]]+)\]\]}{$1 ? "[[$2]]" : $2}eg;
-       s/^#\s/.SH /;
-       s/^\s+//;
+       s{(\\?)\[\[([^\s\|\]]+)(\|[^\s\]]+)?\]\]}{$1 ? "[[$2]]" : $2}eg;
+       s/\`//g;
+       s/^\s*\./\\&./g;
+       if (/^#\s/) {
+               s/^#\s/.SH /;
+               <>; # blank;
+       }
+       s/^[ \n]+//;
+       s/^\t/ /;
+       s/-/\\-/g;
        s/^Warning:.*//g;
        s/^$/.PP\n/;
-       s/\`//g;
        s/^\*\s+(.*)/.IP "$1"/;
        next if $_ eq ".PP\n" && $skippara;
        if (/^.IP /) {