2 package IkiWiki::Plugin::smiley;
12 add_underlay("smiley");
13 hook(type => "filter", id => "smiley", call => \&filter);
16 sub build_regexp () { #{{{
17 my $list=readfile(srcfile("smileys.mdwn"));
18 while ($list =~ m/^\s*\*\s+\\([^\s]+)\s+\[\[([^]]+)\]\]/mg) {
23 debug(gettext("failed to parse any smileys"));
28 # sort and reverse so that substrings come after longer strings
29 # that contain them, in most cases.
30 $smiley_regexp='('.join('|', map { quotemeta }
31 reverse sort keys %smileys).')';
32 #debug($smiley_regexp);
38 build_regexp() unless defined $smiley_regexp;
39 $params{content} =~ s{(?:^|(?<=\s))(\\?)$smiley_regexp(?:(?=\s)|$)}{
40 $1 ? $2 : htmllink($params{page}, $params{destpage}, $smileys{$2}, linktext => $2)
41 }egs if length $smiley_regexp;
43 return $params{content};