1 Why are there graphic-based smileys at all, when Unicode supports most of them directly?
3 What Unicode doesn't support can be handled by FontAwesome or a little CSS.
5 Keeping font-based solutions to emojis allows them to scale naturally with the fonts. An emoji in the title becomes a different size than an emoji in paragraph, or an emoji in a subscript.
7 Here's a smileys.mdwn file that doesn't use any graphics at all:
10 This page is used to control what smileys are supported by the wiki.
11 Just write the text of a smiley to display it.
56 * \\{1} [<span class="priority-1">đ</span>]
57 * \\{2} [<span class="priority-2">đ</span>]
58 * \\{3} [<span class="priority-3">đ<span>]
60 For example: {x} B) {x} {3} :grin: :-1:
64 To change the supported smileys, just edit the lists on this page.
65 Note that the format is important; each list item should start with the
66 text that is turned into the smiley, escaped so that users can see what
67 produces it, followed by a [[ikiwiki/WikiLink]] to the image to display.
69 /!\ Bear in mind that the link to the image needs to be written in a way that
70 will work if it's copied to other pages on the wiki. So be sure to include the
71 smileys directory in the path to the file.
74 Here's the patch to smiley.pm:
77 --- smiley.pm.orig 2017-05-26 18:00:01.000000000 -0400
78 +++ smiley.pm 2017-05-26 22:01:18.000000000 -0400
82 my $list=readfile($srcfile);
83 - while ($list =~ m/^\s*\*\s+\\\\([^\s]+)\s+\[\[([^]]+)\]\]/mg) {
84 + while ($list =~ m/^\s*\*\s+\\\\([^\s]+)\s+\[([^\]]+)\]/mg) {
89 - $smileys{$smiley}=$file;
90 + $smileys{$smiley}=$value;
92 # Add a version with < and > escaped, since they probably
93 # will be (by markdown) by the time the sanitize hook runs.
96 - $smileys{$smiley}=$file;
97 + $smileys{$smiley}=$value;
104 # Replace the smiley with its expanded value.
105 - my $link=htmllink($params{page}, $params{destpage},
106 - $smileys{$smiley}, linktext => $smiley);
107 - substr($_, $spos, length($smiley))=$link;
108 - pos=$epos+length($link);
109 + my $value = $smileys{$smiley};
110 + my $replacement = "";
111 + if ($value =~ /\[([^\]]*)/) {
113 + $replacement=htmllink($params{page}, $params{destpage},
114 + $value, linktext => $smiley);
117 + $replacement=$value;
119 + substr($_, $spos, length($smiley))=$replacement;
120 + pos=$epos+length($replacement);
126 As you can see, it keeps the [] characters around the smiley. This can be useful if it renders to nothing in the browser -- particularly in the CSS-based solutions.
128 It keeps the same data structure, but images get a "[" prefix to them as a marker. Since I minimized the changes to the regex, the trailing "]" is still dropped.