diff options
author | Brent Smith <bmsmith@src.gnome.org> | 2006-05-12 04:29:23 +0000 |
---|---|---|
committer | Brent Smith <bmsmith@src.gnome.org> | 2006-05-12 04:29:23 +0000 |
commit | 3a50c45c9233ea3e063f36b8f31b823ab482d270 (patch) | |
tree | 8cb9630c55ed1ba07ca43b8e0cb94eedf26e68a0 | |
parent | 87fd91cf93d5c7139376863adabba5edde8def15 (diff) | |
download | yelp-3a50c45c9233ea3e063f36b8f31b823ab482d270.tar.gz |
When a man page uses the .so macro to include another file, just provide a
* src/yelp-man-parser.c: (macro_reference_handler):
When a man page uses the .so macro to include another file, just
provide a link to the file; Only works for man pages that have
.so as the first and only macro; sort of fixes #340173
* src/yelp-toc-pager.c: (process_omf_pending):
Don't add OMF entries to the cache file that are missing a url
attribute on the identifier element
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | src/yelp-man-parser.c | 44 | ||||
-rw-r--r-- | src/yelp-toc-pager.c | 7 |
3 files changed, 61 insertions, 2 deletions
@@ -1,3 +1,13 @@ +2006-05-11 Brent Smith <gnome@nextreality.net> + + * src/yelp-man-parser.c: (macro_reference_handler): + When a man page uses the .so macro to include another file, just + provide a link to the file; Only works for man pages that have + .so as the first and only macro; sort of fixes #340173 + * src/yelp-toc-pager.c: (process_omf_pending): + Don't add OMF entries to the cache file that are missing a url + attribute on the identifier element + 2006-05-11 Don Scorgie <dscorgie@cvs.gnome.org> * src/yelp-info-parser.c: @@ -16,7 +26,7 @@ - Only match whole words (basic) - when > 1 search term, reduce number of man / info results drastically - Tweaked result scoring - - Results matching > 1 term are given precedence + - Results matching > 1 term are given precedence - Allow > 1 search at a time (different windows) - Fix various bugs - New man page result parser that collects more results (bug #331831) diff --git a/src/yelp-man-parser.c b/src/yelp-man-parser.c index 007fecc6..644e406d 100644 --- a/src/yelp-man-parser.c +++ b/src/yelp-man-parser.c @@ -676,6 +676,48 @@ macro_verbatim_handler (YelpManParser *parser, gchar *macro, GSList *args) } } +static void +macro_reference_handler (YelpManParser *parser, gchar *macro, GSList *args) +{ + if (g_str_equal (macro, "so")) { + gchar *basename = NULL; + gchar *link = NULL; + + if (args && args->data) { + basename = g_strrstr((const gchar *)args->data, "/"); + + basename++; + + if (basename) + link = g_strdup_printf ("man:%s", basename); + else { + link = g_strdup_printf ("man:%s", (const gchar *)args->data); + basename = (gchar *)args->data; + } + + parser->ins = parser_append_node (parser, "TH"); + parser->ins = parser_append_node (parser, "Title"); + parser_append_given_text (parser, "REFERENCE"); + parser->ins = parser->ins->parent; + parser->ins = parser->ins->parent; + + parser->ins = parser_append_node_attr (parser, "SH", "id", "9999"); + parser_append_given_text (parser, "REFERENCE"); + parser->ins = parser->ins->parent; + + parser_append_given_text (parser, "See "); + parser->ins = parser_append_node (parser, "UR"); + parser->ins = parser_append_node (parser, "URI"); + parser_append_given_text (parser, link); + parser->ins = parser->ins->parent; + parser_append_given_text (parser, basename); + parser->ins = parser->ins->parent; + + g_free (link); + } + } +} + /* many mandoc macros have their arguments parsed so that other * macros can be called to operate on their arguments. This table * indicates which macros are _parsed_ for other callable macros, @@ -961,7 +1003,7 @@ struct MacroHandler macro_handlers[] = { { "SH", macro_section_header_handler }, /* man: unnumbered section heading */ { "Sh", macro_section_header_handler }, /* man: unnumbered section heading */ { "SM", macro_bold_small_italic_handler }, /* man: set font size one SMaller */ - { "so", macro_ignore_handler }, /* groff: include file */ + { "so", macro_reference_handler }, /* groff: include file */ { "sp", macro_spacing_handler }, /* groff: */ { "SS", macro_section_header_handler }, /* man: unnumbered subsection heading */ { "Ss", macro_section_header_handler }, /* man: unnumbered subsection heading */ diff --git a/src/yelp-toc-pager.c b/src/yelp-toc-pager.c index 1d4187f7..2a5386e2 100644 --- a/src/yelp-toc-pager.c +++ b/src/yelp-toc-pager.c @@ -832,6 +832,7 @@ process_omf_pending (YelpTocPager *pager) while (filelist && filelist->data) { gchar *id = NULL; + gchar *url = NULL; firstfile = filelist; filelist = g_slist_remove_link (filelist, firstfile); @@ -846,6 +847,12 @@ process_omf_pending (YelpTocPager *pager) if (!omf_hash) goto done; + /* url is required, if it's not present don't even add the + * entry to the cache file */ + url = g_hash_table_lookup (omf_hash, "url"); + if (url == NULL || *url == '\0') + goto done; + /* this add all the omf information to the xml cache file */ priv->omf_ins = xmlNewChild (priv->omf_ins, NULL, BAD_CAST "omffile", NULL); |