changeset 9071:2233d33b2285

[gaim-migrate @ 9847] This fixes the bug where other GtkTextTags (e.g. from gtkspell) would confuse us slightly and make us end and restart tags at seemingly random places. I.e. we would do like </b><b> for seemingly no good reason. This caused the double link bug on protocols where links didn't have descriptions. <a href="http://foo.bar">http://foo.bar</a> might be split into two links. On AIM that doesn't matter, but on Yahoo and MSN it does. I might have implemented this slightly differently, but I'm assuming that datallah tested this good and so I don't want to mess with it if it works. Oh yeah, did i mention datallah wrote this patch? Thanks! People might want to test this well and make sure we still generate good html. This is probably one of the most important functions in imhtml, with gtk_imhtml_insert_html_at_iter being the other one. The latter parses html and inserts it into a GtkTextBuffer, while the function this patch patches takes a GtkTextBuffer (or a piece of one) and turns it into html. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Wed, 26 May 2004 05:25:06 +0000
parents f13172eed3ad
children 96bfa9bd110f
files src/gtkimhtml.c
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkimhtml.c	Wed May 26 04:55:10 2004 +0000
+++ b/src/gtkimhtml.c	Wed May 26 05:25:06 2004 +0000
@@ -3768,13 +3768,14 @@
 	nextiter = iter = *start;
 	gtk_text_iter_forward_char(&nextiter);
 
-	/* First add the tags that are already in progress */
+	/* First add the tags that are already in progress (we don't care about non-printing tags)*/
 	tags = gtk_text_iter_get_tags(start);
 
 	for (sl = tags; sl; sl = sl->next) {
 		tag = sl->data;
 		if (!gtk_text_iter_toggles_tag(start, GTK_TEXT_TAG(tag))) {
-		 	g_string_append(str, tag_to_html_start(GTK_TEXT_TAG(tag)));
+			if (strlen(tag_to_html_end(tag)) > 0)
+		 		g_string_append(str, tag_to_html_start(tag));
 			g_queue_push_tail(q, tag);
 		}
 	}
@@ -3787,7 +3788,8 @@
 		for (sl = tags; sl; sl = sl->next) {
 			tag = sl->data;
 			if (gtk_text_iter_begins_tag(&iter, GTK_TEXT_TAG(tag))) {
-		 		g_string_append(str, tag_to_html_start(GTK_TEXT_TAG(tag)));
+				if (strlen(tag_to_html_end(tag)) > 0)
+		 			g_string_append(str, tag_to_html_start(tag));
 				g_queue_push_tail(q, tag);
 			}
 		}
@@ -3795,11 +3797,11 @@
 
 		if (c == 0xFFFC) {
 			GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(&iter);
-			char *text = NULL;
-			if (anchor)
-				text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_htmltext");
-			if (text)
-				str = g_string_append(str, text);
+			if (anchor) {
+				char *text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_htmltext");
+				if (text)
+					str = g_string_append(str, text);
+			}
 		} else 	if (c == '<') {
 			str = g_string_append(str, "&lt;");
 		} else if (c == '>') {
@@ -3817,7 +3819,8 @@
 		tags = g_slist_reverse(tags);
 		for (sl = tags; sl; sl = sl->next) {
 			tag = sl->data;
-			if (tag_ends_here(tag, &iter, &nextiter)) {
+			/** don't worry about non-printing tags ending */
+			if (tag_ends_here(tag, &iter, &nextiter) && strlen(tag_to_html_end(tag)) > 0) {
 
 				GtkTextTag *tmp;
 
@@ -3825,7 +3828,7 @@
 					if (tmp == NULL)
 						break;
 
-					if (!tag_ends_here(tmp, &iter, &nextiter))
+					if (!tag_ends_here(tmp, &iter, &nextiter) && strlen(tag_to_html_end(tmp)) > 0)
 						g_queue_push_tail(r, tmp);
 		 			g_string_append(str, tag_to_html_end(GTK_TEXT_TAG(tmp)));
 				}