X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/f2dca770da6b7d7e56195e84ae804f1cb5c466b3..47b12458ae0dad36b1fd5502bd2970cd4e5ca809:/doc/plugins/contrib/mandoc.mdwn diff --git a/doc/plugins/contrib/mandoc.mdwn b/doc/plugins/contrib/mandoc.mdwn index e4ff96d08..672a268cc 100644 --- a/doc/plugins/contrib/mandoc.mdwn +++ b/doc/plugins/contrib/mandoc.mdwn @@ -1,60 +1,12 @@ [[!template id=plugin name=mandoc author="[[schmonz]]"]] +[[!template id=gitbranch branch=schmonz/mandoc author="[[schmonz]]"]] [[!tag type/format]] This plugin lets ikiwiki convert Unix man pages to HTML. It uses [mdocml](http://mdocml.bsd.lv/) for the conversion, and postprocesses xrefs into hyperlinks. -Sample output: +Possible enhancements: ------ - - - #!/usr/bin/perl - package IkiWiki::Plugin::mandoc; - - use warnings; - use strict; - use IkiWiki 3.00; - use Encode; - use IPC::Open2; - - sub import { - hook(type => "getsetup", id => "mandoc", call => \&getsetup); - hook(type => "htmlize", id => $_, call => \&htmlize, keepextension => 1) - foreach ('man', 1..9); - } - - sub getsetup () { - return - plugin => { - safe => 1, - rebuild => 1, # format plugin - section => "format", - }, - } - - sub htmlize (@) { - my %params=@_; - my $content = decode_utf8(encode_utf8($params{content})); - - return $content if $@; - - my $pid = open2(*MANDOCOUT, *MANDOCIN, 'mandoc', '-Thtml'); - binmode($_, ':utf8') foreach (*MANDOCOUT, *MANDOCIN); - - print MANDOCIN $content; - close MANDOCIN; - my @html_output = ; - close MANDOCOUT; - waitpid $pid, 0; - - my $html = join('', @html_output); - my $link_prefix = $config{usedirs} ? '../' : ''; - my $link_suffix = $config{usedirs} ? '/' : ''; - $html =~ s|(.+?)\((.)\)|$1($2)|g; - - return $html; - } - - 1 +* configurable path and args to `mandoc` (and it could be `groff`) +* configurable location for rendered manpages (such as subdirs per section)