2 package IkiWiki::Plugin::smiley;
12 IkiWiki::hook(type => "checkconfig", id => "smiley", call => \&setup);
16 my $list=IkiWiki::readfile(IkiWiki::srcfile("smileys.mdwn"));
17 while ($list =~ m/^\s*\*\s+\\([^\s]+)\s+\[\[([^]]+)\]\]/mg) {
22 IkiWiki::debug("failed to parse any smileys, disabling plugin");
26 IkiWiki::hook(type => "filter", id => "smiley", call => \&filter);
27 # sort and reverse so that substrings come after longer strings
28 # that contain them, in most cases.
29 $smiley_regexp='('.join('|', map { quotemeta }
30 reverse sort keys %smileys).')';
31 #IkiWiki::debug($smiley_regexp);
37 $params{content} =~ s{(?<=\s)(\\?)$smiley_regexp(?=\s)}{
38 $1 ? $2 : IkiWiki::htmllink($params{page}, $params{page}, $smileys{$2}, 0, 0, $2)
41 return $params{content};