2 package IkiWiki::Plugin::smiley;
12 hook(type => "filter", id => "smiley", call => \&filter);
15 sub build_regexp () { #{{{
16 my $list=readfile(srcfile("smileys.mdwn"));
17 while ($list =~ m/^\s*\*\s+\\([^\s]+)\s+\[\[([^]]+)\]\]/mg) {
22 debug(gettext("failed to parse any smileys"));
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 #debug($smiley_regexp);
37 build_regexp() unless defined $smiley_regexp;
38 $params{content} =~ s{(?:^|(?<=\s))(\\?)$smiley_regexp(?:(?=\s)|$)}{
39 $1 ? $2 : htmllink($params{page}, $params{page}, $smileys{$2}, linktext => $2)
40 }egs if length $smiley_regexp;
42 return $params{content};