=================================================================== RCS file: /cvs/mandoc/man_html.c,v retrieving revision 1.169 retrieving revision 1.172 diff -u -p -r1.169 -r1.172 --- mandoc/man_html.c 2019/01/11 16:36:19 1.169 +++ mandoc/man_html.c 2019/03/01 10:57:18 1.172 @@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.169 2019/01/11 16:36:19 schwarze Exp $ */ +/* $Id: man_html.c,v 1.172 2019/03/01 10:57:18 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2013-2015, 2017-2019 Ingo Schwarze @@ -168,10 +168,6 @@ print_man_node(MAN_ARGS) html_fillmode(h, n->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi); child = 1; - t = h->tag; - if (t->tag == TAG_P || t->tag == TAG_PRE) - t = t->next; - switch (n->type) { case ROFFT_TEXT: if (*n->string == '\0') { @@ -183,9 +179,13 @@ print_man_node(MAN_ARGS) 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_EQN: + t = h->tag; + t->refcnt++; print_eqn(h, n->eqn); break; case ROFFT_TBL: @@ -211,12 +211,13 @@ print_man_node(MAN_ARGS) * the "meta" table state. This will be reopened on the * next table element. */ - if (h->tblt != NULL) { + if (h->tblt != NULL) print_tblclose(h); - t = h->tag; - } + t = h->tag; + t->refcnt++; if (n->tok < ROFF_MAX) { roff_html_pre(h, n); + t->refcnt--; print_stagq(h, t); return; } @@ -231,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)) { @@ -290,18 +310,25 @@ man_root_post(const struct roff_meta *man, struct html static int man_SH_pre(MAN_ARGS) { - char *id; + const char *class; + char *id; + enum htmltag tag; + if (n->tok == MAN_SH) { + tag = TAG_H1; + class = "Sh"; + } else { + tag = TAG_H2; + class = "Ss"; + } switch (n->type) { case ROFFT_BLOCK: html_close_paragraph(h); + print_otag(h, TAG_SECTION, "c", class); break; case ROFFT_HEAD: id = html_make_id(n, 1); - if (n->tok == MAN_SH) - print_otag(h, TAG_H1, "ci", "Sh", id); - else - print_otag(h, TAG_H2, "ci", "Ss", id); + print_otag(h, tag, "ci", class, id); if (id != NULL) print_otag(h, TAG_A, "chR", "permalink", id); break; @@ -397,7 +424,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, "");