#define listname(lt) ( (lt)==UL ? "ul" : (lt)==OL ? "ol" : "dl" )
#define itemname(lt) ( (lt)==LI ? "li" : (lt)==DT ? "dt" : "dd" )
- ho.fp = fopen(f->filename, "w");
+ if (!strcmp(f->filename, "-"))
+ ho.fp = stdout;
+ else
+ ho.fp = fopen(f->filename, "w");
if (!ho.fp)
error(err_cantopenw, f->filename);
htmlfile *file, keywordlist *keywords, htmlconfig *cfg)
{
word *w;
- char *c;
+ char *c, *c2, *p, *q;
int style, type;
for (w = words; w; w = w->next) switch (w->type) {
if (flags & LINKS) {
element_open(ho, "a");
c = utoa_dup(w->text, CS_ASCII);
- element_attr(ho, "href", c);
+ c2 = snewn(1 + 10*strlen(c), char);
+ for (p = c, q = c2; *p; p++) {
+ if (*p == '&')
+ q += sprintf(q, "&");
+ else if (*p == '<')
+ q += sprintf(q, "<");
+ else if (*p == '>')
+ q += sprintf(q, ">");
+ else
+ *q++ = *p;
+ }
+ *q = '\0';
+ element_attr(ho, "href", c2);
+ sfree(c2);
sfree(c);
}
break;
static void cleanup(htmloutput *ho)
{
return_to_neutral(ho);
- if (ho->fp)
+ if (ho->fp && ho->fp != stdout)
fclose(ho->fp);
}