diff options
author | Rupert Swarbrick <rswarbrick@gmail.com> | 2010-12-22 00:16:30 +0000 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2011-01-10 09:33:39 -0500 |
commit | 17638fa0cbde8b0a9eac44a511c469cc2335a0cb (patch) | |
tree | 502945ea0ab8f916745171dc0d21e27df97a66a2 | |
parent | 520e28b8171cfa2ef954347d6a0726a116b66f03 (diff) | |
download | yelp-17638fa0cbde8b0a9eac44a511c469cc2335a0cb.tar.gz |
Add support for http:// urls.
-rw-r--r-- | 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 2e381f85..35079d08 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; +} |