+ /* So the div isn't empty: */
+ print_text(h, "\\~");
+
+ return(0);
+}
+
+static int
+man_SH_pre(MAN_ARGS)
+{
+ struct htmlpair tag;
+
+ if (MAN_BLOCK == n->type) {
+ mh->fl &= ~MANH_LITERAL;
+ PAIR_CLASS_INIT(&tag, "section");
+ print_otag(h, TAG_DIV, 1, &tag);
+ return(1);
+ } else if (MAN_BODY == n->type)
+ return(1);
+
+ print_otag(h, TAG_H1, 0, NULL);
+ return(1);
+}
+
+static int
+man_alt_pre(MAN_ARGS)
+{
+ const struct man_node *nn;
+ int i, savelit;
+ enum htmltag fp;
+ struct tag *t;
+
+ if ((savelit = mh->fl & MANH_LITERAL))
+ print_otag(h, TAG_BR, 0, NULL);
+
+ mh->fl &= ~MANH_LITERAL;
+
+ for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
+ t = NULL;
+ switch (n->tok) {
+ case MAN_BI:
+ fp = i % 2 ? TAG_I : TAG_B;
+ break;
+ case MAN_IB:
+ fp = i % 2 ? TAG_B : TAG_I;
+ break;
+ case MAN_RI:
+ fp = i % 2 ? TAG_I : TAG_MAX;
+ break;
+ case MAN_IR:
+ fp = i % 2 ? TAG_MAX : TAG_I;
+ break;
+ case MAN_BR:
+ fp = i % 2 ? TAG_MAX : TAG_B;
+ break;
+ case MAN_RB:
+ fp = i % 2 ? TAG_B : TAG_MAX;
+ break;
+ default:
+ abort();
+ /* NOTREACHED */
+ }
+
+ if (i)
+ h->flags |= HTML_NOSPACE;
+
+ if (TAG_MAX != fp)
+ t = print_otag(h, fp, 0, NULL);
+
+ print_man_node(man, nn, mh, h);
+
+ if (t)
+ print_tagq(h, t);
+ }
+
+ if (savelit)
+ mh->fl |= MANH_LITERAL;
+
+ return(0);
+}
+
+static int
+man_SM_pre(MAN_ARGS)
+{
+
+ print_otag(h, TAG_SMALL, 0, NULL);
+ if (MAN_SB == n->tok)
+ print_otag(h, TAG_B, 0, NULL);
+ return(1);
+}
+
+static int
+man_SS_pre(MAN_ARGS)
+{
+ struct htmlpair tag;
+
+ if (MAN_BLOCK == n->type) {
+ mh->fl &= ~MANH_LITERAL;
+ PAIR_CLASS_INIT(&tag, "subsection");
+ print_otag(h, TAG_DIV, 1, &tag);
+ return(1);
+ } else if (MAN_BODY == n->type)
+ return(1);
+
+ print_otag(h, TAG_H2, 0, NULL);
+ return(1);
+}
+
+static int
+man_PP_pre(MAN_ARGS)
+{
+
+ if (MAN_HEAD == n->type)
+ return(0);
+ else if (MAN_BLOCK == n->type)
+ print_bvspace(h, n);
+
+ return(1);
+}
+
+static int
+man_IP_pre(MAN_ARGS)
+{
+ const struct man_node *nn;
+
+ if (MAN_BODY == n->type) {
+ print_otag(h, TAG_DD, 0, NULL);
+ return(1);
+ } else if (MAN_HEAD != n->type) {
+ print_otag(h, TAG_DL, 0, NULL);
+ return(1);
+ }
+
+ /* FIXME: width specification. */
+
+ print_otag(h, TAG_DT, 0, NULL);
+
+ /* For IP, only print the first header element. */
+
+ if (MAN_IP == n->tok && n->child)
+ print_man_node(man, n->child, mh, h);
+
+ /* For TP, only print next-line header elements. */
+
+ if (MAN_TP == n->tok) {
+ nn = n->child;
+ while (NULL != nn && 0 == (MAN_LINE & nn->flags))
+ nn = nn->next;
+ while (NULL != nn) {
+ print_man_node(man, nn, mh, h);
+ nn = nn->next;
+ }
+ }
+
+ return(0);
+}
+
+static int
+man_HP_pre(MAN_ARGS)
+{
+ struct htmlpair tag[2];
+ struct roffsu su;
+ const struct man_node *np;
+
+ if (MAN_HEAD == n->type)
+ return(0);
+ else if (MAN_BLOCK != n->type)
+ return(1);
+
+ np = n->head->child;
+
+ if (NULL == np || ! a2width(np, &su))
+ SCALE_HS_INIT(&su, INDENT);
+
+ bufinit(h);
+
+ print_bvspace(h, n);
+ bufcat_su(h, "margin-left", &su);
+ su.scale = -su.scale;
+ bufcat_su(h, "text-indent", &su);
+ PAIR_STYLE_INIT(&tag[0], h);
+ PAIR_CLASS_INIT(&tag[1], "spacer");
+ print_otag(h, TAG_DIV, 2, tag);
+ return(1);
+}
+
+static int
+man_OP_pre(MAN_ARGS)
+{
+ struct tag *tt;
+ struct htmlpair tag;
+
+ print_text(h, "[");
+ h->flags |= HTML_NOSPACE;
+ PAIR_CLASS_INIT(&tag, "opt");
+ tt = print_otag(h, TAG_SPAN, 1, &tag);
+
+ if (NULL != (n = n->child)) {
+ print_otag(h, TAG_B, 0, NULL);
+ print_text(h, n->string);
+ }
+
+ print_stagq(h, tt);
+
+ if (NULL != n && NULL != n->next) {
+ print_otag(h, TAG_I, 0, NULL);
+ print_text(h, n->next->string);
+ }
+
+ print_stagq(h, tt);
+ h->flags |= HTML_NOSPACE;
+ print_text(h, "]");
+ return(0);
+}
+
+static int
+man_B_pre(MAN_ARGS)
+{
+
+ print_otag(h, TAG_B, 0, NULL);
+ return(1);
+}
+
+static int
+man_I_pre(MAN_ARGS)
+{
+
+ print_otag(h, TAG_I, 0, NULL);
+ return(1);
+}
+
+static int
+man_literal_pre(MAN_ARGS)
+{
+
+ if (MAN_fi == n->tok || MAN_EE == n->tok) {
+ print_otag(h, TAG_BR, 0, NULL);
+ mh->fl &= ~MANH_LITERAL;
+ } else
+ mh->fl |= MANH_LITERAL;
+
+ return(0);
+}
+
+static int
+man_in_pre(MAN_ARGS)
+{
+
+ print_otag(h, TAG_BR, 0, NULL);
+ return(0);
+}
+
+static int
+man_ign_pre(MAN_ARGS)
+{
+
+ return(0);
+}
+
+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);
+ if (n->head->child)
+ a2width(n->head->child, &su);
+
+ bufinit(h);
+ bufcat_su(h, "margin-left", &su);
+ PAIR_STYLE_INIT(&tag, h);
+ print_otag(h, TAG_DIV, 1, &tag);
+ return(1);
+}
+
+static int
+man_UR_pre(MAN_ARGS)
+{
+ struct htmlpair tag[2];
+
+ n = n->child;
+ assert(MAN_HEAD == n->type);
+ if (n->nchild) {
+ assert(MAN_TEXT == n->child->type);
+ PAIR_CLASS_INIT(&tag[0], "link-ext");
+ PAIR_HREF_INIT(&tag[1], n->child->string);
+ print_otag(h, TAG_A, 2, tag);
+ }
+
+ assert(MAN_BODY == n->next->type);
+ if (n->next->nchild)
+ n = n->next;
+
+ print_man_nodelist(man, n->child, mh, h);
+
+ return(0);