3 package IkiWiki::Plugin::hnb;
5 # Copyright (C) 2008 by Axel Beckert <abe@deuxchevaux.org>
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 # You can reach the author by snail-mail at the following address:
25 # 8049 Zurich, Switzerland
29 # 2008-03-10 / 0.01: Initial release
30 # 2008-05-08 / 0.01.1: License, version and version history added
31 # 2008-05-26 / 0.02: Using content instead of page, s/mktemp/File::Temp/
38 use File::Temp qw(:mktemp);
41 hook(type => "htmlize", id => "hnb", call => \&htmlize);
47 # hnb does output version number etc. every time to STDOUT, so
48 # using files makes it easier to seprarate.
50 my ($fhi, $tmpin) = mkstemp( "/tmp/ikiwiki-hnbin.XXXXXXXXXX" );
51 my ($fho, $tmpout) = mkstemp( "/tmp/ikiwiki-hnbout.XXXXXXXXXX" );
53 open(TMP, '>', $tmpin) or die "Can't write to $tmpin: $!";
54 print TMP $params{content};
57 system("hnb '$tmpin' 'go root' 'export_html $tmpout' > /dev/null");
58 # Nicer, but too much output
59 #system('hnb', $tmpin, 'go root', "export_html $tmpout");
62 open(TMP, '<', $tmpout) or die "Can't read from $tmpout: $!";
68 $ret =~ s/.*<body>//si;
69 $ret =~ s/<body>.*//si;