diff options
author | Rupert Swarbrick <rswarbrick@gmail.com> | 2010-09-11 22:21:19 +0100 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2010-09-15 10:52:24 -0400 |
commit | 0aa33f153602840e0dea6df913a73280b64d0afb (patch) | |
tree | cc6b0d7bb40c35fd7b87d5b97d7a8b54d1912fa5 /libyelp/yelp-info-parser.c | |
parent | 73e13001e849ed6abac71a7addddae7de99739aa (diff) | |
download | yelp-0aa33f153602840e0dea6df913a73280b64d0afb.tar.gz |
Render multi-line links correctly.
Diffstat (limited to 'libyelp/yelp-info-parser.c')
-rw-r--r-- | libyelp/yelp-info-parser.c | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/libyelp/yelp-info-parser.c b/libyelp/yelp-info-parser.c index a85f733e..d4ef7bc8 100644 --- a/libyelp/yelp-info-parser.c +++ b/libyelp/yelp-info-parser.c @@ -1377,6 +1377,9 @@ info_process_text_notes (xmlNodePtr *node, gchar *content, GtkTreeStore *tree) append++; url = g_strndup (*current, append - (*current)); + /* Save a copy of the unadulterated link text for later. */ + link_text = g_strconcat ("*Note", url, NULL); + /* By now, we got 2 things. First, is append which is the (hopefully) * non-link text. Second, we got a url. * The url can be in several forms: @@ -1475,42 +1478,23 @@ info_process_text_notes (xmlNodePtr *node, gchar *content, GtkTreeStore *tree) paragraph = xmlNewChild (*node, NULL, BAD_CAST "para", NULL); } - for (ulink = urls; *ulink != NULL; ulink++) { - if (ulink == urls) - link_text = g_strconcat ("*Note", *ulink, NULL); - else { - gchar *spacing = *ulink; - gchar *tmp; - gint count = 0; - while (*spacing == ' ') { - spacing++; - count++; - } - if (spacing != *ulink) { - if (count > 1) - spacing-=2; - tmp = g_strndup (*ulink, spacing-*ulink); - if (count > 1) - spacing+=2; - xmlNewTextChild (paragraph, NULL, BAD_CAST "spacing", - BAD_CAST tmp); - g_free (tmp); - link_text = g_strdup (spacing); - } else { - link_text = g_strdup (*ulink); - } - } - ref1 = xmlNewTextChild (paragraph, NULL, BAD_CAST "a", - BAD_CAST link_text); - if (*(ulink+1) != NULL) - info_body_text (*node, ¶graph, NULL, FALSE, ""); + /* + Now we're supposed to actually render the link. I have a list of + bits of URL and actually this is really easy - I want to have + the link *text* exactly the same as it appeared in the .info + file, so don't use the list of strings urls, instead use the + whole lot: url (complete with embedded newlines etc.) + */ + ref1 = xmlNewTextChild (paragraph, NULL, BAD_CAST "a", + BAD_CAST link_text); + g_free (link_text); + xmlNewProp (ref1, BAD_CAST "href", BAD_CAST href); - g_free (link_text); - xmlNewProp (ref1, BAD_CAST "href", BAD_CAST href); - } g_strfreev (urls); - /* Finally, we can add the text as required */ + + /* Finally, we can add the following text as required */ info_body_text (*node, ¶graph, NULL, TRUE, append); + g_free (url); g_free (href); } |