static int mdoc__x_pre(MDOC_ARGS) { struct htmlpair tag[2]; enum htmltag t; t = TAG_SPAN; switch (n->tok) { case MDOC__A: PAIR_CLASS_INIT(&tag[0], "ref-auth"); if (n->prev && MDOC__A == n->prev->tok) if (NULL == n->next || MDOC__A != n->next->tok) print_text(h, "and"); break; case MDOC__B: PAIR_CLASS_INIT(&tag[0], "ref-book"); t = TAG_I; break; case MDOC__C: PAIR_CLASS_INIT(&tag[0], "ref-city"); break; case MDOC__D: PAIR_CLASS_INIT(&tag[0], "ref-date"); break; case MDOC__I: PAIR_CLASS_INIT(&tag[0], "ref-issue"); t = TAG_I; break; case MDOC__J: PAIR_CLASS_INIT(&tag[0], "ref-jrnl"); t = TAG_I; break; case MDOC__N: PAIR_CLASS_INIT(&tag[0], "ref-num"); break; case MDOC__O: PAIR_CLASS_INIT(&tag[0], "ref-opt"); break; case MDOC__P: PAIR_CLASS_INIT(&tag[0], "ref-page"); break; case MDOC__Q: PAIR_CLASS_INIT(&tag[0], "ref-corp"); break; case MDOC__R: PAIR_CLASS_INIT(&tag[0], "ref-rep"); break; case MDOC__T: PAIR_CLASS_INIT(&tag[0], "ref-title"); break; case MDOC__U: PAIR_CLASS_INIT(&tag[0], "link-ref"); break; case MDOC__V: PAIR_CLASS_INIT(&tag[0], "ref-vol"); break; default: abort(); /* NOTREACHED */ } if (MDOC__U != n->tok) { print_otag(h, t, 1, tag); return(1); } PAIR_HREF_INIT(&tag[1], n->child->string); print_otag(h, TAG_A, 2, tag); return(1); }
/* ARGSUSED */ static int mdoc_fn_pre(MDOC_ARGS) { struct tag *t; struct htmlpair tag[2]; char nbuf[BUFSIZ]; const char *sp, *ep; int sz, i, pretty; pretty = MDOC_SYNPRETTY & n->flags; synopsis_pre(h, n); /* Split apart into type and name. */ assert(n->child->string); sp = n->child->string; ep = strchr(sp, ' '); if (NULL != ep) { PAIR_CLASS_INIT(&tag[0], "ftype"); t = print_otag(h, TAG_I, 1, tag); while (ep) { sz = MIN((int)(ep - sp), BUFSIZ - 1); (void)memcpy(nbuf, sp, (size_t)sz); nbuf[sz] = '\0'; print_text(h, nbuf); sp = ++ep; ep = strchr(sp, ' '); } print_tagq(h, t); } PAIR_CLASS_INIT(&tag[0], "fname"); /* * FIXME: only refer to IDs that we know exist. */ #if 0 if (MDOC_SYNPRETTY & n->flags) { nbuf[0] = '\0'; html_idcat(nbuf, sp, BUFSIZ); PAIR_ID_INIT(&tag[1], nbuf); } else { strlcpy(nbuf, "#", BUFSIZ); html_idcat(nbuf, sp, BUFSIZ); PAIR_HREF_INIT(&tag[1], nbuf); } #endif t = print_otag(h, TAG_B, 1, tag); if (sp) { strlcpy(nbuf, sp, BUFSIZ); print_text(h, nbuf); } print_tagq(h, t); h->flags |= HTML_NOSPACE; print_text(h, "("); bufinit(h); PAIR_CLASS_INIT(&tag[0], "farg"); bufcat_style(h, "white-space", "nowrap"); PAIR_STYLE_INIT(&tag[1], h); for (n = n->child->next; n; n = n->next) { i = 1; if (MDOC_SYNPRETTY & n->flags) i = 2; t = print_otag(h, TAG_I, i, tag); print_text(h, n->string); print_tagq(h, t); if (n->next) { h->flags |= HTML_NOSPACE; print_text(h, ","); } } h->flags |= HTML_NOSPACE; print_text(h, ")"); if (pretty) { h->flags |= HTML_NOSPACE; print_text(h, ";"); } return(0); }
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); /* * XXX This is broken and not easy to fix. * When using -Oincludes, truncation may occur. * Dynamic allocation wouldn't help because * passing long strings to buffmt_includes() * does not work either. */ 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"); 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); }