# HG changeset patch # User Nathan Walp # Date 1050044825 0 # Node ID b99910bfedd2a4f6ad171c67f83ab70ff33a19db # Parent 7b218dde1d735d4bbe7d7caedfab73f43d2f9a7f [gaim-migrate @ 5470] this mostly completes html_to_xhtml() except for dealing with
tags, which I'm really not too worried about right now committer: Tailor Script diff -r 7b218dde1d73 -r b99910bfedd2 src/html.c --- a/src/html.c Fri Apr 11 07:01:54 2003 +0000 +++ b/src/html.c Fri Apr 11 07:07:05 2003 +0000 @@ -413,13 +413,11 @@ ALLOW_TAG("a"); ALLOW_TAG_ALT("b", "strong"); ALLOW_TAG("blockquote"); - ALLOW_TAG("body"); ALLOW_TAG_ALT("bold", "strong"); ALLOW_TAG("br"); ALLOW_TAG("cite"); ALLOW_TAG("div"); ALLOW_TAG("em"); - ALLOW_TAG("font"); /* FIXME: not valid, need to translate */ ALLOW_TAG("h1"); ALLOW_TAG("h2"); ALLOW_TAG("h3"); @@ -475,6 +473,95 @@ xhtml = g_string_append(xhtml, ""); continue; } + if(!g_ascii_strncasecmp(c, "' || *(c+5) == ' ')) { + const char *p = c; + GString *style = g_string_new(""); + struct gaim_parse_tag *pt; + while(*p && *p != '>') { + if(!g_ascii_strncasecmp(p, "color=", strlen("color="))) { + const char *q = p + strlen("color="); + GString *color = g_string_new(""); + if(*q == '\'' || *q == '\"') + q++; + while(*q && *q != '\"' && *q != '\'' && *q != ' ') { + color = g_string_append_c(color, *q); + q++; + } + g_string_append_printf(style, "color: %s; ", color->str); + g_string_free(color, TRUE); + p = q; + } else if(!g_ascii_strncasecmp(p, "face=", strlen("face="))) { + const char *q = p + strlen("face="); + gboolean space_allowed = FALSE; + GString *face = g_string_new(""); + if(*q == '\'' || *q == '\"') { + space_allowed = TRUE; + q++; + } + while(*q && *q != '\"' && *q != '\'' && (space_allowed || *q != ' ')) { + face = g_string_append_c(face, *q); + q++; + } + g_string_append_printf(style, "font-family: %s; ", face->str); + g_string_free(face, TRUE); + p = q; + } else if(!g_ascii_strncasecmp(p, "size=", strlen("size="))) { + const char *q = p + strlen("size="); + int sz; + const char *size = "medium"; + if(*q == '\'' || *q == '\"') + q++; + sz = atoi(q); + if(sz < 3) + size = "smaller"; + else if(sz > 3) + size = "larger"; + g_string_append_printf(style, "font-size: %s; ", size); + p = q; + } + p++; + } + c = strchr(c, '>') + 1; + pt = g_new0(struct gaim_parse_tag, 1); + pt->src_tag = "font"; + pt->dest_tag = "span"; + tags = g_list_prepend(tags, pt); + xhtml = g_string_append(xhtml, "len) + g_string_append_printf(xhtml, " style='%s'", style->str); + xhtml = g_string_append_c(xhtml, '>'); + g_string_free(style, TRUE); + continue; + } + if(!g_ascii_strncasecmp(c, "", color->str); + g_string_free(color, TRUE); + c = strchr(c, '>') + 1; + pt->src_tag = "body"; + pt->dest_tag = "span"; + tags = g_list_prepend(tags, pt); + did_something = TRUE; + break; + } + p++; + } + if(did_something) continue; + } + /* this has to come after the special case for bgcolor */ + ALLOW_TAG("body"); if(!g_ascii_strncasecmp(c, ""); if(p) {