summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-08-17 18:20:16 +0200
committerGravatar default2023-08-17 18:20:16 +0200
commit8b176292d60975f498a5a1564ab66393a9f4fd5b (patch)
treed7329a149cc22fcee7c8b7751c1b69513955c480
parentmastoapi: in instance, return the list of supported mime types from the inter... (diff)
downloadpenes-snac2-8b176292d60975f498a5a1564ab66393a9f4fd5b.tar.gz
penes-snac2-8b176292d60975f498a5a1564ab66393a9f4fd5b.tar.xz
penes-snac2-8b176292d60975f498a5a1564ab66393a9f4fd5b.zip
Simplified smiley processing.
-rw-r--r--format.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/format.c b/format.c
index 2d09131..37b0838 100644
--- a/format.c
+++ b/format.c
@@ -8,34 +8,30 @@
8#include "snac.h" 8#include "snac.h"
9 9
10/* emoticons, people laughing and such */ 10/* emoticons, people laughing and such */
11 11const char *smileys[] = {
12struct { 12 ":-)", "🙂",
13 const char *key; 13 ":-D", "😀",
14 const char *value; 14 "X-D", "😆",
15} smileys[] = { 15 ";-)", "😉",
16 { ":-)", "🙂" }, 16 "B-)", "😎",
17 { ":-D", "😀" }, 17 ">:-(", "😡",
18 { "X-D", "😆" }, 18 ":-(", "😞",
19 { ";-)", "😉" }, 19 ":-*", "😘",
20 { "B-)", "😎" }, 20 ":-/", "😕",
21 { ">:-(", "😡" }, 21 "8-o", "😲",
22 { ":-(", "😞" }, 22 "%-)", "🤪",
23 { ":-*", "😘" }, 23 ":_(", "😢",
24 { ":-/", "😕" }, 24 ":-|", "😐",
25 { "8-o", "&#128562;" }, 25 "<3", "&#128147;",
26 { "%-)", "&#129322;" }, 26 ":facepalm:", "&#129318;",
27 { ":_(", "&#128546;" }, 27 ":shrug:", "&#129335;",
28 { ":-|", "&#128528;" }, 28 ":shrug2:", "&#175;\\_(&#12484;)_/&#175;",
29 { "<3", "&#128147;" }, 29 ":eyeroll:", "&#128580;",
30 { ":facepalm:", "&#129318;" }, 30 ":beer:", "&#127866;",
31 { ":shrug:", "&#129335;" }, 31 ":beers:", "&#127867;",
32 { ":shrug2:", "&#175;\\_(&#12484;)_/&#175;" }, 32 ":munch:", "&#128561;",
33 { ":eyeroll:", "&#128580;" }, 33 ":thumb:", "&#128077;",
34 { ":beer:", "&#127866;" }, 34 NULL, NULL
35 { ":beers:", "&#127867;" },
36 { ":munch:", "&#128561;" },
37 { ":thumb:", "&#128077;" },
38 { NULL, NULL }
39}; 35};
40 36
41 37
@@ -193,10 +189,12 @@ xs_str *not_really_markdown(const char *content, xs_list **attach)
193 189
194 { 190 {
195 /* traditional emoticons */ 191 /* traditional emoticons */
196 int n; 192 const char **emo = smileys;
197 193
198 for (n = 0; smileys[n].key; n++) 194 while (*emo) {
199 s = xs_replace_i(s, smileys[n].key, smileys[n].value); 195 s = xs_replace_i(s, emo[0], emo[1]);
196 emo += 2;
197 }
200 } 198 }
201 199
202 return s; 200 return s;