3 # Include polygen output in a page
6 package IkiWiki::Plugin::polygen;
14 hook(type => "getsetup", id => "polygen", call => \&getsetup);
15 hook(type => "preprocess", id => "polygen", call => \&preprocess);
29 my $grammar = ($params{grammar} or 'polygen');
30 my $symbol = ($params{symbol} or undef);
33 $grammar =~ IkiWiki::basename($grammar);
34 $grammar =~ s/[^A-Za-z0-9]//g;
35 $grammar =~ s/\.grm$//;
37 $symbol =~ s/[^A-Za-z0-9]//g if defined $symbol;
38 $symbol = IkiWiki::possibly_foolish_untaint($symbol) if defined $symbol;
40 my $grmfile = '/usr/share/polygen/ita/polygen.grm';
41 if (! -d '/usr/share/polygen') {
42 error gettext("polygen not installed");
45 if (substr($File::Find::name, -length($grammar)) eq $grammar) {
46 $grmfile = IkiWiki::possibly_foolish_untaint($File::Find::name);
50 }, '/usr/share/polygen');
53 if (defined $symbol) {
54 $res = `polygen -S $symbol $grmfile 2>/dev/null`;
57 $res = `polygen $grmfile 2>/dev/null`;
61 error gettext("command failed");
64 # Strip trailing spaces and newlines so that we flow well with the