static void print_mdoc_node(MDOC_ARGS) { int child; struct tag *t; if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT) return; child = 1; t = h->tag; n->flags &= ~NODE_ENDED; switch (n->type) { case ROFFT_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 == ' ' && n->flags & NODE_LINE && (h->flags & (HTML_LITERAL | HTML_NONEWLINE)) == 0) print_otag(h, TAG_BR, ""); if (NODE_DELIMC & n->flags) h->flags |= HTML_NOSPACE; print_text(h, n->string); if (NODE_DELIMO & n->flags) h->flags |= HTML_NOSPACE; return; case ROFFT_EQN: print_eqn(h, n->eqn); break; case ROFFT_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->tag; } assert(h->tblt == NULL); if (n->tok < ROFF_MAX) { roff_html_pre(h, n); child = 0; break; } assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); if (mdocs[n->tok].pre != NULL && (n->end == ENDBODY_NOT || n->child != NULL)) child = (*mdocs[n->tok].pre)(meta, n, h); break; } if (h->flags & HTML_KEEP && n->flags & NODE_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 ROFFT_EQN: break; default: if (n->tok < ROFF_MAX || mdocs[n->tok].post == NULL || n->flags & NODE_ENDED) break; (*mdocs[n->tok].post)(meta, n, h); if (n->end != ENDBODY_NOT) n->body->flags |= NODE_ENDED; break; } }
static void print_man_node(MAN_ARGS) { int child; struct tag *t; child = 1; t = h->tags.head; switch (n->type) { case MAN_ROOT: man_root_pre(man, n, mh, h); break; case MAN_TEXT: if ('\0' == *n->string) { print_paragraph(h); return; } if (n->flags & MAN_LINE && (*n->string == ' ' || (n->prev != NULL && mh->fl & MANH_LITERAL && ! (h->flags & HTML_NONEWLINE)))) print_otag(h, TAG_BR, 0, NULL); print_text(h, n->string); return; case MAN_EQN: print_eqn(h, n->eqn); break; case MAN_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 scope of font prior to opening a macro * scope. */ if (HTMLFONT_NONE != h->metac) { h->metal = h->metac; h->metac = HTMLFONT_NONE; } /* * 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; } if (mans[n->tok].pre) child = (*mans[n->tok].pre)(man, n, mh, h); break; } if (child && n->child) print_man_nodelist(man, n->child, mh, h); /* This will automatically close out any font scope. */ print_stagq(h, t); switch (n->type) { case MAN_ROOT: man_root_post(man, n, mh, h); break; case MAN_EQN: break; default: if (mans[n->tok].post) (*mans[n->tok].post)(man, n, mh, h); break; } }
static void print_man_node(MAN_ARGS) { int child; struct tag *t; child = 1; t = h->tags.head; switch (n->type) { case (MAN_ROOT): man_root_pre(man, n, mh, h); break; case (MAN_TEXT): /* * If we have a blank line, output a vertical space. * If we have a space as the first character, break * before printing the line's data. */ if ('\0' == *n->string) { print_otag(h, TAG_P, 0, NULL); return; } if (' ' == *n->string && MAN_LINE & n->flags) print_otag(h, TAG_BR, 0, NULL); else if (MANH_LITERAL & mh->fl && n->prev) print_otag(h, TAG_BR, 0, NULL); print_text(h, n->string); return; case (MAN_EQN): print_eqn(h, n->eqn); break; case (MAN_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 scope of font prior to opening a macro * scope. */ if (HTMLFONT_NONE != h->metac) { h->metal = h->metac; h->metac = HTMLFONT_NONE; } /* * 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; } if (mans[n->tok].pre) child = (*mans[n->tok].pre)(man, n, mh, h); break; } if (child && n->child) print_man_nodelist(man, n->child, mh, h); /* This will automatically close out any font scope. */ print_stagq(h, t); switch (n->type) { case (MAN_ROOT): man_root_post(man, n, mh, h); break; case (MAN_EQN): break; default: if (mans[n->tok].post) (*mans[n->tok].post)(man, n, mh, 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; } }
static void print_man_node(MAN_ARGS) { static int want_fillmode = MAN_fi; static int save_fillmode; struct tag *t; int child; /* * Handle fill mode switch requests up front, * they would just cause trouble in the subsequent code. */ switch (n->tok) { case MAN_nf: case MAN_EX: want_fillmode = MAN_nf; return; case MAN_fi: case MAN_EE: want_fillmode = MAN_fi; if (fillmode(h, 0) == MAN_fi) print_otag(h, TAG_BR, ""); return; default: break; } /* Set up fill mode for the upcoming node. */ switch (n->type) { case ROFFT_BLOCK: save_fillmode = 0; /* Some block macros suspend or cancel .nf. */ switch (n->tok) { case MAN_TP: /* Tagged paragraphs */ case MAN_IP: /* temporarily disable .nf */ case MAN_HP: /* for the head. */ save_fillmode = want_fillmode; /* FALLTHROUGH */ case MAN_SH: /* Section headers */ case MAN_SS: /* permanently cancel .nf. */ want_fillmode = MAN_fi; /* FALLTHROUGH */ case MAN_PP: /* These have no head. */ case MAN_LP: /* They will simply */ case MAN_P: /* reopen .nf in the body. */ case MAN_RS: case MAN_UR: fillmode(h, MAN_fi); break; default: break; } break; case ROFFT_TBL: fillmode(h, MAN_fi); break; case ROFFT_ELEM: /* * Some in-line macros produce tags and/or text * in the handler, so they require fill mode to be * configured up front just like for text nodes. * For the others, keep the traditional approach * of doing the same, for now. */ fillmode(h, want_fillmode); break; case ROFFT_TEXT: if (fillmode(h, want_fillmode) == MAN_fi && want_fillmode == MAN_fi && n->flags & NODE_LINE && *n->string == ' ' && (h->flags & HTML_NONEWLINE) == 0) print_otag(h, TAG_BR, ""); if (*n->string != '\0') break; print_paragraph(h); return; default: break; } /* Produce output for this node. */ child = 1; switch (n->type) { case ROFFT_TEXT: t = h->tag; print_text(h, n->string); break; case ROFFT_EQN: t = h->tag; print_eqn(h, n->eqn); break; case ROFFT_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 scope of font prior to opening a macro * scope. */ if (HTMLFONT_NONE != h->metac) { h->metal = h->metac; h->metac = HTMLFONT_NONE; } /* * 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->tag; if (n->tok < ROFF_MAX) { roff_html_pre(h, n); child = 0; break; } assert(n->tok >= MAN_TH && n->tok < MAN_MAX); if (mans[n->tok].pre) child = (*mans[n->tok].pre)(man, n, h); /* Some block macros resume .nf in the body. */ if (save_fillmode && n->type == ROFFT_BODY) want_fillmode = save_fillmode; break; } if (child && n->child) print_man_nodelist(man, n->child, h); /* This will automatically close out any font scope. */ print_stagq(h, t); if (fillmode(h, 0) == MAN_nf && n->next != NULL && n->next->flags & NODE_LINE) print_endline(h); }