void html_mdoc(void *arg, const struct roff_man *mdoc) { struct html *h; struct roff_node *n; struct tag *t; h = (struct html *)arg; n = mdoc->first->child; if ((h->oflags & HTML_FRAGMENT) == 0) { print_gen_decls(h); print_otag(h, TAG_HTML, ""); if (n->type == ROFFT_COMMENT) print_gen_comment(h, n); t = print_otag(h, TAG_HEAD, ""); print_mdoc_head(&mdoc->meta, h); print_tagq(h, t); print_otag(h, TAG_BODY, ""); } mdoc_root_pre(&mdoc->meta, h); t = print_otag(h, TAG_DIV, "c", "manual-text"); print_mdoc_nodelist(&mdoc->meta, n, h); print_tagq(h, t); mdoc_root_post(&mdoc->meta, h); print_tagq(h, NULL); }
static void print_mdoc_node(MDOC_ARGS) { int child; struct tag *t; struct htmlpair tag; child = 1; t = h->tags.head; bufinit(h); switch (n->type) { case (MDOC_ROOT): child = mdoc_root_pre(m, n, h); break; case (MDOC_TEXT): /* No tables in this mode... */ assert(NULL == h->tblt); /* * Make sure that if we're in a literal mode already * (i.e., within a <PRE>) don't print the newline. */ if (' ' == *n->string && MDOC_LINE & n->flags) if ( ! (HTML_LITERAL & h->flags)) print_otag(h, TAG_BR, 0, NULL); if (MDOC_DELIMC & n->flags) h->flags |= HTML_NOSPACE; print_text(h, n->string); if (MDOC_DELIMO & n->flags) h->flags |= HTML_NOSPACE; return; case (MDOC_EQN): PAIR_CLASS_INIT(&tag, "eqn"); print_otag(h, TAG_SPAN, 1, &tag); print_text(h, n->eqn->data); break; case (MDOC_TBL): /* * This will take care of initialising all of the table * state data for the first table, then tearing it down * for the last one. */ print_tbl(h, n->span); return; default: /* * Close out the current table, if it's open, and unset * the "meta" table state. This will be reopened on the * next table element. */ if (h->tblt) { print_tblclose(h); t = h->tags.head; } assert(NULL == h->tblt); if (mdocs[n->tok].pre && ENDBODY_NOT == n->end) child = (*mdocs[n->tok].pre)(m, n, h); break; } if (HTML_KEEP & h->flags) { if (n->prev && n->prev->line != n->line) { h->flags &= ~HTML_KEEP; h->flags |= HTML_PREKEEP; } else if (NULL == n->prev) { if (n->parent && n->parent->line != n->line) { h->flags &= ~HTML_KEEP; h->flags |= HTML_PREKEEP; } } } if (child && n->child) print_mdoc_nodelist(m, n->child, h); print_stagq(h, t); bufinit(h); switch (n->type) { case (MDOC_ROOT): mdoc_root_post(m, n, h); break; case (MDOC_EQN): break; default: if (mdocs[n->tok].post && ENDBODY_NOT == n->end) (*mdocs[n->tok].post)(m, n, h); break; } }
static void print_mdoc_node(MDOC_ARGS) { int child; struct tag *t; child = 1; t = h->tags.head; n->flags &= ~MDOC_ENDED; switch (n->type) { case MDOC_ROOT: child = mdoc_root_pre(meta, n, h); break; case MDOC_TEXT: /* No tables in this mode... */ assert(NULL == h->tblt); /* * Make sure that if we're in a literal mode already * (i.e., within a <PRE>) don't print the newline. */ if (' ' == *n->string && MDOC_LINE & n->flags) if ( ! (HTML_LITERAL & h->flags)) print_otag(h, TAG_BR, 0, NULL); if (MDOC_DELIMC & n->flags) h->flags |= HTML_NOSPACE; print_text(h, n->string); if (MDOC_DELIMO & n->flags) h->flags |= HTML_NOSPACE; return; case MDOC_EQN: if (n->flags & MDOC_LINE) putchar('\n'); print_eqn(h, n->eqn); break; case MDOC_TBL: /* * This will take care of initialising all of the table * state data for the first table, then tearing it down * for the last one. */ print_tbl(h, n->span); return; default: /* * Close out the current table, if it's open, and unset * the "meta" table state. This will be reopened on the * next table element. */ if (h->tblt != NULL) { print_tblclose(h); t = h->tags.head; } assert(h->tblt == NULL); if (mdocs[n->tok].pre && (n->end == ENDBODY_NOT || n->child)) child = (*mdocs[n->tok].pre)(meta, n, h); break; } if (h->flags & HTML_KEEP && n->flags & MDOC_LINE) { h->flags &= ~HTML_KEEP; h->flags |= HTML_PREKEEP; } if (child && n->child) print_mdoc_nodelist(meta, n->child, h); print_stagq(h, t); switch (n->type) { case MDOC_ROOT: mdoc_root_post(meta, n, h); break; case MDOC_EQN: break; default: if ( ! mdocs[n->tok].post || n->flags & MDOC_ENDED) break; (*mdocs[n->tok].post)(meta, n, h); if (n->end != ENDBODY_NOT) n->body->flags |= MDOC_ENDED; if (n->end == ENDBODY_NOSPACE) h->flags |= HTML_NOSPACE; break; } }