summaryrefslogtreecommitdiff
path: root/libyelp/yelp-info-parser.c
diff options
context:
space:
mode:
authorRupert Swarbrick <rswarbrick@gmail.com>2010-09-11 22:21:19 +0100
committerShaun McCance <shaunm@gnome.org>2010-09-15 10:52:24 -0400
commit0aa33f153602840e0dea6df913a73280b64d0afb (patch)
treecc6b0d7bb40c35fd7b87d5b97d7a8b54d1912fa5 /libyelp/yelp-info-parser.c
parent73e13001e849ed6abac71a7addddae7de99739aa (diff)
downloadyelp-0aa33f153602840e0dea6df913a73280b64d0afb.tar.gz
Render multi-line links correctly.
Diffstat (limited to 'libyelp/yelp-info-parser.c')
-rw-r--r--libyelp/yelp-info-parser.c50
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, &paragraph, 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, &paragraph, NULL, TRUE, append);
+
g_free (url);
g_free (href);
}