=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_html.c,v retrieving revision 1.17 retrieving revision 1.18 diff -c -r1.17 -r1.18 *** src/usr.bin/mandoc/mdoc_html.c 2010/05/23 22:45:00 1.17 --- src/usr.bin/mandoc/mdoc_html.c 2010/05/24 00:00:10 1.18 *************** *** 1,4 **** ! /* $Id: mdoc_html.c,v 1.17 2010/05/23 22:45:00 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * --- 1,4 ---- ! /* $Id: mdoc_html.c,v 1.18 2010/05/24 00:00:10 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * *************** *** 53,60 **** 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); --- 53,58 ---- *************** *** 94,104 **** 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, struct roffsu *); ! static int mdoc_it_body_pre(MDOC_ARGS, int); static int mdoc_it_pre(MDOC_ARGS); static int mdoc_lb_pre(MDOC_ARGS); static int mdoc_li_pre(MDOC_ARGS); --- 92,102 ---- 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, 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, enum mdoc_list); static int mdoc_it_pre(MDOC_ARGS); static int mdoc_lb_pre(MDOC_ARGS); static int mdoc_li_pre(MDOC_ARGS); *************** *** 273,322 **** /* - * 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. --- 271,276 ---- *************** *** 864,870 **** /* ARGSUSED */ static int ! mdoc_it_block_pre(MDOC_ARGS, int type, int comp, struct roffsu *offs, struct roffsu *width) { struct htmlpair tag; --- 818,824 ---- /* ARGSUSED */ static int ! mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list type, int comp, struct roffsu *offs, struct roffsu *width) { struct htmlpair tag; *************** *** 876,888 **** /* XXX: see notes in mdoc_it_pre(). */ ! if (MDOC_Column == type) { /* Don't width-pad on the left. */ SCALE_HS_INIT(width, 0); /* Also disallow non-compact. */ comp = 1; } ! if (MDOC_Diag == type) /* Mandate non-compact with empty prior. */ if (n->prev && NULL == n->prev->body->child) comp = 1; --- 830,842 ---- /* XXX: see notes in mdoc_it_pre(). */ ! if (LIST_column == type) { /* Don't width-pad on the left. */ SCALE_HS_INIT(width, 0); /* Also disallow non-compact. */ comp = 1; } ! if (LIST_diag == type) /* Mandate non-compact with empty prior. */ if (n->prev && NULL == n->prev->body->child) comp = 1; *************** *** 919,935 **** /* ARGSUSED */ static int ! mdoc_it_body_pre(MDOC_ARGS, int type) { struct htmlpair tag; struct roffsu su; switch (type) { ! case (MDOC_Item): /* FALLTHROUGH */ ! case (MDOC_Ohang): /* FALLTHROUGH */ ! case (MDOC_Column): break; default: /* --- 873,889 ---- /* ARGSUSED */ static int ! mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list type) { struct htmlpair tag; struct roffsu su; switch (type) { ! case (LIST_item): /* FALLTHROUGH */ ! case (LIST_ohang): /* FALLTHROUGH */ ! case (LIST_column): break; default: /* *************** *** 949,967 **** /* ARGSUSED */ static int ! mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *width) { struct htmlpair tag; struct ord *ord; char nbuf[BUFSIZ]; switch (type) { ! case (MDOC_Item): return(0); ! case (MDOC_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) --- 903,921 ---- /* ARGSUSED */ static int ! 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 (LIST_item): return(0); ! case (LIST_ohang): print_otag(h, TAG_DIV, 0, &tag); return(1); ! case (LIST_column): bufcat_su(h, "min-width", width); bufcat_style(h, "clear", "none"); if (n->next && MDOC_HEAD == n->next->type) *************** *** 985,1008 **** } switch (type) { ! case (MDOC_Diag): PAIR_CLASS_INIT(&tag, "diag"); print_otag(h, TAG_SPAN, 1, &tag); break; ! case (MDOC_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): print_text(h, "\\(en"); return(0); ! case (MDOC_Hyphen): print_text(h, "\\(hy"); return(0); ! case (MDOC_Bullet): print_text(h, "\\(bu"); return(0); default: --- 939,962 ---- } switch (type) { ! case (LIST_diag): PAIR_CLASS_INIT(&tag, "diag"); print_otag(h, TAG_SPAN, 1, &tag); break; ! 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 (LIST_dash): print_text(h, "\\(en"); return(0); ! case (LIST_hyphen): print_text(h, "\\(hy"); return(0); ! case (LIST_bullet): print_text(h, "\\(bu"); return(0); default: *************** *** 1016,1024 **** static int mdoc_it_pre(MDOC_ARGS) { ! int i, type, wp, comp; const struct mdoc_node *bl, *nn; struct roffsu width, offs; /* * XXX: be very careful in changing anything, here. Lists in --- 970,979 ---- static int mdoc_it_pre(MDOC_ARGS) { ! 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 *************** *** 1030,1049 **** if (MDOC_BLOCK != n->type) bl = bl->parent; ! type = a2list(bl); /* Set default width and offset. */ SCALE_HS_INIT(&offs, 0); switch (type) { ! case (MDOC_Enum): /* FALLTHROUGH */ ! case (MDOC_Dash): /* FALLTHROUGH */ ! case (MDOC_Hyphen): /* FALLTHROUGH */ ! case (MDOC_Bullet): SCALE_HS_INIT(&width, 2); break; default: --- 985,1004 ---- if (MDOC_BLOCK != n->type) bl = bl->parent; ! type = bl->data.list; /* Set default width and offset. */ SCALE_HS_INIT(&offs, 0); switch (type) { ! case (LIST_enum): /* FALLTHROUGH */ ! case (LIST_dash): /* FALLTHROUGH */ ! case (LIST_hyphen): /* FALLTHROUGH */ ! case (LIST_bullet): SCALE_HS_INIT(&width, 2); break; default: *************** *** 1074,1086 **** /* Override width in some cases. */ switch (type) { ! case (MDOC_Ohang): /* FALLTHROUGH */ ! case (MDOC_Item): /* FALLTHROUGH */ ! case (MDOC_Inset): /* FALLTHROUGH */ ! case (MDOC_Diag): SCALE_HS_INIT(&width, 0); break; default: --- 1029,1041 ---- /* Override width in some cases. */ switch (type) { ! case (LIST_ohang): /* FALLTHROUGH */ ! case (LIST_item): /* FALLTHROUGH */ ! case (LIST_inset): /* FALLTHROUGH */ ! case (LIST_diag): SCALE_HS_INIT(&width, 0); break; default: *************** *** 1099,1105 **** /* Override column widths. */ ! if (MDOC_Column == type) { nn = n->parent->child; for (i = 0; nn && nn != n; nn = nn->next, i++) /* Counter... */ ; --- 1054,1060 ---- /* Override column widths. */ ! if (LIST_column == type) { nn = n->parent->child; for (i = 0; nn && nn != n; nn = nn->next, i++) /* Counter... */ ; *************** *** 1121,1127 **** return(0); if (MDOC_BLOCK != n->type) return(1); ! if (MDOC_Enum != a2list(n)) return(1); ord = malloc(sizeof(struct ord)); --- 1076,1082 ---- return(0); if (MDOC_BLOCK != n->type) return(1); ! if (MDOC_Enum != n->data.list) return(1); ord = malloc(sizeof(struct ord)); *************** *** 1145,1151 **** if (MDOC_BLOCK != n->type) return; ! if (MDOC_Enum != a2list(n)) return; ord = h->ords.head; --- 1100,1106 ---- if (MDOC_BLOCK != n->type) return; ! if (MDOC_Enum != n->data.list) return; ord = h->ords.head;