<img src="/pics/smile.png" alt=":-)">
You can test it on the EmacsWiki:SandBox.
You can get the icons I used from http://www.emacswiki.org/pics. These are from the Gnus distribution and under the GPL. -- AlexSchroeder
You can get more icons from: http://helios.wmid.amu.edu.pl/~sheep/pictures/Smilies%20-%20scalable.html
...
New variables:
# Configuration/constant variables: use vars qw(... $UseSmilies %Smilies);
New minor option:
# Minor options: ... $UseSmilies = 1; # 1 = use smily pictures 0 = do not change :-) etc.
Init the Smilies variable at the end of InitLinkPatterns:
sub InitLinkPatterns { ... if ($UseSmilies) { %Smilies = ( ":-?\\)(?=\\W)" => "/pics/smile.png", ";-?\\)(?=\\W)" => "/pics/blink.png", ":-?](?=\\W)" => "/pics/forced.png", "8-?\\)(?=\\W)" => "/pics/braindamaged.png", ":-\\|(?=\\W)" => "/pics/indifferent.png", ":-?[/\\\\](?=\\W)" => "/pics/wry.png", ":-?\\((?=\\W)" => "/pics/sad.png", ":-?\\((?=\\W)" => "/pics/frown.png", ); } }
And in the middle of CommonMarkup, do the stuff:
sub CommonMarkup { ... if ($ThinLine) { s/----+/<hr noshade size=1>/g; s/====+/<hr noshade size=2>/g; } else { s/----+/<hr>/g; } if ($UseSmilies) { foreach my $regexp (keys %Smilies) { s/$regexp/<img src="$Smilies{$regexp}" alt="$&">/g; } } } if ($doLines) { # 0 = no line-oriented, 1 or 2 = do line-oriented # The quote markup patterns avoid overlapping tags (with 5 quotes) # by matching the inner quotes for the strong pattern. ...
I've added a bunch of new smilies to that list, but there is one particular one that is failing. I've added ":-?\\>(?=\\W)" as a key to the list but it never converts :> or :-> to a smile. Can anybody explain to me why Perl refuses to parse a smile with a > in it? I'm kind of new at this. I'm guessing Perl is confusing the < and > as part of some sort of reference or assignment? ~SL
$& refers to the entire matched string, here by $regexp. Here this will be the smiley. Also see "man perlre". -- MarkusLude