# HG changeset patch # User mikanbako # Date 1210611992 -32400 # Node ID 68db38b5b40162af9c169ffb57be4d2438428b61 # Parent 0a81ccfa194197c9d665db09a6260d507ef106e3 fixed changeset 41:0a81ccfa1941 diff -r 0a81ccfa1941 -r 68db38b5b401 pidgin-twitter.c --- a/pidgin-twitter.c Tue May 13 00:35:42 2008 +0900 +++ b/pidgin-twitter.c Tue May 13 02:06:32 2008 +0900 @@ -36,6 +36,8 @@ #define COMMAND 2 #define PSEUDO 3 #define EXCESS_MARKUP 4 +#define FONT_MARKUP 5 +#define ATMARK_AFTER_A 6 #define PLUGIN_ID "gtk-honeyplanet-pidgin_twitter" #define PLUGIN_NAME "pidgin-twitter" @@ -62,7 +64,7 @@ #define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, "%s():%4d: " fmt, __FUCTION__, (int)__LINE__, ## __VA_ARGS__); /* globals */ -static GRegex *regp[5]; +static GRegex *regp[7]; static gboolean suppress_oops = FALSE; /* prototypes */ @@ -95,9 +97,21 @@ { gchar *newstr = NULL; - /* replace senders with link */ + /* strip font */ + newstr = g_regex_replace(regp[FONT_MARKUP], *str, -1, 0, "\\1", 0, NULL); + twitter_debug("*str = %s newstr = %s\n", *str, newstr); + g_free(*str); + *str = newstr; + + /* change from atmark after a to atmark before a */ + newstr = g_regex_replace(regp[ATMARK_AFTER_A], *str, -1, 0, "@\\1", 0, NULL); + twitter_debug("*str = %s newstr = %s\n", *str, newstr); + g_free(*str); + *str = newstr; + + /* strip link */ newstr = - g_regex_replace(regp[EXCESS_MARKUP], *str, -1, 0, "\\1\\2\\3", 0, NULL); + g_regex_replace(regp[EXCESS_MARKUP], *str, -1, 0, "\\1", 0, NULL); twitter_debug("*str = %s newstr = %s\n", *str, newstr); @@ -517,8 +531,10 @@ G_REGEX_RAW, 0, NULL); regp[EXCESS_MARKUP] = g_regex_new - ("([@dDfFgGlLmMnNtTwW]{1})(\\s?)(?:)?(?:)?([A-Za-z0-9_]+)(?:)?(?:)?", 0, 0, + ("\\1", 0, 0, NULL); + regp[FONT_MARKUP] = g_regex_new("(.+?)", 0, 0, NULL); + regp[ATMARK_AFTER_A] = g_regex_new("()@", 0, 0, NULL); /* attach counter to the existing twitter window */ gboolean enabled = purple_prefs_get_bool(OPT_COUNTER); @@ -554,6 +570,8 @@ g_regex_unref(regp[COMMAND]); g_regex_unref(regp[PSEUDO]); g_regex_unref(regp[EXCESS_MARKUP]); + g_regex_unref(regp[FONT_MARKUP]); + g_regex_unref(regp[ATMARK_AFTER_A]); /* detach from twitter window */ detach_from_window();