static void man_root_pre(MAN_ARGS) { struct htmlpair tag; struct tag *t, *tt; char *title; assert(man->title); assert(man->msec); mandoc_asprintf(&title, "%s(%s)", man->title, man->msec); PAIR_CLASS_INIT(&tag, "head"); t = print_otag(h, TAG_TABLE, 1, &tag); print_otag(h, TAG_TBODY, 0, NULL); tt = print_otag(h, TAG_TR, 0, NULL); PAIR_CLASS_INIT(&tag, "head-ltitle"); print_otag(h, TAG_TD, 1, &tag); print_text(h, title); print_stagq(h, tt); PAIR_CLASS_INIT(&tag, "head-vol"); print_otag(h, TAG_TD, 1, &tag); if (NULL != man->vol) print_text(h, man->vol); print_stagq(h, tt); PAIR_CLASS_INIT(&tag, "head-rtitle"); print_otag(h, TAG_TD, 1, &tag); print_text(h, title); print_tagq(h, t); free(title); }
static void man_root_post(MAN_ARGS) { struct htmlpair tag; struct tag *t, *tt; PAIR_CLASS_INIT(&tag, "foot"); t = print_otag(h, TAG_TABLE, 1, &tag); tt = print_otag(h, TAG_TR, 0, NULL); PAIR_CLASS_INIT(&tag, "foot-date"); print_otag(h, TAG_TD, 1, &tag); assert(man->date); print_text(h, man->date); print_stagq(h, tt); PAIR_CLASS_INIT(&tag, "foot-os"); print_otag(h, TAG_TD, 1, &tag); if (man->source) print_text(h, man->source); print_tagq(h, t); }
/* ARGSUSED */ static int mdoc_bf_pre(MDOC_ARGS) { struct htmlpair tag[2]; struct roffsu su; if (MDOC_HEAD == n->type) return(0); else if (MDOC_BODY != n->type) return(1); if (FONT_Em == n->norm->Bf.font) PAIR_CLASS_INIT(&tag[0], "emph"); else if (FONT_Sy == n->norm->Bf.font) PAIR_CLASS_INIT(&tag[0], "symb"); else if (FONT_Li == n->norm->Bf.font) PAIR_CLASS_INIT(&tag[0], "lit"); else PAIR_CLASS_INIT(&tag[0], "none"); /* * We want this to be inline-formatted, but needs to be div to * accept block children. */ bufcat_style(h, "display", "inline"); SCALE_HS_INIT(&su, 1); /* Needs a left-margin for spacing. */ bufcat_su(h, "margin-left", &su); PAIR_STYLE_INIT(&tag[1], h); print_otag(h, TAG_DIV, 2, tag); return(1); }
/* ARGSUSED */ static void man_root_post(MAN_ARGS) { struct htmlpair tag[3]; struct tag *t, *tt; PAIR_SUMMARY_INIT(&tag[0], "Document Footer"); PAIR_CLASS_INIT(&tag[1], "foot"); PAIR_INIT(&tag[2], ATTR_WIDTH, "100%"); t = print_otag(h, TAG_TABLE, 3, tag); PAIR_INIT(&tag[0], ATTR_WIDTH, "50%"); print_otag(h, TAG_COL, 1, tag); print_otag(h, TAG_COL, 1, tag); tt = print_otag(h, TAG_TR, 0, NULL); PAIR_CLASS_INIT(&tag[0], "foot-date"); print_otag(h, TAG_TD, 1, tag); assert(man->date); print_text(h, man->date); print_stagq(h, tt); PAIR_CLASS_INIT(&tag[0], "foot-os"); PAIR_INIT(&tag[1], ATTR_ALIGN, "right"); print_otag(h, TAG_TD, 2, tag); if (man->source) print_text(h, man->source); print_tagq(h, t); }
/* ARGSUSED */ static int mdoc_root_pre(MDOC_ARGS) { struct htmlpair tag[3]; struct tag *t, *tt; char b[BUFSIZ], title[BUFSIZ]; strlcpy(b, m->vol, BUFSIZ); if (m->arch) { strlcat(b, " (", BUFSIZ); strlcat(b, m->arch, BUFSIZ); strlcat(b, ")", BUFSIZ); } snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec); PAIR_SUMMARY_INIT(&tag[0], "Document Header"); PAIR_CLASS_INIT(&tag[1], "head"); if (NULL == h->style) { PAIR_INIT(&tag[2], ATTR_WIDTH, "100%"); t = print_otag(h, TAG_TABLE, 3, tag); PAIR_INIT(&tag[0], ATTR_WIDTH, "30%"); print_otag(h, TAG_COL, 1, tag); print_otag(h, TAG_COL, 1, tag); print_otag(h, TAG_COL, 1, tag); } else t = print_otag(h, TAG_TABLE, 2, tag); print_otag(h, TAG_TBODY, 0, NULL); tt = print_otag(h, TAG_TR, 0, NULL); PAIR_CLASS_INIT(&tag[0], "head-ltitle"); print_otag(h, TAG_TD, 1, tag); print_text(h, title); print_stagq(h, tt); PAIR_CLASS_INIT(&tag[0], "head-vol"); if (NULL == h->style) { PAIR_INIT(&tag[1], ATTR_ALIGN, "center"); print_otag(h, TAG_TD, 2, tag); } else print_otag(h, TAG_TD, 1, tag); print_text(h, b); print_stagq(h, tt); PAIR_CLASS_INIT(&tag[0], "head-rtitle"); if (NULL == h->style) { PAIR_INIT(&tag[1], ATTR_ALIGN, "right"); print_otag(h, TAG_TD, 2, tag); } else print_otag(h, TAG_TD, 1, tag); print_text(h, title); print_tagq(h, t); return(1); }
/* 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_fd_pre(MDOC_ARGS) { struct htmlpair tag[2]; char buf[BUFSIZ]; size_t sz; int i; struct tag *t; synopsis_pre(h, n); if (NULL == (n = n->child)) return(0); assert(MDOC_TEXT == n->type); if (strcmp(n->string, "#include")) { PAIR_CLASS_INIT(&tag[0], "macro"); print_otag(h, TAG_B, 1, tag); return(1); } PAIR_CLASS_INIT(&tag[0], "includes"); print_otag(h, TAG_B, 1, tag); print_text(h, n->string); if (NULL != (n = n->next)) { assert(MDOC_TEXT == n->type); strlcpy(buf, '<' == *n->string || '"' == *n->string ? n->string + 1 : n->string, BUFSIZ); sz = strlen(buf); if (sz && ('>' == buf[sz - 1] || '"' == buf[sz - 1])) buf[sz - 1] = '\0'; PAIR_CLASS_INIT(&tag[0], "link-includes"); bufinit(h); i = 1; if (h->base_includes) { buffmt_includes(h, buf); PAIR_HREF_INIT(&tag[i], h->buf); i++; } t = print_otag(h, TAG_A, i, tag); print_text(h, n->string); print_tagq(h, t); n = n->next; } for ( ; n; n = n->next) { assert(MDOC_TEXT == n->type); print_text(h, n->string); } return(0); }
/* ARGSUSED */ static int mdoc_in_pre(MDOC_ARGS) { struct tag *t; struct htmlpair tag[2]; int i; synopsis_pre(h, n); PAIR_CLASS_INIT(&tag[0], "includes"); print_otag(h, TAG_B, 1, tag); /* * The first argument of the `In' gets special treatment as * being a linked value. Subsequent values are printed * afterward. groff does similarly. This also handles the case * of no children. */ if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags) print_text(h, "#include"); print_text(h, "<"); h->flags |= HTML_NOSPACE; if (NULL != (n = n->child)) { assert(MDOC_TEXT == n->type); PAIR_CLASS_INIT(&tag[0], "link-includes"); bufinit(h); i = 1; if (h->base_includes) { buffmt_includes(h, n->string); PAIR_HREF_INIT(&tag[i], h->buf); i++; } t = print_otag(h, TAG_A, i, tag); print_text(h, n->string); print_tagq(h, t); n = n->next; } h->flags |= HTML_NOSPACE; print_text(h, ">"); for ( ; n; n = n->next) { assert(MDOC_TEXT == n->type); print_text(h, n->string); } return(0); }
static int mdoc_rv_pre(MDOC_ARGS) { struct htmlpair tag; struct tag *t; int nchild; if (n->prev) print_otag(h, TAG_BR, 0, NULL); PAIR_CLASS_INIT(&tag, "fname"); nchild = n->nchild; if (nchild > 0) { print_text(h, "The"); for (n = n->child; n; n = n->next) { t = print_otag(h, TAG_B, 1, &tag); print_text(h, n->string); print_tagq(h, t); h->flags |= HTML_NOSPACE; print_text(h, "()"); if (n->next == NULL) continue; if (nchild > 2) { h->flags |= HTML_NOSPACE; print_text(h, ","); } if (n->next->next == NULL) print_text(h, "and"); } if (nchild > 1) print_text(h, "functions return"); else print_text(h, "function returns"); print_text(h, "the value\\~0 if successful;"); } else print_text(h, "Upon successful completion," " the value\\~0 is returned;"); print_text(h, "otherwise the value\\~\\-1 is returned" " and the global variable"); PAIR_CLASS_INIT(&tag, "var"); t = print_otag(h, TAG_B, 1, &tag); print_text(h, "errno"); print_tagq(h, t); print_text(h, "is set to indicate the error."); return(0); }
/* ARGSUSED */ static int mdoc_rv_pre(MDOC_ARGS) { struct htmlpair tag; struct tag *t; int nchild; if (n->prev) print_otag(h, TAG_BR, 0, NULL); PAIR_CLASS_INIT(&tag, "fname"); print_text(h, "The"); nchild = n->nchild; for (n = n->child; n; n = n->next) { assert(MDOC_TEXT == n->type); t = print_otag(h, TAG_B, 1, &tag); print_text(h, n->string); print_tagq(h, t); h->flags |= HTML_NOSPACE; print_text(h, "()"); if (nchild > 2 && n->next) { h->flags |= HTML_NOSPACE; print_text(h, ","); } if (n->next && NULL == n->next->next) print_text(h, "and"); } if (nchild > 1) print_text(h, "functions return"); else print_text(h, "function returns"); print_text(h, "the value 0 if successful; otherwise the value " "-1 is returned and the global variable"); PAIR_CLASS_INIT(&tag, "var"); t = print_otag(h, TAG_B, 1, &tag); print_text(h, "errno"); print_tagq(h, t); print_text(h, "is set to indicate the error."); return(0); }
static int mdoc_nm_pre(MDOC_ARGS) { struct htmlpair tag; struct roffsu su; int len; switch (n->type) { case MDOC_ELEM: synopsis_pre(h, n); PAIR_CLASS_INIT(&tag, "name"); print_otag(h, TAG_B, 1, &tag); if (NULL == n->child && meta->name) print_text(h, meta->name); return(1); case MDOC_HEAD: print_otag(h, TAG_TD, 0, NULL); if (NULL == n->child && meta->name) print_text(h, meta->name); return(1); case MDOC_BODY: print_otag(h, TAG_TD, 0, NULL); return(1); default: break; } synopsis_pre(h, n); PAIR_CLASS_INIT(&tag, "synopsis"); print_otag(h, TAG_TABLE, 1, &tag); for (len = 0, n = n->child; n; n = n->next) if (MDOC_TEXT == n->type) len += html_strlen(n->string); if (0 == len && meta->name) len = html_strlen(meta->name); SCALE_HS_INIT(&su, len); bufinit(h); bufcat_su(h, "width", &su); PAIR_STYLE_INIT(&tag, h); print_otag(h, TAG_COL, 1, &tag); print_otag(h, TAG_COL, 0, NULL); print_otag(h, TAG_TBODY, 0, NULL); print_otag(h, TAG_TR, 0, NULL); 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_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 mdoc_an_pre(MDOC_ARGS) { struct htmlpair tag; if (n->norm->An.auth == AUTH_split) { h->flags &= ~HTML_NOSPLIT; h->flags |= HTML_SPLIT; return(0); } if (n->norm->An.auth == AUTH_nosplit) { h->flags &= ~HTML_SPLIT; h->flags |= HTML_NOSPLIT; return(0); } if (h->flags & HTML_SPLIT) print_otag(h, TAG_BR, 0, NULL); if (n->sec == SEC_AUTHORS && ! (h->flags & HTML_NOSPLIT)) h->flags |= HTML_SPLIT; PAIR_CLASS_INIT(&tag, "author"); print_otag(h, TAG_SPAN, 1, &tag); return(1); }
static void html_tblopen(struct html *h, const struct tbl_span *sp) { struct htmlpair tag; struct roffsu su; struct roffcol *col; int ic; if (h->tbl.cols == NULL) { h->tbl.len = html_tbl_len; h->tbl.slen = html_tbl_strlen; tblcalc(&h->tbl, sp, 0); } assert(NULL == h->tblt); PAIR_CLASS_INIT(&tag, "tbl"); h->tblt = print_otag(h, TAG_TABLE, 1, &tag); for (ic = 0; ic < sp->opts->cols; ic++) { bufinit(h); col = h->tbl.cols + ic; SCALE_HS_INIT(&su, col->width); bufcat_su(h, "width", &su); PAIR_STYLE_INIT(&tag, h); print_otag(h, TAG_COL, 1, &tag); } print_otag(h, TAG_TBODY, 0, NULL); }
static int mdoc_sh_pre(MDOC_ARGS) { struct htmlpair tag; switch (n->type) { case MDOC_BLOCK: PAIR_CLASS_INIT(&tag, "section"); print_otag(h, TAG_DIV, 1, &tag); return(1); case MDOC_BODY: if (n->sec == SEC_AUTHORS) h->flags &= ~(HTML_SPLIT|HTML_NOSPLIT); return(1); default: break; } bufinit(h); bufcat(h, "x"); for (n = n->child; n && MDOC_TEXT == n->type; ) { bufcat_id(h, n->string); if (NULL != (n = n->next)) bufcat_id(h, " "); } if (NULL == n) { PAIR_ID_INIT(&tag, h->buf); print_otag(h, TAG_H1, 1, &tag); } else print_otag(h, TAG_H1, 0, NULL); return(1); }
static int mdoc_ss_pre(MDOC_ARGS) { struct htmlpair tag; if (MDOC_BLOCK == n->type) { PAIR_CLASS_INIT(&tag, "subsection"); print_otag(h, TAG_DIV, 1, &tag); return(1); } else if (MDOC_BODY == n->type) return(1); bufinit(h); bufcat(h, "x"); for (n = n->child; n && MDOC_TEXT == n->type; ) { bufcat_id(h, n->string); if (NULL != (n = n->next)) bufcat_id(h, " "); } if (NULL == n) { PAIR_ID_INIT(&tag, h->buf); print_otag(h, TAG_H2, 1, &tag); } else print_otag(h, TAG_H2, 0, NULL); return(1); }
/* ARGSUSED */ static int mdoc_fa_pre(MDOC_ARGS) { const struct mdoc_node *nn; struct htmlpair tag; struct tag *t; PAIR_CLASS_INIT(&tag, "farg"); if (n->parent->tok != MDOC_Fo) { print_otag(h, TAG_I, 1, &tag); return(1); } for (nn = n->child; nn; nn = nn->next) { t = print_otag(h, TAG_I, 1, &tag); print_text(h, nn->string); print_tagq(h, t); if (nn->next) { h->flags |= HTML_NOSPACE; print_text(h, ","); } } if (n->child && n->next && n->next->tok == MDOC_Fa) { h->flags |= HTML_NOSPACE; print_text(h, ","); } return(0); }
/* ARGSUSED */ static int mdoc_bx_pre(MDOC_ARGS) { struct htmlpair tag; PAIR_CLASS_INIT(&tag, "unix"); print_otag(h, TAG_SPAN, 1, &tag); if (NULL != (n = n->child)) { print_text(h, n->string); h->flags |= HTML_NOSPACE; print_text(h, "BSD"); } else { print_text(h, "BSD"); return(0); } if (NULL != (n = n->next)) { h->flags |= HTML_NOSPACE; print_text(h, "-"); h->flags |= HTML_NOSPACE; print_text(h, n->string); } return(0); }
static void html_tblopen(struct html *h, const struct tbl_span *sp) { const struct tbl_head *hp; struct htmlpair tag; struct roffsu su; struct roffcol *col; if (TBL_SPAN_FIRST & sp->flags) { h->tbl.len = html_tbl_len; h->tbl.slen = html_tbl_strlen; tblcalc(&h->tbl, sp); } assert(NULL == h->tblt); PAIR_CLASS_INIT(&tag, "tbl"); h->tblt = print_otag(h, TAG_TABLE, 1, &tag); for (hp = sp->head; hp; hp = hp->next) { bufinit(h); col = &h->tbl.cols[hp->ident]; SCALE_HS_INIT(&su, col->width); bufcat_su(h, "width", &su); PAIR_STYLE_INIT(&tag, h); print_otag(h, TAG_COL, 1, &tag); } print_otag(h, TAG_TBODY, 0, NULL); }
/* ARGSUSED */ static int mdoc_xr_pre(MDOC_ARGS) { struct htmlpair tag[2]; if (NULL == n->child) return(0); PAIR_CLASS_INIT(&tag[0], "link-man"); if (h->base_man) { buffmt_man(h, n->child->string, n->child->next ? n->child->next->string : NULL); PAIR_HREF_INIT(&tag[1], h->buf); print_otag(h, TAG_A, 2, tag); } else print_otag(h, TAG_A, 1, tag); n = n->child; print_text(h, n->string); if (NULL == (n = n->next)) return(0); h->flags |= HTML_NOSPACE; print_text(h, "("); h->flags |= HTML_NOSPACE; print_text(h, n->string); h->flags |= HTML_NOSPACE; print_text(h, ")"); return(0); }
/* ARGSUSED */ static int mdoc_fo_pre(MDOC_ARGS) { struct htmlpair tag; struct tag *t; if (MDOC_BODY == n->type) { h->flags |= HTML_NOSPACE; print_text(h, "("); h->flags |= HTML_NOSPACE; return(1); } else if (MDOC_BLOCK == n->type) { synopsis_pre(h, n); return(1); } /* XXX: we drop non-initial arguments as per groff. */ assert(n->child); assert(n->child->string); PAIR_CLASS_INIT(&tag, "fname"); t = print_otag(h, TAG_B, 1, &tag); print_text(h, n->child->string); print_tagq(h, t); return(0); }
static int mdoc_root_pre(MDOC_ARGS) { struct htmlpair tag; struct tag *t, *tt; char *volume, *title; if (NULL == meta->arch) volume = mandoc_strdup(meta->vol); else mandoc_asprintf(&volume, "%s (%s)", meta->vol, meta->arch); if (NULL == meta->msec) title = mandoc_strdup(meta->title); else mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec); PAIR_CLASS_INIT(&tag, "head"); t = print_otag(h, TAG_TABLE, 1, &tag); print_otag(h, TAG_TBODY, 0, NULL); tt = print_otag(h, TAG_TR, 0, NULL); PAIR_CLASS_INIT(&tag, "head-ltitle"); print_otag(h, TAG_TD, 1, &tag); print_text(h, title); print_stagq(h, tt); PAIR_CLASS_INIT(&tag, "head-vol"); print_otag(h, TAG_TD, 1, &tag); print_text(h, volume); print_stagq(h, tt); PAIR_CLASS_INIT(&tag, "head-rtitle"); print_otag(h, TAG_TD, 1, &tag); print_text(h, title); print_tagq(h, t); free(title); free(volume); return(1); }
/* ARGSUSED */ static void man_root_pre(MAN_ARGS) { struct htmlpair tag[3]; struct tag *t, *tt; char b[BUFSIZ], title[BUFSIZ]; b[0] = 0; if (man->vol) (void)strlcat(b, man->vol, BUFSIZ); assert(man->title); assert(man->msec); snprintf(title, BUFSIZ - 1, "%s(%s)", man->title, man->msec); PAIR_SUMMARY_INIT(&tag[0], "Document Header"); PAIR_CLASS_INIT(&tag[1], "head"); PAIR_INIT(&tag[2], ATTR_WIDTH, "100%"); t = print_otag(h, TAG_TABLE, 3, tag); PAIR_INIT(&tag[0], ATTR_WIDTH, "30%"); print_otag(h, TAG_COL, 1, tag); print_otag(h, TAG_COL, 1, tag); print_otag(h, TAG_COL, 1, tag); print_otag(h, TAG_TBODY, 0, NULL); tt = print_otag(h, TAG_TR, 0, NULL); PAIR_CLASS_INIT(&tag[0], "head-ltitle"); print_otag(h, TAG_TD, 1, tag); print_text(h, title); print_stagq(h, tt); PAIR_CLASS_INIT(&tag[0], "head-vol"); PAIR_INIT(&tag[1], ATTR_ALIGN, "center"); print_otag(h, TAG_TD, 2, tag); print_text(h, b); print_stagq(h, tt); PAIR_CLASS_INIT(&tag[0], "head-rtitle"); PAIR_INIT(&tag[1], ATTR_ALIGN, "right"); print_otag(h, TAG_TD, 2, tag); print_text(h, title); print_tagq(h, t); }
/* ARGSUSED */ static int mdoc_ar_pre(MDOC_ARGS) { struct htmlpair tag; PAIR_CLASS_INIT(&tag, "arg"); print_otag(h, TAG_I, 1, &tag); return(1); }
static int mdoc_li_pre(MDOC_ARGS) { struct htmlpair tag; PAIR_CLASS_INIT(&tag, "lit"); print_otag(h, TAG_CODE, 1, &tag); return(1); }
/* ARGSUSED */ static int mdoc_sy_pre(MDOC_ARGS) { struct htmlpair tag; PAIR_CLASS_INIT(&tag, "symb"); print_otag(h, TAG_SPAN, 1, &tag); return(1); }
void print_paragraph(struct html *h) { struct tag *t; struct htmlpair tag; PAIR_CLASS_INIT(&tag, "spacer"); t = print_otag(h, TAG_DIV, 1, &tag); print_tagq(h, t); }
/* ARGSUSED */ static int mdoc_cd_pre(MDOC_ARGS) { struct htmlpair tag; synopsis_pre(h, n); PAIR_CLASS_INIT(&tag, "config"); print_otag(h, TAG_B, 1, &tag); return(1); }
/* ARGSUSED */ static int mdoc_ft_pre(MDOC_ARGS) { struct htmlpair tag; synopsis_pre(h, n); PAIR_CLASS_INIT(&tag, "ftype"); print_otag(h, TAG_I, 1, &tag); return(1); }