- /* 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;
-
- bufcat_style(h, "clear", "both");
- if (offs->scale > 0)
- bufcat_su(h, "margin-left", offs);
- if (width->scale > 0)
- bufcat_su(h, "padding-left", width);
-
- PAIR_STYLE_INIT(&tag, h);
-
- /* Mandate compact following `Ss' and `Sh' starts. */
-
- for (nn = n; nn && ! comp; nn = nn->parent) {
- if (MDOC_BLOCK != nn->type)
- continue;
- if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
- comp = 1;
- if (nn->prev)
- break;
- }
-
- if ( ! comp) {
- SCALE_VS_INIT(&su, 1);
- bufcat_su(h, "padding-top", &su);
- }
-
- PAIR_STYLE_INIT(&tag, h);
- print_otag(h, TAG_DIV, 1, &tag);
- return(1);
-}
-
-
-/* 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:
- /*
- * XXX: this tricks CSS into aligning the bodies with
- * the right-padding in the head.
- */
- SCALE_HS_INIT(&su, 2);
- bufcat_su(h, "margin-left", &su);
- PAIR_STYLE_INIT(&tag, h);
- print_otag(h, TAG_DIV, 1, &tag);
- break;
- }
-
- return(1);
-}
-
-
-/* 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)
- bufcat_style(h, "float", "left");
- PAIR_STYLE_INIT(&tag, h);
- print_otag(h, TAG_DIV, 1, &tag);
- break;
- default:
- bufcat_su(h, "min-width", width);
- SCALE_INVERT(width);
- bufcat_su(h, "margin-left", width);
- if (n->next && n->next->child)
- bufcat_style(h, "float", "left");
-
- /* XXX: buffer if we run into body. */
- SCALE_HS_INIT(width, 1);
- bufcat_su(h, "margin-right", width);
- PAIR_STYLE_INIT(&tag, h);
- print_otag(h, TAG_DIV, 1, &tag);
- break;
- }
-
- 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:
- break;
- }
-
- return(1);
-}
-
-
-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
- * mandoc have many peculiarities; furthermore, they don't
- * translate well into HTML and require a bit of mangling.
- */
-
- bl = n->parent->parent;
- 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:
- SCALE_HS_INIT(&width, INDENT);
- break;
- }
-
- /* Get width, offset, and compact arguments. */
-
- for (wp = -1, comp = i = 0; i < (int)bl->args->argc; i++)
- switch (bl->args->argv[i].arg) {
- case (MDOC_Column):
- wp = i; /* Save for later. */
- break;
- case (MDOC_Width):
- a2width(bl->args->argv[i].value[0], &width);
- break;
- case (MDOC_Offset):
- a2offs(bl->args->argv[i].value[0], &offs);
- break;
- case (MDOC_Compact):
- comp = 1;
- break;
- default:
- break;
- }
-
- /* 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);