static int man_br_pre(MAN_ARGS) { struct roffsu su; struct htmlpair tag; SCALE_VS_INIT(&su, 1); if (MAN_sp == n->tok) { if (NULL != (n = n->child)) if ( ! a2roffsu(n->string, &su, SCALE_VS)) SCALE_VS_INIT(&su, atoi(n->string)); } else su.scale = 0.0; bufinit(h); bufcat_su(h, "height", &su); PAIR_STYLE_INIT(&tag, h); print_otag(h, TAG_DIV, 1, &tag); /* So the div isn't empty: */ print_text(h, "\\~"); return(0); }
/* ARGSUSED */ static int mdoc_d1_pre(MDOC_ARGS) { struct htmlpair tag[2]; struct roffsu su; if (MDOC_BLOCK != n->type) return(1); SCALE_VS_INIT(&su, 0); bufcat_su(h, "margin-top", &su); bufcat_su(h, "margin-bottom", &su); PAIR_STYLE_INIT(&tag[0], h); print_otag(h, TAG_BLOCKQUOTE, 1, tag); /* BLOCKQUOTE needs a block body. */ PAIR_CLASS_INIT(&tag[0], "display"); print_otag(h, TAG_DIV, 1, tag); if (MDOC_Dl == n->tok) { PAIR_CLASS_INIT(&tag[0], "lit"); print_otag(h, TAG_CODE, 1, tag); } return(1); }
/* ARGSUSED */ static int mdoc_sp_pre(MDOC_ARGS) { struct roffsu su; struct htmlpair tag; SCALE_VS_INIT(&su, 1); if (MDOC_sp == n->tok) { if (n->child) a2roffsu(n->child->string, &su, SCALE_VS); } else su.scale = 0; bufinit(h); bufcat_su(h, "height", &su); PAIR_STYLE_INIT(&tag, h); print_otag(h, TAG_DIV, 1, &tag); /* So the div isn't empty: */ print_text(h, "\\~"); return(0); }
static size_t a2height(const struct termp *p, const char *cp) { struct roffsu su; if ( ! a2roffsu(cp, &su, SCALE_VS)) SCALE_VS_INIT(&su, atoi(cp)); return(term_vspan(p, &su)); }
static size_t a2height(const struct termp *p, const char *v) { struct roffsu su; assert(v); if ( ! a2roffsu(v, &su, SCALE_VS)) SCALE_VS_INIT(&su, term_len(p, 1)); return(term_vspan(p, &su)); }
/* ARGSUSED */ static int mdoc_bl_pre(MDOC_ARGS) { int i; struct htmlpair tag[3]; struct roffsu su; char buf[BUFSIZ]; if (MDOC_BODY == n->type) { if (LIST_column == n->norm->Bl.type) print_otag(h, TAG_TBODY, 0, NULL); return(1); } if (MDOC_HEAD == n->type) { if (LIST_column != n->norm->Bl.type) return(0); /* * For each column, print out the <COL> tag with our * suggested width. The last column gets min-width, as * in terminal mode it auto-sizes to the width of the * screen and we want to preserve that behaviour. */ for (i = 0; i < (int)n->norm->Bl.ncols; i++) { a2width(n->norm->Bl.cols[i], &su); bufinit(h); if (i < (int)n->norm->Bl.ncols - 1) bufcat_su(h, "width", &su); else bufcat_su(h, "min-width", &su); PAIR_STYLE_INIT(&tag[0], h); print_otag(h, TAG_COL, 1, tag); } return(0); } SCALE_VS_INIT(&su, 0); bufcat_su(h, "margin-top", &su); bufcat_su(h, "margin-bottom", &su); PAIR_STYLE_INIT(&tag[0], h); assert(lists[n->norm->Bl.type]); strlcpy(buf, "list ", BUFSIZ); strlcat(buf, lists[n->norm->Bl.type], BUFSIZ); PAIR_INIT(&tag[1], ATTR_CLASS, buf); /* Set the block's left-hand margin. */ if (n->norm->Bl.offs) { a2offs(n->norm->Bl.offs, &su); bufcat_su(h, "margin-left", &su); } switch (n->norm->Bl.type) { case(LIST_bullet): /* FALLTHROUGH */ case(LIST_dash): /* FALLTHROUGH */ case(LIST_hyphen): /* FALLTHROUGH */ case(LIST_item): print_otag(h, TAG_UL, 2, tag); break; case(LIST_enum): print_otag(h, TAG_OL, 2, tag); break; case(LIST_diag): /* FALLTHROUGH */ case(LIST_hang): /* FALLTHROUGH */ case(LIST_inset): /* FALLTHROUGH */ case(LIST_ohang): /* FALLTHROUGH */ case(LIST_tag): print_otag(h, TAG_DL, 2, tag); break; case(LIST_column): print_otag(h, TAG_TABLE, 2, tag); break; default: abort(); /* NOTREACHED */ } return(1); }
/* ARGSUSED */ static int mdoc_it_pre(MDOC_ARGS) { struct roffsu su; enum mdoc_list type; struct htmlpair tag[2]; const struct mdoc_node *bl; bl = n->parent; while (bl && MDOC_Bl != bl->tok) bl = bl->parent; assert(bl); type = bl->norm->Bl.type; assert(lists[type]); PAIR_CLASS_INIT(&tag[0], lists[type]); if (MDOC_HEAD == n->type) { switch (type) { case(LIST_bullet): /* FALLTHROUGH */ case(LIST_dash): /* FALLTHROUGH */ case(LIST_item): /* FALLTHROUGH */ case(LIST_hyphen): /* FALLTHROUGH */ case(LIST_enum): return(0); case(LIST_diag): /* FALLTHROUGH */ case(LIST_hang): /* FALLTHROUGH */ case(LIST_inset): /* FALLTHROUGH */ case(LIST_ohang): /* FALLTHROUGH */ case(LIST_tag): SCALE_VS_INIT(&su, ! bl->norm->Bl.comp); bufcat_su(h, "margin-top", &su); PAIR_STYLE_INIT(&tag[1], h); print_otag(h, TAG_DT, 2, tag); if (LIST_diag != type) break; PAIR_CLASS_INIT(&tag[0], "diag"); print_otag(h, TAG_B, 1, tag); break; case(LIST_column): break; default: break; } } else if (MDOC_BODY == n->type) { switch (type) { case(LIST_bullet): /* FALLTHROUGH */ case(LIST_hyphen): /* FALLTHROUGH */ case(LIST_dash): /* FALLTHROUGH */ case(LIST_enum): /* FALLTHROUGH */ case(LIST_item): SCALE_VS_INIT(&su, ! bl->norm->Bl.comp); bufcat_su(h, "margin-top", &su); PAIR_STYLE_INIT(&tag[1], h); print_otag(h, TAG_LI, 2, tag); break; case(LIST_diag): /* FALLTHROUGH */ case(LIST_hang): /* FALLTHROUGH */ case(LIST_inset): /* FALLTHROUGH */ case(LIST_ohang): /* FALLTHROUGH */ case(LIST_tag): if (NULL == bl->norm->Bl.width) { print_otag(h, TAG_DD, 1, tag); break; } a2width(bl->norm->Bl.width, &su); bufcat_su(h, "margin-left", &su); PAIR_STYLE_INIT(&tag[1], h); print_otag(h, TAG_DD, 2, tag); break; case(LIST_column): SCALE_VS_INIT(&su, ! bl->norm->Bl.comp); bufcat_su(h, "margin-top", &su); PAIR_STYLE_INIT(&tag[1], h); print_otag(h, TAG_TD, 2, tag); break; default: break; } } else { switch (type) { case (LIST_column): print_otag(h, TAG_TR, 1, tag); break; default: break; } } return(1); }