Mercurial > pidgin
comparison src/html.c @ 5107:b99910bfedd2
[gaim-migrate @ 5470]
this mostly completes html_to_xhtml() except for dealing with <hr> tags,
which I'm really not too worried about right now
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Fri, 11 Apr 2003 07:07:05 +0000 |
parents | a20a644e0da4 |
children | 496ea7c1b77b |
comparison
equal
deleted
inserted
replaced
5106:7b218dde1d73 | 5107:b99910bfedd2 |
---|---|
411 } | 411 } |
412 } else { /* opening tag */ | 412 } else { /* opening tag */ |
413 ALLOW_TAG("a"); | 413 ALLOW_TAG("a"); |
414 ALLOW_TAG_ALT("b", "strong"); | 414 ALLOW_TAG_ALT("b", "strong"); |
415 ALLOW_TAG("blockquote"); | 415 ALLOW_TAG("blockquote"); |
416 ALLOW_TAG("body"); | |
417 ALLOW_TAG_ALT("bold", "strong"); | 416 ALLOW_TAG_ALT("bold", "strong"); |
418 ALLOW_TAG("br"); | 417 ALLOW_TAG("br"); |
419 ALLOW_TAG("cite"); | 418 ALLOW_TAG("cite"); |
420 ALLOW_TAG("div"); | 419 ALLOW_TAG("div"); |
421 ALLOW_TAG("em"); | 420 ALLOW_TAG("em"); |
422 ALLOW_TAG("font"); /* FIXME: not valid, need to translate */ | |
423 ALLOW_TAG("h1"); | 421 ALLOW_TAG("h1"); |
424 ALLOW_TAG("h2"); | 422 ALLOW_TAG("h2"); |
425 ALLOW_TAG("h3"); | 423 ALLOW_TAG("h3"); |
426 ALLOW_TAG("h4"); | 424 ALLOW_TAG("h4"); |
427 ALLOW_TAG("h5"); | 425 ALLOW_TAG("h5"); |
473 tags = g_list_prepend(tags, pt); | 471 tags = g_list_prepend(tags, pt); |
474 c = strchr(c, '>') + 1; | 472 c = strchr(c, '>') + 1; |
475 xhtml = g_string_append(xhtml, "<span style='vertical-align:super;'>"); | 473 xhtml = g_string_append(xhtml, "<span style='vertical-align:super;'>"); |
476 continue; | 474 continue; |
477 } | 475 } |
476 if(!g_ascii_strncasecmp(c, "<font", 5) && (*(c+5) == '>' || *(c+5) == ' ')) { | |
477 const char *p = c; | |
478 GString *style = g_string_new(""); | |
479 struct gaim_parse_tag *pt; | |
480 while(*p && *p != '>') { | |
481 if(!g_ascii_strncasecmp(p, "color=", strlen("color="))) { | |
482 const char *q = p + strlen("color="); | |
483 GString *color = g_string_new(""); | |
484 if(*q == '\'' || *q == '\"') | |
485 q++; | |
486 while(*q && *q != '\"' && *q != '\'' && *q != ' ') { | |
487 color = g_string_append_c(color, *q); | |
488 q++; | |
489 } | |
490 g_string_append_printf(style, "color: %s; ", color->str); | |
491 g_string_free(color, TRUE); | |
492 p = q; | |
493 } else if(!g_ascii_strncasecmp(p, "face=", strlen("face="))) { | |
494 const char *q = p + strlen("face="); | |
495 gboolean space_allowed = FALSE; | |
496 GString *face = g_string_new(""); | |
497 if(*q == '\'' || *q == '\"') { | |
498 space_allowed = TRUE; | |
499 q++; | |
500 } | |
501 while(*q && *q != '\"' && *q != '\'' && (space_allowed || *q != ' ')) { | |
502 face = g_string_append_c(face, *q); | |
503 q++; | |
504 } | |
505 g_string_append_printf(style, "font-family: %s; ", face->str); | |
506 g_string_free(face, TRUE); | |
507 p = q; | |
508 } else if(!g_ascii_strncasecmp(p, "size=", strlen("size="))) { | |
509 const char *q = p + strlen("size="); | |
510 int sz; | |
511 const char *size = "medium"; | |
512 if(*q == '\'' || *q == '\"') | |
513 q++; | |
514 sz = atoi(q); | |
515 if(sz < 3) | |
516 size = "smaller"; | |
517 else if(sz > 3) | |
518 size = "larger"; | |
519 g_string_append_printf(style, "font-size: %s; ", size); | |
520 p = q; | |
521 } | |
522 p++; | |
523 } | |
524 c = strchr(c, '>') + 1; | |
525 pt = g_new0(struct gaim_parse_tag, 1); | |
526 pt->src_tag = "font"; | |
527 pt->dest_tag = "span"; | |
528 tags = g_list_prepend(tags, pt); | |
529 xhtml = g_string_append(xhtml, "<span"); | |
530 if(style->len) | |
531 g_string_append_printf(xhtml, " style='%s'", style->str); | |
532 xhtml = g_string_append_c(xhtml, '>'); | |
533 g_string_free(style, TRUE); | |
534 continue; | |
535 } | |
536 if(!g_ascii_strncasecmp(c, "<body ", 6)) { | |
537 const char *p = c; | |
538 gboolean did_something = FALSE; | |
539 while(*p && *p != '>') { | |
540 if(!g_ascii_strncasecmp(p, "bgcolor=", strlen("bgcolor="))) { | |
541 const char *q = p + strlen("bgcolor="); | |
542 struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); | |
543 GString *color = g_string_new(""); | |
544 if(*q == '\'' || *q == '\"') | |
545 q++; | |
546 while(*q && *q != '\"' && *q != '\'' && *q != ' ') { | |
547 color = g_string_append_c(color, *q); | |
548 q++; | |
549 } | |
550 g_string_append_printf(xhtml, "<span style='background: %s;'>", color->str); | |
551 g_string_free(color, TRUE); | |
552 c = strchr(c, '>') + 1; | |
553 pt->src_tag = "body"; | |
554 pt->dest_tag = "span"; | |
555 tags = g_list_prepend(tags, pt); | |
556 did_something = TRUE; | |
557 break; | |
558 } | |
559 p++; | |
560 } | |
561 if(did_something) continue; | |
562 } | |
563 /* this has to come after the special case for bgcolor */ | |
564 ALLOW_TAG("body"); | |
478 if(!g_ascii_strncasecmp(c, "<!--", strlen("<!--"))) { | 565 if(!g_ascii_strncasecmp(c, "<!--", strlen("<!--"))) { |
479 char *p = strstr(c + strlen("<!--"), "-->"); | 566 char *p = strstr(c + strlen("<!--"), "-->"); |
480 if(p) { | 567 if(p) { |
481 xhtml = g_string_append(xhtml, "<!--"); | 568 xhtml = g_string_append(xhtml, "<!--"); |
482 c += strlen("<!--"); | 569 c += strlen("<!--"); |