=================================================================== RCS file: /cvs/mandoc/man_html.c,v retrieving revision 1.166 retrieving revision 1.171 diff -u -p -r1.166 -r1.171 --- mandoc/man_html.c 2019/01/06 04:55:09 1.166 +++ mandoc/man_html.c 2019/02/28 16:36:13 1.171 @@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.166 2019/01/06 04:55:09 schwarze Exp $ */ +/* $Id: man_html.c,v 1.171 2019/02/28 16:36:13 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2013-2015, 2017-2019 Ingo Schwarze @@ -119,7 +119,7 @@ html_man(void *arg, const struct roff_meta *man) if ((h->oflags & HTML_FRAGMENT) == 0) { print_gen_decls(h); print_otag(h, TAG_HTML, ""); - if (n->type == ROFFT_COMMENT) + if (n != NULL && n->type == ROFFT_COMMENT) print_gen_comment(h, n); t = print_otag(h, TAG_HEAD, ""); print_man_head(man, h); @@ -162,6 +162,9 @@ print_man_node(MAN_ARGS) struct tag *t; int child; + if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT) + return; + html_fillmode(h, n->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi); child = 1; @@ -171,18 +174,18 @@ print_man_node(MAN_ARGS) print_endline(h); return; } - t = h->tag; if (*n->string == ' ' && n->flags & NODE_LINE && (h->flags & HTML_NONEWLINE) == 0) print_endline(h); else if (n->flags & NODE_DELIMC) h->flags |= HTML_NOSPACE; + t = h->tag; + t->refcnt++; print_text(h, n->string); break; - case ROFFT_COMMENT: - return; case ROFFT_EQN: t = h->tag; + t->refcnt++; print_eqn(h, n->eqn); break; case ROFFT_TBL: @@ -210,15 +213,14 @@ print_man_node(MAN_ARGS) */ if (h->tblt != NULL) print_tblclose(h); - t = h->tag; + t->refcnt++; if (n->tok < ROFF_MAX) { roff_html_pre(h, n); - if (n->tok != ROFF_sp) - print_stagq(h, t); + t->refcnt--; + print_stagq(h, t); return; } - assert(n->tok >= MAN_TH && n->tok < MAN_MAX); if (man_html_acts[n->tok - MAN_TH].pre != NULL) child = (*man_html_acts[n->tok - MAN_TH].pre)(man, @@ -230,7 +232,26 @@ print_man_node(MAN_ARGS) print_man_nodelist(man, n->child, h); /* This will automatically close out any font scope. */ - print_stagq(h, t); + t->refcnt--; + if (n->type == ROFFT_BLOCK && + (n->tok == MAN_IP || n->tok == MAN_TP || n->tok == MAN_TQ)) { + t = h->tag; + while (t->tag != TAG_DL) + t = t->next; + /* + * Close the list if no further item of the same type + * follows; otherwise, close the item only. + */ + if (n->next == NULL || + (n->tok == MAN_IP && n->next->tok != MAN_IP) || + (n->tok != MAN_IP && + n->next->tok != MAN_TP && n->next->tok != MAN_TQ)) { + print_tagq(h, t); + t = NULL; + } + } + if (t != NULL) + print_stagq(h, t); if (n->flags & NODE_NOFILL && n->tok != MAN_YS && (n->next != NULL && n->next->flags & NODE_LINE)) { @@ -298,9 +319,9 @@ man_SH_pre(MAN_ARGS) case ROFFT_HEAD: id = html_make_id(n, 1); if (n->tok == MAN_SH) - print_otag(h, TAG_H1, "cTi", "Sh", id); + print_otag(h, TAG_H1, "ci", "Sh", id); else - print_otag(h, TAG_H2, "cTi", "Ss", id); + print_otag(h, TAG_H2, "ci", "Ss", id); if (id != NULL) print_otag(h, TAG_A, "chR", "permalink", id); break; @@ -396,7 +417,15 @@ man_IP_pre(MAN_ARGS) switch (n->type) { case ROFFT_BLOCK: html_close_paragraph(h); - print_otag(h, TAG_DL, "c", "Bl-tag"); + /* + * Open a new list unless there is an immediately + * preceding item of the same type. + */ + if (n->prev == NULL || + (n->tok == MAN_IP && n->prev->tok != MAN_IP) || + (n->tok != MAN_IP && + n->prev->tok != MAN_TP && n->prev->tok != MAN_TQ)) + print_otag(h, TAG_DL, "c", "Bl-tag"); return 1; case ROFFT_HEAD: print_otag(h, TAG_DT, ""); @@ -512,7 +541,7 @@ man_SY_pre(MAN_ARGS) break; case ROFFT_HEAD: print_otag(h, TAG_TD, ""); - print_otag(h, TAG_CODE, "cT", "Nm"); + print_otag(h, TAG_CODE, "c", "Nm"); break; case ROFFT_BODY: print_otag(h, TAG_TD, ""); @@ -534,10 +563,10 @@ man_UR_pre(MAN_ARGS) assert(n->child->type == ROFFT_TEXT); if (n->tok == MAN_MT) { mandoc_asprintf(&cp, "mailto:%s", n->child->string); - print_otag(h, TAG_A, "cTh", "Mt", cp); + print_otag(h, TAG_A, "ch", "Mt", cp); free(cp); } else - print_otag(h, TAG_A, "cTh", "Lk", n->child->string); + print_otag(h, TAG_A, "ch", "Lk", n->child->string); } assert(n->next->type == ROFFT_BODY);