=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.47 retrieving revision 1.73 diff -u -p -r1.47 -r1.73 --- mandoc/mdoc_html.c 2009/11/14 12:04:59 1.47 +++ mandoc/mdoc_html.c 2010/06/04 21:05:39 1.73 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.47 2009/11/14 12:04:59 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.73 2010/06/04 21:05:39 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -14,8 +14,11 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include -#include #include #include @@ -24,6 +27,7 @@ #include #include +#include "mandoc.h" #include "out.h" #include "html.h" #include "mdoc.h" @@ -36,6 +40,10 @@ const struct mdoc_node *n, \ struct html *h +#ifndef MIN +#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b)) +#endif + struct htmlmdoc { int (*pre)(MDOC_ARGS); void (*post)(MDOC_ARGS); @@ -49,8 +57,6 @@ static void print_mdoc_nodelist(MDOC_ARGS); static void a2width(const char *, struct roffsu *); static void a2offs(const char *, struct roffsu *); -static int a2list(const struct mdoc_node *); - static void mdoc_root_post(MDOC_ARGS); static int mdoc_root_pre(MDOC_ARGS); @@ -78,6 +84,7 @@ static void mdoc_dq_post(MDOC_ARGS); static int mdoc_dq_pre(MDOC_ARGS); static int mdoc_dv_pre(MDOC_ARGS); static int mdoc_fa_pre(MDOC_ARGS); +static void mdoc_fd_post(MDOC_ARGS); static int mdoc_fd_pre(MDOC_ARGS); static int mdoc_fl_pre(MDOC_ARGS); static int mdoc_fn_pre(MDOC_ARGS); @@ -90,11 +97,12 @@ static void mdoc_fo_post(MDOC_ARGS); static int mdoc_fo_pre(MDOC_ARGS); static int mdoc_ic_pre(MDOC_ARGS); static int mdoc_in_pre(MDOC_ARGS); -static int mdoc_it_block_pre(MDOC_ARGS, int, int, - struct roffsu *, struct roffsu *); -static int mdoc_it_head_pre(MDOC_ARGS, int, +static int mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list, + int, struct roffsu *, struct roffsu *); +static int mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list, struct roffsu *); -static int mdoc_it_body_pre(MDOC_ARGS, int); +static int mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list, + struct roffsu *); static int mdoc_it_pre(MDOC_ARGS); static int mdoc_lb_pre(MDOC_ARGS); static int mdoc_li_pre(MDOC_ARGS); @@ -126,11 +134,6 @@ static int mdoc_vt_pre(MDOC_ARGS); static int mdoc_xr_pre(MDOC_ARGS); static int mdoc_xx_pre(MDOC_ARGS); -#ifdef __linux__ -extern size_t strlcpy(char *, const char *, size_t); -extern size_t strlcat(char *, const char *, size_t); -#endif - static const struct htmlmdoc mdocs[MDOC_MAX] = { {mdoc_ap_pre, NULL}, /* Ap */ {NULL, NULL}, /* Dd */ @@ -156,7 +159,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {mdoc_ev_pre, NULL}, /* Ev */ {mdoc_ex_pre, NULL}, /* Ex */ {mdoc_fa_pre, NULL}, /* Fa */ - {mdoc_fd_pre, NULL}, /* Fd */ + {mdoc_fd_pre, mdoc_fd_post}, /* Fd */ {mdoc_fl_pre, NULL}, /* Fl */ {mdoc_fn_pre, NULL}, /* Fn */ {mdoc_ft_pre, NULL}, /* Ft */ @@ -198,7 +201,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {NULL, NULL}, /* Dc */ {mdoc_dq_pre, mdoc_dq_post}, /* Do */ {mdoc_dq_pre, mdoc_dq_post}, /* Dq */ - {NULL, NULL}, /* Ec */ + {NULL, NULL}, /* Ec */ /* FIXME: no space */ {NULL, NULL}, /* Ef */ {mdoc_em_pre, NULL}, /* Em */ {NULL, NULL}, /* Eo */ @@ -253,6 +256,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {mdoc_sp_pre, NULL}, /* br */ {mdoc_sp_pre, NULL}, /* sp */ {mdoc__x_pre, mdoc__x_post}, /* %U */ + {NULL, NULL}, /* Ta */ }; @@ -264,7 +268,7 @@ html_mdoc(void *arg, const struct mdoc *m) h = (struct html *)arg; - print_gen_doctype(h); + print_gen_decls(h); t = print_otag(h, TAG_HTML, 0, NULL); print_mdoc(mdoc_meta(m), mdoc_node(m), h); print_tagq(h, t); @@ -274,50 +278,6 @@ html_mdoc(void *arg, const struct mdoc *m) /* - * Return the list type for `Bl', e.g., `Bl -column' returns - * MDOC_Column. This can ONLY be run for lists; it will abort() if no - * list type is found. - */ -static int -a2list(const struct mdoc_node *n) -{ - int i; - - assert(n->args); - for (i = 0; i < (int)n->args->argc; i++) - switch (n->args->argv[i].arg) { - case (MDOC_Enum): - /* FALLTHROUGH */ - case (MDOC_Dash): - /* FALLTHROUGH */ - case (MDOC_Hyphen): - /* FALLTHROUGH */ - case (MDOC_Bullet): - /* FALLTHROUGH */ - case (MDOC_Tag): - /* FALLTHROUGH */ - case (MDOC_Hang): - /* FALLTHROUGH */ - case (MDOC_Inset): - /* FALLTHROUGH */ - case (MDOC_Diag): - /* FALLTHROUGH */ - case (MDOC_Item): - /* FALLTHROUGH */ - case (MDOC_Column): - /* FALLTHROUGH */ - case (MDOC_Ohang): - return(n->args->argv[i].arg); - default: - break; - } - - abort(); - /* NOTREACHED */ -} - - -/* * Calculate the scaling unit passed in a `-width' argument. This uses * either a native scaling unit (e.g., 1i, 2m) or the string length of * the value. @@ -385,7 +345,7 @@ print_mdoc_head(MDOC_ARGS) print_gen_head(h); bufinit(h); - buffmt(h, "%s(%d)", m->title, m->msec); + buffmt(h, "%s(%s)", m->title, m->msec); if (m->arch) { bufcat(h, " ("); @@ -424,7 +384,7 @@ print_mdoc_node(MDOC_ARGS) break; case (MDOC_TEXT): print_text(h, n->string); - break; + return; default: if (mdocs[n->tok].pre) child = (*mdocs[n->tok].pre)(m, n, h); @@ -441,8 +401,6 @@ print_mdoc_node(MDOC_ARGS) case (MDOC_ROOT): mdoc_root_post(m, n, h); break; - case (MDOC_TEXT): - break; default: if (mdocs[n->tok].post) (*mdocs[n->tok].post)(m, n, h); @@ -509,7 +467,7 @@ mdoc_root_pre(MDOC_ARGS) } (void)snprintf(title, BUFSIZ - 1, - "%s(%d)", m->title, m->msec); + "%s(%s)", m->title, m->msec); /* XXX: see note in mdoc_root_post() about divs. */ @@ -589,14 +547,9 @@ mdoc_sh_pre(MDOC_ARGS) html_idcat(buf, " ", BUFSIZ); } - /* - * TODO: make sure there are no duplicates, as HTML does not - * allow for multiple `id' tags of the same name. - */ - PAIR_CLASS_INIT(&tag[0], "sec-head"); - tag[1].key = ATTR_ID; - tag[1].val = buf; + PAIR_ID_INIT(&tag[1], buf); + print_otag(h, TAG_DIV, 2, tag); return(1); } @@ -648,8 +601,8 @@ mdoc_ss_pre(MDOC_ARGS) PAIR_CLASS_INIT(&tag[0], "ssec-head"); PAIR_STYLE_INIT(&tag[1], h); - tag[2].key = ATTR_ID; - tag[2].val = buf; + PAIR_ID_INIT(&tag[2], buf); + print_otag(h, TAG_DIV, 3, tag); return(1); } @@ -663,10 +616,19 @@ mdoc_fl_pre(MDOC_ARGS) PAIR_CLASS_INIT(&tag, "flag"); print_otag(h, TAG_SPAN, 1, &tag); - if (MDOC_Fl == n->tok) { - print_text(h, "\\-"); + + /* `Cm' has no leading hyphen. */ + + if (MDOC_Cm == n->tok) + return(1); + + print_text(h, "\\-"); + + if (n->child) h->flags |= HTML_NOSPACE; - } + else if (n->next && n->next->line == n->line) + h->flags |= HTML_NOSPACE; + return(1); } @@ -725,7 +687,11 @@ mdoc_nm_pre(MDOC_ARGS) { struct htmlpair tag; - if (SEC_SYNOPSIS == n->sec && n->prev) { + if (NULL == n->child && NULL == m->name) + return(1); + + if (SEC_SYNOPSIS == n->sec && + n->prev && MDOC_LINE & n->flags) { bufcat_style(h, "clear", "both"); PAIR_STYLE_INIT(&tag, h); print_otag(h, TAG_BR, 1, &tag); @@ -747,14 +713,16 @@ mdoc_xr_pre(MDOC_ARGS) struct htmlpair tag[2]; const struct mdoc_node *nn; + if (NULL == n->child) + return(0); + PAIR_CLASS_INIT(&tag[0], "link-man"); if (h->base_man) { buffmt_man(h, n->child->string, n->child->next ? n->child->next->string : NULL); - tag[1].key = ATTR_HREF; - tag[1].val = h->buf; + PAIR_HREF_INIT(&tag[1], h->buf); print_otag(h, TAG_A, 2, tag); } else print_otag(h, TAG_A, 1, tag); @@ -857,7 +825,7 @@ mdoc_bx_pre(MDOC_ARGS) /* ARGSUSED */ static int -mdoc_it_block_pre(MDOC_ARGS, int type, int comp, +mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list type, int comp, struct roffsu *offs, struct roffsu *width) { struct htmlpair tag; @@ -865,17 +833,16 @@ mdoc_it_block_pre(MDOC_ARGS, int type, int comp, struct roffsu su; nn = n->parent->parent; - assert(nn->args); /* XXX: see notes in mdoc_it_pre(). */ - if (MDOC_Column == type) { + if (LIST_column == type) { /* Don't width-pad on the left. */ SCALE_HS_INIT(width, 0); /* Also disallow non-compact. */ comp = 1; } - if (MDOC_Diag == type) + if (LIST_diag == type) /* Mandate non-compact with empty prior. */ if (n->prev && NULL == n->prev->body->child) comp = 1; @@ -912,17 +879,23 @@ mdoc_it_block_pre(MDOC_ARGS, int type, int comp, /* ARGSUSED */ static int -mdoc_it_body_pre(MDOC_ARGS, int type) +mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list type, struct roffsu *width) { struct htmlpair tag; struct roffsu su; switch (type) { - case (MDOC_Item): + case (LIST_item): /* FALLTHROUGH */ - case (MDOC_Ohang): + case (LIST_ohang): /* FALLTHROUGH */ - case (MDOC_Column): + case (LIST_column): + bufcat_su(h, "min-width", width); + bufcat_style(h, "clear", "none"); + if (n->next) + bufcat_style(h, "float", "left"); + PAIR_STYLE_INIT(&tag, h); + print_otag(h, TAG_DIV, 1, &tag); break; default: /* @@ -942,25 +915,19 @@ mdoc_it_body_pre(MDOC_ARGS, int type) /* ARGSUSED */ static int -mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *width) +mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list type, struct roffsu *width) { struct htmlpair tag; struct ord *ord; char nbuf[BUFSIZ]; switch (type) { - case (MDOC_Item): + case (LIST_item): return(0); - case (MDOC_Ohang): + case (LIST_ohang): print_otag(h, TAG_DIV, 0, &tag); return(1); - case (MDOC_Column): - bufcat_su(h, "min-width", width); - bufcat_style(h, "clear", "none"); - if (n->next && MDOC_HEAD == n->next->type) - bufcat_style(h, "float", "left"); - PAIR_STYLE_INIT(&tag, h); - print_otag(h, TAG_DIV, 1, &tag); + case (LIST_column): break; default: bufcat_su(h, "min-width", width); @@ -978,24 +945,24 @@ mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *w } switch (type) { - case (MDOC_Diag): + case (LIST_diag): PAIR_CLASS_INIT(&tag, "diag"); print_otag(h, TAG_SPAN, 1, &tag); break; - case (MDOC_Enum): + case (LIST_enum): ord = h->ords.head; assert(ord); nbuf[BUFSIZ - 1] = 0; (void)snprintf(nbuf, BUFSIZ - 1, "%d.", ord->pos++); print_text(h, nbuf); return(0); - case (MDOC_Dash): + case (LIST_dash): print_text(h, "\\(en"); return(0); - case (MDOC_Hyphen): + case (LIST_hyphen): print_text(h, "\\(hy"); return(0); - case (MDOC_Bullet): + case (LIST_bullet): print_text(h, "\\(bu"); return(0); default: @@ -1009,9 +976,10 @@ mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *w static int mdoc_it_pre(MDOC_ARGS) { - int i, type, wp, comp; + int i, wp, comp; const struct mdoc_node *bl, *nn; struct roffsu width, offs; + enum mdoc_list type; /* * XXX: be very careful in changing anything, here. Lists in @@ -1023,20 +991,20 @@ mdoc_it_pre(MDOC_ARGS) if (MDOC_BLOCK != n->type) bl = bl->parent; - type = a2list(bl); + type = bl->data.list; /* Set default width and offset. */ SCALE_HS_INIT(&offs, 0); switch (type) { - case (MDOC_Enum): + case (LIST_enum): /* FALLTHROUGH */ - case (MDOC_Dash): + case (LIST_dash): /* FALLTHROUGH */ - case (MDOC_Hyphen): + case (LIST_hyphen): /* FALLTHROUGH */ - case (MDOC_Bullet): + case (LIST_bullet): SCALE_HS_INIT(&width, 2); break; default: @@ -1046,7 +1014,8 @@ mdoc_it_pre(MDOC_ARGS) /* Get width, offset, and compact arguments. */ - for (wp = -1, comp = i = 0; i < (int)bl->args->argc; i++) + wp = -1; + for (comp = i = 0; bl->args && i < (int)bl->args->argc; i++) switch (bl->args->argv[i].arg) { case (MDOC_Column): wp = i; /* Save for later. */ @@ -1067,13 +1036,13 @@ mdoc_it_pre(MDOC_ARGS) /* Override width in some cases. */ switch (type) { - case (MDOC_Ohang): + case (LIST_ohang): /* FALLTHROUGH */ - case (MDOC_Item): + case (LIST_item): /* FALLTHROUGH */ - case (MDOC_Inset): + case (LIST_inset): /* FALLTHROUGH */ - case (MDOC_Diag): + case (LIST_diag): SCALE_HS_INIT(&width, 0); break; default: @@ -1082,25 +1051,21 @@ mdoc_it_pre(MDOC_ARGS) break; } - /* Flip to body/block processing. */ - - if (MDOC_BODY == n->type) - return(mdoc_it_body_pre(m, n, h, type)); - if (MDOC_BLOCK == n->type) - return(mdoc_it_block_pre(m, n, h, type, comp, - &offs, &width)); - - /* Override column widths. */ - - if (MDOC_Column == type) { + if (LIST_column == type && MDOC_BODY == n->type) { nn = n->parent->child; - for (i = 0; nn && nn != n; nn = nn->next, i++) - /* Counter... */ ; + for (i = 0; nn && nn != n; nn = nn->next) + if (MDOC_BODY == nn->type) + i++; if (i < (int)bl->args->argv[wp].sz) a2width(bl->args->argv[wp].value[i], &width); } - return(mdoc_it_head_pre(m, n, h, type, &width)); + if (MDOC_HEAD == n->type) + return(mdoc_it_head_pre(m, n, h, type, &width)); + else if (MDOC_BODY == n->type) + return(mdoc_it_body_pre(m, n, h, type, &width)); + + return(mdoc_it_block_pre(m, n, h, type, comp, &offs, &width)); } @@ -1110,9 +1075,11 @@ mdoc_bl_pre(MDOC_ARGS) { struct ord *ord; + if (MDOC_HEAD == n->type) + return(0); if (MDOC_BLOCK != n->type) return(1); - if (MDOC_Enum != a2list(n)) + if (LIST_enum != n->data.list) return(1); ord = malloc(sizeof(struct ord)); @@ -1136,7 +1103,7 @@ mdoc_bl_post(MDOC_ARGS) if (MDOC_BLOCK != n->type) return; - if (MDOC_Enum != a2list(n)) + if (LIST_enum != n->data.list) return; ord = h->ords.head; @@ -1172,7 +1139,7 @@ mdoc_ex_pre(MDOC_ARGS) h->flags &= ~HTML_NOSPACE; } - if (n->child->next) + if (n->child && n->child->next) print_text(h, "utilities exit"); else print_text(h, "utility exits"); @@ -1280,7 +1247,7 @@ mdoc_d1_pre(MDOC_ARGS) /* FIXME: D1 shouldn't be literal. */ - SCALE_VS_INIT(&su, INDENT - 2); + SCALE_VS_INIT(&su, INDENT - 1); bufcat_su(h, "margin-left", &su); PAIR_CLASS_INIT(&tag[0], "lit"); PAIR_STYLE_INIT(&tag[1], h); @@ -1297,8 +1264,6 @@ mdoc_sx_pre(MDOC_ARGS) const struct mdoc_node *nn; char buf[BUFSIZ]; - /* FIXME: duplicates? */ - strlcpy(buf, "#", BUFSIZ); for (nn = n->child; nn; nn = nn->next) { html_idcat(buf, nn->string, BUFSIZ); @@ -1307,8 +1272,7 @@ mdoc_sx_pre(MDOC_ARGS) } PAIR_CLASS_INIT(&tag[0], "link-sec"); - tag[1].key = ATTR_HREF; - tag[1].val = buf; + PAIR_HREF_INIT(&tag[1], buf); print_otag(h, TAG_A, 2, tag); return(1); @@ -1359,7 +1323,7 @@ mdoc_bd_pre(MDOC_ARGS) SCALE_VS_INIT(&su, 0); type = comp = 0; - for (i = 0; i < (int)bl->args->argc; i++) + for (i = 0; bl->args && i < (int)bl->args->argc; i++) switch (bl->args->argv[i].arg) { case (MDOC_Offset): a2offs(bl->args->argv[i].value[0], &su); @@ -1383,6 +1347,7 @@ mdoc_bd_pre(MDOC_ARGS) } /* FIXME: -centered, etc. formatting. */ + /* FIXME: does not respect -offset ??? */ if (MDOC_BLOCK == n->type) { bufcat_su(h, "margin-left", &su); @@ -1395,7 +1360,8 @@ mdoc_bd_pre(MDOC_ARGS) break; } if (comp) { - print_otag(h, TAG_DIV, 0, tag); + PAIR_STYLE_INIT(&tag[0], h); + print_otag(h, TAG_DIV, 1, tag); return(1); } SCALE_VS_INIT(&su, 1); @@ -1545,22 +1511,20 @@ mdoc_fa_pre(MDOC_ARGS) /* ARGSUSED */ +static void +mdoc_fd_post(MDOC_ARGS) +{ + + print_otag(h, TAG_BR, 0, NULL); +} + + +/* ARGSUSED */ static int mdoc_fd_pre(MDOC_ARGS) { struct htmlpair tag; - struct roffsu su; - if (SEC_SYNOPSIS == n->sec) { - if (n->next && MDOC_Fd != n->next->tok) { - SCALE_VS_INIT(&su, 1); - bufcat_su(h, "margin-bottom", &su); - PAIR_STYLE_INIT(&tag, h); - print_otag(h, TAG_DIV, 1, &tag); - } else - print_otag(h, TAG_DIV, 0, NULL); - } - PAIR_CLASS_INIT(&tag, "macro"); print_otag(h, TAG_SPAN, 1, &tag); return(1); @@ -1574,7 +1538,7 @@ mdoc_vt_pre(MDOC_ARGS) struct htmlpair tag; struct roffsu su; - if (SEC_SYNOPSIS == n->sec) { + if (SEC_SYNOPSIS == n->sec && MDOC_BLOCK == n->type) { if (n->next && MDOC_Vt != n->next->tok) { SCALE_VS_INIT(&su, 1); bufcat_su(h, "margin-bottom", &su); @@ -1582,7 +1546,10 @@ mdoc_vt_pre(MDOC_ARGS) print_otag(h, TAG_DIV, 1, &tag); } else print_otag(h, TAG_DIV, 0, NULL); - } + + return(1); + } else if (MDOC_HEAD == n->type) + return(0); PAIR_CLASS_INIT(&tag, "type"); print_otag(h, TAG_SPAN, 1, &tag); @@ -1595,17 +1562,9 @@ static int mdoc_ft_pre(MDOC_ARGS) { struct htmlpair tag; - struct roffsu su; - if (SEC_SYNOPSIS == n->sec) { - if (n->prev && MDOC_Fo == n->prev->tok) { - SCALE_VS_INIT(&su, 1); - bufcat_su(h, "margin-top", &su); - PAIR_STYLE_INIT(&tag, h); - print_otag(h, TAG_DIV, 1, &tag); - } else - print_otag(h, TAG_DIV, 0, NULL); - } + if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) + print_otag(h, TAG_DIV, 0, NULL); PAIR_CLASS_INIT(&tag, "ftype"); print_otag(h, TAG_SPAN, 1, &tag); @@ -1625,7 +1584,7 @@ mdoc_fn_pre(MDOC_ARGS) int sz, i; struct roffsu su; - if (SEC_SYNOPSIS == n->sec) { + if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) { SCALE_HS_INIT(&su, INDENT); bufcat_su(h, "margin-left", &su); su.scale = -su.scale; @@ -1659,10 +1618,27 @@ mdoc_fn_pre(MDOC_ARGS) } PAIR_CLASS_INIT(&tag[0], "fname"); + + /* + * FIXME: only refer to IDs that we know exist. + */ + +#if 0 + if (SEC_SYNOPSIS == n->sec) { + nbuf[0] = '\0'; + html_idcat(nbuf, sp, BUFSIZ); + PAIR_ID_INIT(&tag[1], nbuf); + } else { + strlcpy(nbuf, "#", BUFSIZ); + html_idcat(nbuf, sp, BUFSIZ); + PAIR_HREF_INIT(&tag[1], nbuf); + } +#endif + t = print_otag(h, TAG_SPAN, 1, tag); if (sp) { - (void)strlcpy(nbuf, sp, BUFSIZ); + strlcpy(nbuf, sp, BUFSIZ); print_text(h, nbuf); } @@ -1763,8 +1739,7 @@ mdoc_lk_pre(MDOC_ARGS) nn = n->child; PAIR_CLASS_INIT(&tag[0], "link-ext"); - tag[1].key = ATTR_HREF; - tag[1].val = nn->string; + PAIR_HREF_INIT(&tag[1], nn->string); print_otag(h, TAG_A, 2, tag); if (NULL == nn->next) @@ -1791,7 +1766,7 @@ mdoc_mt_pre(MDOC_ARGS) bufinit(h); bufcat(h, "mailto:"); bufcat(h, nn->string); - PAIR_STYLE_INIT(&tag[1], h); + PAIR_HREF_INIT(&tag[1], h->buf); t = print_otag(h, TAG_A, 2, tag); print_text(h, nn->string); print_tagq(h, t); @@ -1806,14 +1781,20 @@ static int mdoc_fo_pre(MDOC_ARGS) { struct htmlpair tag; + struct roffsu su; if (MDOC_BODY == n->type) { h->flags |= HTML_NOSPACE; print_text(h, "("); h->flags |= HTML_NOSPACE; return(1); - } else if (MDOC_BLOCK == n->type) + } else if (MDOC_BLOCK == n->type && n->next) { + SCALE_VS_INIT(&su, 1); + bufcat_su(h, "margin-bottom", &su); + PAIR_STYLE_INIT(&tag, h); + print_otag(h, TAG_DIV, 1, &tag); return(1); + } PAIR_CLASS_INIT(&tag, "fname"); print_otag(h, TAG_SPAN, 1, &tag); @@ -1844,7 +1825,7 @@ mdoc_in_pre(MDOC_ARGS) int i; struct roffsu su; - if (SEC_SYNOPSIS == n->sec) { + if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) { if (n->next && MDOC_In != n->next->tok) { SCALE_VS_INIT(&su, 1); bufcat_su(h, "margin-bottom", &su); @@ -1873,8 +1854,8 @@ mdoc_in_pre(MDOC_ARGS) bufinit(h); if (h->base_includes) { buffmt_includes(h, nn->string); - tag[i].key = ATTR_HREF; - tag[i++].val = h->buf; + PAIR_HREF_INIT(&tag[i], h->buf); + i++; } t = print_otag(h, TAG_A, i, tag); print_mdoc_node(m, nn, h); @@ -1926,7 +1907,7 @@ mdoc_rv_pre(MDOC_ARGS) print_text(h, "()"); } - if (n->child->next) + if (n->child && n->child->next) print_text(h, "functions return"); else print_text(h, "function returns"); @@ -2015,8 +1996,7 @@ mdoc_bf_pre(MDOC_ARGS) else if ( ! strcmp("Li", n->head->child->string)) PAIR_CLASS_INIT(&tag[0], "lit"); } else { - assert(n->args); - for (i = 0; i < (int)n->args->argc; i++) + for (i = 0; n->args && i < (int)n->args->argc; i++) switch (n->args->argv[i].arg) { case (MDOC_Symbolic): PAIR_CLASS_INIT(&tag[0], "symb"); @@ -2149,7 +2129,7 @@ mdoc_lb_pre(MDOC_ARGS) { struct htmlpair tag; - if (SEC_SYNOPSIS == n->sec) + if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags) print_otag(h, TAG_DIV, 0, NULL); PAIR_CLASS_INIT(&tag, "lib"); print_otag(h, TAG_SPAN, 1, &tag); @@ -2199,8 +2179,6 @@ mdoc__x_pre(MDOC_ARGS) break; case(MDOC__T): PAIR_CLASS_INIT(&tag[0], "ref-title"); - print_text(h, "\\(lq"); - h->flags |= HTML_NOSPACE; break; case(MDOC__U): PAIR_CLASS_INIT(&tag[0], "link-ref"); @@ -2229,14 +2207,8 @@ static void mdoc__x_post(MDOC_ARGS) { + /* TODO: %U */ + h->flags |= HTML_NOSPACE; - switch (n->tok) { - case (MDOC__T): - print_text(h, "\\(rq"); - h->flags |= HTML_NOSPACE; - break; - default: - break; - } print_text(h, n->next ? "," : "."); }