3 package IkiWiki::Plugin::otl;
10 hook(type => "filter", id => "otl", call => \&filter);
11 hook(type => "htmlize", id => "otl", call => \&htmlize);
18 # Munge up check boxes to look a little bit better. This is a hack.
19 my $checked=htmllink($params{page}, $params{page},
20 "smileys/star_on.png", 0, 0, "[X]");
21 my $unchecked=htmllink($params{page}, $params{page},
22 "smileys/star_off.png", 0, 0, "[_]");
23 $params{content}=~s/^(\s*)\[X\]\s/${1}$checked /mg;
24 $params{content}=~s/^(\s*)\[_\]\s/${1}$unchecked /mg;
26 return $params{content};
29 sub htmlize (@) { #{{{
32 # Can't use open2 since otl2html doesn't play nice with buffering.
33 # Instead, fork off a child process that will run otl2html and feed
34 # it the content. Then read otl2html's response.
39 $pid = open(KID_TO_READ, "-|");
40 unless (defined $pid) {
43 debug("failed to fork: $@");
44 return $params{content};
54 $pid = open(KID_TO_WRITE, "|-");
55 unless (defined $pid) {
58 debug("failed to fork: $@");
59 print $params{content};
66 if (! exec 'otl2html', '-S', '/dev/null', '-T', '/dev/stdin') {
67 debug("failed to run otl2html: $@");
68 print $params{content};
73 print KID_TO_WRITE $params{content};
80 my $ret=<KID_TO_READ>;
86 $ret=~s/<div class="Footer">.*//s;