[PATCH 3/3] Add support for http:// urls.
- From: Rupert Swarbrick <rswarbrick gmail com>
- To: gnome-doc-devel-list gnome org
- Subject: [PATCH 3/3] Add support for http:// urls.
- Date: Wed, 22 Dec 2010 00:16:30 +0000
---
libyelp/yelp-man-parser.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/libyelp/yelp-man-parser.c b/libyelp/yelp-man-parser.c
index bbfca9a..57c09b5 100644
--- a/libyelp/yelp-man-parser.c
+++ b/libyelp/yelp-man-parser.c
@@ -216,6 +216,8 @@ static void fixup_links (YelpManParser *parser,
static gsize man_link_inserter (offset_elt_pair *offsets,
const GMatchInfo *match_info);
+static gsize http_link_inserter (offset_elt_pair *offsets,
+ const GMatchInfo *match_info);
/******************************************************************************/
/* Translations for the 'C' command. This is indeed hackish, but the
@@ -1125,6 +1127,16 @@ cleanup_parsed_page (YelpManParser *parser)
g_return_if_fail (regex);
fixup_links (parser, regex, man_link_inserter);
g_regex_unref (regex);
+
+ /* Now for http:// links.
+ */
+ regex = g_regex_new ("https?:\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+"
+ "([\\w\\-\\.,@?^=%&:/~\\+#]*"
+ "[\\w\\-\\ ?^=%&/~\\+#])?",
+ 0, 0, NULL);
+ g_return_if_fail (regex);
+ fixup_links (parser, regex, http_link_inserter);
+ g_regex_unref (regex);
}
static gchar *
@@ -1520,3 +1532,21 @@ man_link_inserter (offset_elt_pair *offsets,
return do_link_insertion (url, offsets, startpos, endpos);
}
+
+static gsize
+http_link_inserter (offset_elt_pair *offsets,
+ const GMatchInfo *match_info)
+{
+ gchar *url;
+ gint startpos, endpos;
+ gsize ret;
+
+ url = g_match_info_fetch (match_info, 0);
+ g_match_info_fetch_pos (match_info, 0, &startpos, &endpos);
+
+ ret = do_link_insertion (url, offsets, startpos, endpos);
+
+ g_free (url);
+
+ return ret;
+}
--
1.7.2.3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]