[GRASS-SVN] r57897 - grass/trunk/lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Sep 30 15:28:15 PDT 2013
Author: martinl
Date: 2013-09-30 15:28:15 -0700 (Mon, 30 Sep 2013)
New Revision: 57897
Modified:
grass/trunk/lib/gis/parser.c
grass/trunk/lib/gis/parser_html.c
Log:
libgis/html-description: print second keyword as a link to the 'topic' page
Modified: grass/trunk/lib/gis/parser.c
===================================================================
--- grass/trunk/lib/gis/parser.c 2013-09-30 22:05:04 UTC (rev 57896)
+++ grass/trunk/lib/gis/parser.c 2013-09-30 22:28:15 UTC (rev 57897)
@@ -742,6 +742,15 @@
return 0;
}
+/*!
+ \brief Print list of keywords (internal use only)
+
+ If <em>format</em> function is NULL than list of keywords is printed
+ comma-separated.
+
+ \param[out] fd file where to print
+ \param format pointer to print function
+*/
void G__print_keywords(FILE *fd, void (*format)(FILE *, const char *))
{
int i;
Modified: grass/trunk/lib/gis/parser_html.c
===================================================================
--- grass/trunk/lib/gis/parser_html.c 2013-09-30 22:05:04 UTC (rev 57896)
+++ grass/trunk/lib/gis/parser_html.c 2013-09-30 22:28:15 UTC (rev 57897)
@@ -19,8 +19,9 @@
#include "parser_local_proto.h"
-static void print_escaped_for_html(FILE * f, const char *str);
-static void print_escaped_for_html_options(FILE * f, const char *str);
+static void print_escaped_for_html(FILE *, const char *);
+static void print_escaped_for_html_options(FILE *, const char *);
+static void print_escaped_for_html_keywords(FILE * , const char *);
/*!
\brief Print module usage description in HTML format.
@@ -66,7 +67,7 @@
fprintf(stdout, "<h2>%s</h2>\n", _("KEYWORDS"));
if (st->module_info.keywords) {
- G__print_keywords(stdout, NULL);
+ G__print_keywords(stdout, print_escaped_for_html_keywords);
fprintf(stdout, "\n");
}
fprintf(stdout, "<h2>%s</h2>\n", _("SYNOPSIS"));
@@ -312,4 +313,27 @@
}
}
}
+
+void print_escaped_for_html_keywords(FILE * f, const char * str)
+{
+ /* HTML link only for second keyword */
+ if (st->n_keys > 1 &&
+ strcmp(st->module_info.keywords[1], str) == 0) {
+
+ const char *s;
+
+ fprintf(f, "<a href=\"topic_");
+ for (s = str; *s; s++) {
+ switch (*s) {
+ do_escape(' ', "_");
+ default:
+ fputc(*s, f);
+ }
+ }
+ fprintf(f, ".html\">%s</a>", str);
+ }
+ else {
+ fprintf(f, "%s", str);
+ }
+}
#undef do_escape
More information about the grass-commit
mailing list