[GRASS-dev] doc bug #411: quoting <> in html pages
Glynn Clements
glynn at gclements.plus.com
Thu May 31 05:25:11 EDT 2007
Hamish wrote:
> re bug 411
> http://wald.intevation.org/tracker/?func=detail&atid=207&aid=411&group_id=21
>
>
>
> Any <> chars used in module option descriptions are broken when
> converted into html docs.
>
> Daniel pointed out that parser.c has print_escaped_for_xml() for this.
>
> but....
>
> lib/gis/parser.c G_usage_html()
>
>
> if (opt->description) {
> fprintf(stdout, "<DD>");
> newbuf = G_str_replace(opt->description, "\n","<br>");
> if (newbuf) {
> print_escaped_for_xml(stdout, newbuf);
> G_free(newbuf);
> } else
> print_escaped_for_xml(stdout, opt->description);
> fprintf(stdout, "</DD>\n");
> }
>
>
> print_escaped_for_xml() reformats the <BR>s which were inserted by
> G_str_replace() into "<BR>". :(
>
> any ideas? Use G_tokenize() with '\n' as the field sep?
Add e.g. "char *escape_xml(const char *)" which returns either its
argument or a dynamically-allocated copy with &<> replaced. Apply that
first, then apply G_str_replace() to the result, then print that.
I wouldn't worry about free()ing the result, as this will only be
applied to a relatively limited amount of data.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list