=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.229 retrieving revision 1.236 diff -u -p -r1.229 -r1.236 --- mandoc/mdoc_html.c 2015/04/02 23:48:20 1.229 +++ mandoc/mdoc_html.c 2015/09/26 00:54:04 1.236 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.229 2015/04/02 23:48:20 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.236 2015/09/26 00:54:04 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2014, 2015 Ingo Schwarze @@ -48,7 +48,6 @@ struct htmlmdoc { void (*post)(MDOC_ARGS); }; -static void print_mdoc(MDOC_ARGS); static void print_mdoc_head(MDOC_ARGS); static void print_mdoc_node(MDOC_ARGS); static void print_mdoc_nodelist(MDOC_ARGS); @@ -264,15 +263,6 @@ static const char * const lists[LIST_MAX] = { }; -void -html_mdoc(void *arg, const struct mdoc *mdoc) -{ - - print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc)->child, - (struct html *)arg); - putchar('\n'); -} - /* * Calculate the scaling unit passed in a `-width' argument. This uses * either a native scaling unit (e.g., 1i, 2m) or the string length of @@ -331,27 +321,32 @@ synopsis_pre(struct html *h, const struct roff_node *n } } -static void -print_mdoc(MDOC_ARGS) +void +html_mdoc(void *arg, const struct roff_man *mdoc) { - struct tag *t, *tt; struct htmlpair tag; + struct html *h; + struct tag *t, *tt; PAIR_CLASS_INIT(&tag, "mandoc"); + h = (struct html *)arg; if ( ! (HTML_FRAGMENT & h->oflags)) { print_gen_decls(h); t = print_otag(h, TAG_HTML, 0, NULL); tt = print_otag(h, TAG_HEAD, 0, NULL); - print_mdoc_head(meta, n, h); + print_mdoc_head(&mdoc->meta, mdoc->first->child, h); print_tagq(h, tt); print_otag(h, TAG_BODY, 0, NULL); print_otag(h, TAG_DIV, 1, &tag); } else t = print_otag(h, TAG_DIV, 1, &tag); - print_mdoc_nodelist(meta, n, h); + mdoc_root_pre(&mdoc->meta, mdoc->first->child, h); + print_mdoc_nodelist(&mdoc->meta, mdoc->first->child, h); + mdoc_root_post(&mdoc->meta, mdoc->first->child, h); print_tagq(h, t); + putchar('\n'); } static void @@ -391,9 +386,6 @@ print_mdoc_node(MDOC_ARGS) n->flags &= ~MDOC_ENDED; switch (n->type) { - case ROFFT_ROOT: - child = mdoc_root_pre(meta, n, h); - break; case ROFFT_TEXT: /* No tables in this mode... */ assert(NULL == h->tblt); @@ -451,9 +443,6 @@ print_mdoc_node(MDOC_ARGS) print_stagq(h, t); switch (n->type) { - case ROFFT_ROOT: - mdoc_root_post(meta, n, h); - break; case ROFFT_EQN: break; default: @@ -652,18 +641,15 @@ mdoc_nm_pre(MDOC_ARGS) int len; switch (n->type) { + case ROFFT_HEAD: + print_otag(h, TAG_TD, 0, NULL); + /* FALLTHROUGH */ case ROFFT_ELEM: - synopsis_pre(h, n); PAIR_CLASS_INIT(&tag, "name"); print_otag(h, TAG_B, 1, &tag); - if (NULL == n->child && meta->name) + if (n->child == NULL && meta->name != NULL) print_text(h, meta->name); return(1); - case ROFFT_HEAD: - print_otag(h, TAG_TD, 0, NULL); - if (NULL == n->child && meta->name) - print_text(h, meta->name); - return(1); case ROFFT_BODY: print_otag(h, TAG_TD, 0, NULL); return(1); @@ -675,11 +661,11 @@ mdoc_nm_pre(MDOC_ARGS) PAIR_CLASS_INIT(&tag, "synopsis"); print_otag(h, TAG_TABLE, 1, &tag); - for (len = 0, n = n->child; n; n = n->next) + for (len = 0, n = n->head->child; n; n = n->next) if (n->type == ROFFT_TEXT) len += html_strlen(n->string); - if (0 == len && meta->name) + if (len == 0 && meta->name != NULL) len = html_strlen(meta->name); SCALE_HS_INIT(&su, len); @@ -1014,7 +1000,6 @@ mdoc_bl_pre(MDOC_ARGS) break; default: abort(); - /* NOTREACHED */ } return(1); @@ -1653,11 +1638,10 @@ mdoc_fo_pre(MDOC_ARGS) return(1); } - /* XXX: we drop non-initial arguments as per groff. */ + if (n->child == NULL) + return(0); - 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); @@ -2012,7 +1996,6 @@ mdoc__x_pre(MDOC_ARGS) break; default: abort(); - /* NOTREACHED */ } if (MDOC__U != n->tok) { @@ -2059,7 +2042,6 @@ mdoc_bk_pre(MDOC_ARGS) break; default: abort(); - /* NOTREACHED */ } return(1); @@ -2139,7 +2121,6 @@ mdoc_quote_pre(MDOC_ARGS) break; default: abort(); - /* NOTREACHED */ } h->flags |= HTML_NOSPACE; @@ -2207,7 +2188,6 @@ mdoc_quote_post(MDOC_ARGS) break; default: abort(); - /* NOTREACHED */ } }