diff options
author | Patanjali Somayaji <patanjali@codito.com> | 2002-05-22 21:17:24 +0000 |
---|---|---|
committer | Mikael Hallendal <hallski@src.gnome.org> | 2002-05-22 21:17:24 +0000 |
commit | 71344417f1cfc562866df7775b9b1e7e49e5f797 (patch) | |
tree | 34778f691633fe8d97d8341a7f5f0d956a8c6de2 | |
parent | e802e59f7745c276b18b34840bb8cb46df6a4571 (diff) | |
download | yelp-71344417f1cfc562866df7775b9b1e7e49e5f797.tar.gz |
output only the section asked for, see comment in the beginning of the
2002-05-22 Patanjali Somayaji <patanjali@codito.com>
* help-converters/info/main.c: output only the section asked for,
see comment in the beginning of the file.
* help-converters/info/html.c:
(form_info_tag_href): output links in info with ?section
-rw-r--r-- | src/info2html/html.c | 14 | ||||
-rw-r--r-- | src/info2html/main.c | 39 |
2 files changed, 45 insertions, 8 deletions
diff --git a/src/info2html/html.c b/src/info2html/html.c index 86062088..92a54da3 100644 --- a/src/info2html/html.c +++ b/src/info2html/html.c @@ -54,12 +54,14 @@ char *form_info_tag_href( char *nodefile, char *nodename ) } else filename = nodefile; - + if (galeon_mode) g_snprintf (tmp, sizeof (tmp), "HREF=\"info:%s?%s\"", filename, escaped_nodename); - else - g_snprintf (tmp, sizeof (tmp), "HREF=\"#%s\"", escaped_nodename); - + /*else + g_snprintf (tmp, sizeof (tmp), "HREF=\"#%s\"", escaped_nodename); */ + /* make the default mode output links of the form "info:filename?section" */ + else + g_snprintf (tmp, sizeof (tmp), "HREF=\"info:%s?%s\"", filename, escaped_nodename); if (escaped_nodename) g_free(escaped_nodename); return g_strdup(tmp); @@ -142,13 +144,13 @@ void write_node_link_html( FILE *f, char *nodefile, char *refname, char *ref ) { char *converted_nodename; char *href; - + if (ref) { if (g_strcasecmp(ref, "(dir)")) { converted_nodename = g_strdup( ref ); map_spaces_to_underscores( converted_nodename ); href = form_info_tag_href(nodefile, converted_nodename); - fprintf(f,"<A %s>%s%s</A>\n", href, refname, ref); + fprintf(f,"<A %s>%s%s</A>\n", href, refname, ref); g_free(href); g_free(converted_nodename); } else { diff --git a/src/info2html/main.c b/src/info2html/main.c index 33310570..d2142a7a 100644 --- a/src/info2html/main.c +++ b/src/info2html/main.c @@ -1,5 +1,13 @@ /* little test main() to see how we're doing */ +/* modifications to support : + 1. command-line of the form filename?section for yelp support + 2. outputs only "Top" section of document if no node / section is specified + 3. links modified to be of the form "info://filename?section" + + - Patanjali +*/ + #include <config.h> #include <stdio.h> #include <stdlib.h> @@ -19,9 +27,13 @@ /* be quiet or not? */ static int be_quiet=1; +char top_string [] = "Top"; + /* line_number we're on */ static int work_line_number; + static char *requested_nodename=NULL; +static char *requested_section=NULL; static struct poptOption options[] = { {NULL, 'a', POPT_ARG_STRING, &requested_nodename}, {NULL, 'b', POPT_ARG_STRING, &OverrideBaseFilename}, @@ -46,6 +58,7 @@ main(int argc, const char **argv) int result; int foundit=0; int i, n; + char *cptr; char convanc[1024]; NODE *node; @@ -68,6 +81,19 @@ main(int argc, const char **argv) return 1; for(n = 0; args[n]; n++) /* */; + + /* hack to convert the first argument to the form : + filename?section instead of passing it in with the + -a option */ + for (cptr = args [0]; *cptr != '\0'; cptr++) { + if (*cptr == '?') { + *cptr++ = '\0'; + requested_section = g_strdup (cptr); + break; + } + + } + /* requested_section now contains the requested section, if at all ... */ if(n == 1 && !file_exists(args[0])) { /* As strtok destroys the string it parses and g_getenv returns a pointer to @@ -150,8 +176,17 @@ main(int argc, const char **argv) /* convert anchor so matching works */ map_spaces_to_underscores(requested_nodename); + } else { + /* since no node has been asked for, it might have been passed in + as filename?section. In that case, set requested_nodename + to what is in requested_section, if that is NULL, set requested_nodename + to "Top" to display only the "Top" Node */ + if (requested_section) { + requested_nodename = requested_section; + } else { + requested_nodename = top_string; + } } - work_line_number = 0; /* hack, just send to stdout for now */ @@ -238,7 +273,7 @@ main(int argc, const char **argv) else continue; } - + if (!foundit && requested_nodename) { fprintf(stderr, "Requested node <b>%s</b> not found\n", requested_nodename); |