3 # Include polygen output in a page
6 package IkiWiki::Plugin::polygen;
14 IkiWiki::hook(type => "preprocess", id => "polygen",
15 call => \&preprocess);
18 sub preprocess (@) { #{{{
20 my $grammar = ($params{grammar} or 'polygen');
21 my $symbol = ($params{symbol} or undef);
24 $grammar =~ IkiWiki::basename($grammar);
25 $grammar =~ s/\.grm$//;
27 $symbol =~ s/[^A-Za-z0-9]//g if defined $symbol;
29 my $grmfile = '/usr/share/polygen/ita/polygen.grm';
31 if (substr($File::Find::name, -length($grammar)) eq $grammar) {
32 $grmfile = IkiWiki::possibly_foolish_untaint($File::Find::name);
36 }, '/usr/share/polygen');
39 if (defined $symbol) {
40 $res = `polygen -S $symbol $grmfile 2>/dev/null`;
43 $res = `polygen $grmfile 2>/dev/null`;
47 $res="[[polygen failed]]";
50 # Strip trainling spaces and newlines so that we flow well with the