emoji.pl 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Copyright (C) 2014 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation; either version 3 of the License, or (at your option) any later
  6. # version.
  7. #
  8. # This program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along with
  13. # this program. If not, see <http://www.gnu.org/licenses/>.
  14. use strict;
  15. use v5.10;
  16. AddModuleDescription('emoji.pl', 'Smilies');
  17. our (%RuleOrder, @MyRules);
  18. push(@MyRules, \&EmojiRule);
  19. # this must come before tex.pl because of \o/ turning into ø/
  20. $RuleOrder{\&EmojiRule} = 150;
  21. # Some relevant links
  22. # https://en.wikipedia.org/wiki/List_of_emoticons
  23. sub EmojiRule {
  24. if (m/\G:-?D/cg) {
  25. # 😀 1F600 GRINNING FACE
  26. return '&#x1F600;';
  27. } elsif (/\G:[-o]?\)/cg) {
  28. # 😊 1F60A SMILING FACE WITH SMILING EYES
  29. return '&#x1F60A;';
  30. } elsif (/\G\s+:3/cg) {
  31. # 😸 1F638 GRINNING CAT FACE WITH SMILING EYES
  32. return ' &#x1f638;';
  33. } elsif (/\G:-?\(/cg) {
  34. # 😟 1F61F WORRIED FACE
  35. return '&#x1F61F;';
  36. } elsif (/\G;-?\)/cg) {
  37. # 😉 1F609 WINKING FACE
  38. return '&#x1F609;';
  39. } elsif (/\G:'\(/cg) {
  40. # 😢 1F622 CRYING FACE
  41. return '&#x1F622;';
  42. } elsif (/\G&gt;:-?\(/cg) {
  43. # 😠 1F620 ANGRY FACE
  44. return '&#x1F620;';
  45. } elsif (/\G:-?[Ppb]\b/cg) {
  46. # 😝 1F61D FACE WITH STUCK-OUT TONGUE AND TIGHTLY-CLOSED EYES
  47. return '&#x1F61D;';
  48. } elsif (/\G&lt;3/cg) {
  49. # ❤ 2764 HEAVY BLACK HEART
  50. return '&#x2764;';
  51. } elsif (/\G\^_*\^/cg) {
  52. # 😄 1F604 SMILING FACE WITH OPEN MOUTH AND SMILING EYES
  53. return '&#x1F604;';
  54. } elsif (/\G\b[Oo]_[Oo]\b/cg) {
  55. # 😲 1F632 ASTONISHED FACE
  56. return '&#x1F632;';
  57. } elsif (/\G\\o\//cg) {
  58. # 🙌 1F64C PERSON RAISING BOTH HANDS IN CELEBRATION
  59. return '&#x1F64C;';
  60. } elsif (/\G\\m\//cg) {
  61. # ✊ 270A RAISED FIST
  62. return '&#x270A;';
  63. }
  64. return;
  65. }