+ i = 0;
+
+ if (MAN_ROOT == n->parent->type) {
+ SCALE_HS_INIT(&su, INDENT);
+ bufcat_su(h, "margin-left", &su);
+ i = 1;
+ }
+ if (n->prev) {
+ SCALE_VS_INIT(&su, 1);
+ bufcat_su(h, "margin-top", &su);
+ i = 1;
+ }
+
+ PAIR_STYLE_INIT(&tag, h);
+ print_otag(h, TAG_DIV, i, &tag);
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
+man_IP_pre(MAN_ARGS)
+{
+ struct roffsu su;
+ struct htmlpair tag;
+ const struct man_node *nn;
+ int width;
+
+ /*
+ * This scattering of 1-BU margins and pads is to make sure that
+ * when text overruns its box, the subsequent text isn't flush
+ * up against it. However, the rest of the right-hand box must
+ * also be adjusted in consideration of this 1-BU space.
+ */
+
+ if (MAN_BODY == n->type) {
+ SCALE_HS_INIT(&su, INDENT);
+ bufcat_su(h, "margin-left", &su);
+ PAIR_STYLE_INIT(&tag, h);
+ print_otag(h, TAG_DIV, 1, &tag);
+ return(1);
+ }
+
+ nn = MAN_BLOCK == n->type ?
+ n->head->child : n->parent->head->child;
+
+ SCALE_HS_INIT(&su, INDENT);
+ width = 0;
+
+ /* Width is the last token. */
+
+ if (MAN_IP == n->tok && NULL != nn)
+ if (NULL != (nn = nn->next)) {
+ for ( ; nn->next; nn = nn->next)
+ /* Do nothing. */ ;
+ width = a2width(nn, &su);
+ }
+
+ /* Width is the first token. */
+
+ if (MAN_TP == n->tok && NULL != nn) {
+ /* Skip past non-text children. */
+ while (nn && MAN_TEXT != nn->type)
+ nn = nn->next;
+ if (nn)
+ width = a2width(nn, &su);
+ }
+
+ if (MAN_BLOCK == n->type) {
+ bufcat_su(h, "margin-left", &su);
+ SCALE_VS_INIT(&su, 1);
+ bufcat_su(h, "margin-top", &su);
+ bufcat_style(h, "clear", "both");
+ PAIR_STYLE_INIT(&tag, h);
+ print_otag(h, TAG_DIV, 1, &tag);
+ return(1);
+ }
+
+ bufcat_su(h, "min-width", &su);
+ SCALE_INVERT(&su);
+ bufcat_su(h, "margin-left", &su);
+ SCALE_HS_INIT(&su, 1);
+ bufcat_su(h, "margin-right", &su);
+ bufcat_style(h, "clear", "left");
+
+ if (n->next && n->next->child)
+ bufcat_style(h, "float", "left");
+
+ PAIR_STYLE_INIT(&tag, h);
+ print_otag(h, TAG_DIV, 1, &tag);
+
+ /*
+ * Without a length string, we can print all of our children.
+ */
+
+ if ( ! width)
+ return(1);
+
+ /*
+ * When a length has been specified, we need to carefully print
+ * our child context: IP gets all children printed but the last
+ * (the width), while TP gets all children printed but the first
+ * (the width).
+ */
+
+ if (MAN_IP == n->tok)
+ for (nn = n->child; nn->next; nn = nn->next)
+ print_man_node(m, nn, mh, h);
+ if (MAN_TP == n->tok)
+ for (nn = n->child->next; nn; nn = nn->next)
+ print_man_node(m, nn, mh, h);
+
+ return(0);
+}
+
+
+/* ARGSUSED */
+static int
+man_HP_pre(MAN_ARGS)
+{
+ const struct man_node *nn;
+ struct htmlpair tag;
+ struct roffsu su;
+
+ if (MAN_HEAD == n->type)
+ return(0);
+
+ nn = MAN_BLOCK == n->type ?
+ n->head->child : n->parent->head->child;
+
+ SCALE_HS_INIT(&su, INDENT);
+
+ if (NULL != nn)
+ (void)a2width(nn, &su);
+
+ if (MAN_BLOCK == n->type) {
+ bufcat_su(h, "margin-left", &su);
+ SCALE_VS_INIT(&su, 1);
+ bufcat_su(h, "margin-top", &su);
+ bufcat_style(h, "clear", "both");
+ PAIR_STYLE_INIT(&tag, h);
+ print_otag(h, TAG_DIV, 1, &tag);
+ return(1);
+ }
+
+ bufcat_su(h, "margin-left", &su);
+ SCALE_INVERT(&su);
+ bufcat_su(h, "text-indent", &su);
+
+ PAIR_STYLE_INIT(&tag, h);
+ print_otag(h, TAG_DIV, 1, &tag);
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
+man_B_pre(MAN_ARGS)
+{
+
+ print_ofont(h, HTMLFONT_BOLD);
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
+man_I_pre(MAN_ARGS)
+{
+
+ print_ofont(h, HTMLFONT_ITALIC);
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
+man_literal_pre(MAN_ARGS)
+{
+
+ switch (n->tok) {
+ case (MAN_nf):
+ /* FALLTHROUGH */
+ case (MAN_Vb):
+ print_otag(h, TAG_BR, 0, NULL);
+ mh->fl |= MANH_LITERAL;
+ return(MAN_Vb != n->tok);
+ default:
+ mh->fl &= ~MANH_LITERAL;
+ break;
+ }
+
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
+man_in_pre(MAN_ARGS)
+{
+
+ print_otag(h, TAG_BR, 0, NULL);
+ return(0);
+}
+
+
+/* ARGSUSED */
+static int
+man_ign_pre(MAN_ARGS)
+{
+
+ return(0);
+}
+
+
+/* ARGSUSED */
+static int
+man_RS_pre(MAN_ARGS)
+{
+ struct htmlpair tag;
+ struct roffsu su;
+
+ if (MAN_HEAD == n->type)
+ return(0);
+ else if (MAN_BODY == n->type)
+ return(1);
+
+ SCALE_HS_INIT(&su, INDENT);
+ bufcat_su(h, "margin-left", &su);
+
+ if (n->head->child) {
+ SCALE_VS_INIT(&su, 1);
+ a2width(n->head->child, &su);
+ bufcat_su(h, "margin-top", &su);
+ }