snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit e6e84ce7b8b4f34dd2e7df2f38610749f612ad6b
parent 9aec7c9fa8fe5396451aae608f8b9c58346f4b4e
Author: default <nobody@localhost>
Date:   Fri,  7 Oct 2022 19:02:29 +0200

Added a set of smileys/emoticons that are replaced by emojis.

Diffstat:
Mformat.c | 32++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+), 0 deletions(-)

diff --git a/format.c b/format.c @@ -6,6 +6,30 @@ #include "snac.h" +/* emoticons, people laughing and such */ + +struct { + const char *key; + const char *value; +} smileys[] = { + { ":-)", "&#128578;" }, + { ":-D", "&#128512;" }, + { "X-D", "&#128518;" }, + { ";-)", "&#128521;" }, + { "B-)", "&#128526;" }, + { ":-(", "&#128542;" }, + { ":-*", "&#128536;" }, + { ":-/", "&#128533;" }, + { "8-o", "&#128562;" }, + { "%-)", "&#129322;" }, + { ":_(", "&#128546;" }, + { ":-|", "&#128528;" }, + { ":facepalm:", "&#129318;" }, + { ":shrug:", "&#129335;" }, + { NULL, NULL } +}; + + d_char *not_really_markdown(char *content, d_char **f_content) /* formats a content using some Markdown rules */ { @@ -110,6 +134,14 @@ d_char *not_really_markdown(char *content, d_char **f_content) /* some beauty fixes */ s = xs_replace_i(s, "</blockquote><br>", "</blockquote>"); + { + /* traditional emoticons */ + int n; + + for (n = 0; smileys[n].key; n++) + s = xs_replace_i(s, smileys[n].key, smileys[n].value); + } + *f_content = s; return *f_content;