=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.155 retrieving revision 1.158 diff -u -p -r1.155 -r1.158 --- mandoc/mdoc_html.c 2011/03/22 14:05:45 1.155 +++ mandoc/mdoc_html.c 2011/04/04 15:45:12 1.158 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.155 2011/03/22 14:05:45 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.158 2011/04/04 15:45:12 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * @@ -751,8 +751,7 @@ mdoc_nm_pre(MDOC_ARGS) static int mdoc_xr_pre(MDOC_ARGS) { - struct htmlpair tag[2]; - const struct mdoc_node *nn; + struct htmlpair tag[2]; if (NULL == n->child) return(0); @@ -768,16 +767,16 @@ mdoc_xr_pre(MDOC_ARGS) } else print_otag(h, TAG_A, 1, tag); - nn = n->child; - print_text(h, nn->string); + n = n->child; + print_text(h, n->string); - if (NULL == (nn = nn->next)) + if (NULL == (n = n->next)) return(0); h->flags |= HTML_NOSPACE; print_text(h, "("); h->flags |= HTML_NOSPACE; - print_text(h, nn->string); + print_text(h, n->string); h->flags |= HTML_NOSPACE; print_text(h, ")"); return(0); @@ -1168,14 +1167,13 @@ mdoc_d1_pre(MDOC_ARGS) static int mdoc_sx_pre(MDOC_ARGS) { - struct htmlpair tag[2]; - const struct mdoc_node *nn; - char buf[BUFSIZ]; + struct htmlpair tag[2]; + char buf[BUFSIZ]; strlcpy(buf, "#", BUFSIZ); - for (nn = n->child; nn; nn = nn->next) { - html_idcat(buf, nn->string, BUFSIZ); - if (nn->next) + for (n = n->child; n; n = n->next) { + html_idcat(buf, n->string, BUFSIZ); + if (n->next) html_idcat(buf, " ", BUFSIZ); } @@ -1451,13 +1449,13 @@ mdoc_ft_pre(MDOC_ARGS) static int mdoc_fn_pre(MDOC_ARGS) { - struct tag *t; - struct htmlpair tag[2]; - const struct mdoc_node *nn; - char nbuf[BUFSIZ]; - const char *sp, *ep; - int sz, i; + struct tag *t; + struct htmlpair tag[2]; + char nbuf[BUFSIZ]; + const char *sp, *ep; + int sz, i, pretty; + pretty = MDOC_SYNPRETTY & n->flags; synopsis_pre(h, n); /* Split apart into type and name. */ @@ -1515,14 +1513,14 @@ mdoc_fn_pre(MDOC_ARGS) bufcat_style(h, "white-space", "nowrap"); PAIR_STYLE_INIT(&tag[1], h); - for (nn = n->child->next; nn; nn = nn->next) { + for (n = n->child->next; n; n = n->next) { i = 1; if (MDOC_SYNPRETTY & n->flags) i = 2; t = print_otag(h, TAG_I, i, tag); - print_text(h, nn->string); + print_text(h, n->string); print_tagq(h, t); - if (nn->next) { + if (n->next) { h->flags |= HTML_NOSPACE; print_text(h, ","); } @@ -1531,7 +1529,7 @@ mdoc_fn_pre(MDOC_ARGS) h->flags |= HTML_NOSPACE; print_text(h, ")"); - if (MDOC_SYNPRETTY & n->flags) { + if (pretty) { h->flags |= HTML_NOSPACE; print_text(h, ";"); } @@ -1605,21 +1603,23 @@ mdoc_sp_pre(MDOC_ARGS) static int mdoc_lk_pre(MDOC_ARGS) { - const struct mdoc_node *nn; - struct htmlpair tag[2]; + struct htmlpair tag[2]; - nn = n->child; + if (NULL == (n = n->child)) + return(0); + assert(MDOC_TEXT == n->type); + PAIR_CLASS_INIT(&tag[0], "link-ext"); - PAIR_HREF_INIT(&tag[1], nn->string); + PAIR_HREF_INIT(&tag[1], n->string); + print_otag(h, TAG_A, 2, tag); - if (NULL == nn || NULL == nn->next) - return(1); + for (n = n->next; n; n = n->next) { + assert(MDOC_TEXT == n->type); + print_text(h, n->string); + } - for (nn = nn->next; nn; nn = nn->next) - print_text(h, nn->string); - return(0); } @@ -1696,38 +1696,55 @@ mdoc_fo_post(MDOC_ARGS) static int mdoc_in_pre(MDOC_ARGS) { - const struct mdoc_node *nn; - struct tag *t; - struct htmlpair tag[2]; - int i; + struct tag *t; + struct htmlpair tag[2]; + int i; synopsis_pre(h, n); PAIR_CLASS_INIT(&tag[0], "includes"); print_otag(h, TAG_B, 1, tag); + /* + * The first argument of the `In' gets special treatment as + * being a linked value. Subsequent values are printed + * afterward. groff does similarly. This also handles the case + * of no children. + */ + if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags) print_text(h, "#include"); print_text(h, "<"); h->flags |= HTML_NOSPACE; - for (nn = n->child; nn; nn = nn->next) { + if (NULL != (n = n->child)) { + assert(MDOC_TEXT == n->type); + PAIR_CLASS_INIT(&tag[0], "link-includes"); - i = 1; bufinit(h); + + i = 1; + if (h->base_includes) { - buffmt_includes(h, nn->string); - PAIR_HREF_INIT(&tag[i], h->buf); - i++; - } + buffmt_includes(h, n->string); + PAIR_HREF_INIT(&tag[i++], h->buf); + } + t = print_otag(h, TAG_A, i, tag); - print_mdoc_node(m, nn, h); + print_text(h, n->string); print_tagq(h, t); + + n = n->next; } h->flags |= HTML_NOSPACE; print_text(h, ">"); + + for ( ; n; n = n->next) { + assert(MDOC_TEXT == n->type); + print_text(h, n->string); + } return(0); }