diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-19 15:17:26 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-19 15:17:26 -0400 |
commit | 6ef1c2d2daf37dc92b4c364ea34802b62688018b (patch) | |
tree | 3373a8c4b5cef35dac4efddbf7af7a0218b9d325 /mdwn2man | |
parent | 21128c88e71cb2050b78f996888d9e251a448807 (diff) |
allow lines with leading tab, to be preformatted text
Diffstat (limited to 'mdwn2man')
-rwxr-xr-x | mdwn2man | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/mdwn2man b/mdwn2man new file mode 100755 index 000000000..c21253945 --- /dev/null +++ b/mdwn2man @@ -0,0 +1,43 @@ +#!/usr/bin/perl +# Warning: hack + +my $prog=shift; +my $section=shift; + +print ".TH $prog $section\n"; + +while (<>) { + s{(\\?)\[\[([^\s\|\]]+)(\|[^\s\]]+)?\]\]}{$1 ? "[[$2]]" : $2}eg; + s/\`//g; + s/^\s*\./\\&./g; + if (/^#\s/) { + s/^#\s/.SH /; + <>; # blank; + } + s/^ +//; + 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 $_; +} |