=================================================================== RCS file: /cvs/docbook2mdoc/docbook2mdoc.c,v retrieving revision 1.52 retrieving revision 1.55 diff -u -p -r1.52 -r1.55 --- docbook2mdoc/docbook2mdoc.c 2019/03/22 16:21:23 1.52 +++ docbook2mdoc/docbook2mdoc.c 2019/03/22 16:35:41 1.55 @@ -1,4 +1,4 @@ -/* $Id: docbook2mdoc.c,v 1.52 2019/03/22 16:21:23 schwarze Exp $ */ +/* $Id: docbook2mdoc.c,v 1.55 2019/03/22 16:35:41 schwarze Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * Copyright (c) 2019 Ingo Schwarze @@ -690,6 +690,37 @@ pnode_printmclosepunct(struct parse *p, struct pnode * p->newln = 1; } +static void +pnode_printpara(struct parse *p, struct pnode *pn) +{ + struct pnode *pp; + + assert(p->newln); + if (NULL == pn->parent || NODE_LISTITEM == pn->parent->node) + return; + + pp = TAILQ_PREV(pn, pnodeq, child); + if (NULL == pp) + pp = pn->parent; + switch (pp->node) { + case (NODE_CHAPTER): + case (NODE_PREFACE): + case (NODE_REFSECT1): + case (NODE_REFSECT2): + case (NODE_REFSECT3): + case (NODE_REFSECTION): + case (NODE_SECT1): + case (NODE_SECT2): + case (NODE_SECTION): + if (2 > p->level) + return; + break; + default: + break; + } + puts(".Pp"); +} + /* * If the SYNOPSIS macro has a superfluous title, kill it. */ @@ -765,7 +796,7 @@ pnode_printrefsect(struct parse *p, struct pnode *pn) fputs(".Ss", stdout); break; default: - puts(".Pp"); + pnode_printpara(p, pn); fputs(".Sy", stdout); break; } @@ -1161,7 +1192,7 @@ pnode_printtable(struct parse *p, struct pnode *pn) assert(p->newln); TAILQ_FOREACH(pp, &pn->childq, child) if (NODE_TITLE == pp->node) { - puts(".Pp"); + pnode_printpara(p, pp); pnode_print(p, pp); pnode_unlink(pp); } @@ -1185,7 +1216,7 @@ pnode_printlist(struct parse *p, struct pnode *pn) assert(p->newln); TAILQ_FOREACH(pp, &pn->childq, child) if (NODE_TITLE == pp->node) { - puts(".Pp"); + pnode_printpara(p, pp); pnode_print(p, pp); pnode_unlink(pp); } @@ -1194,7 +1225,7 @@ pnode_printlist(struct parse *p, struct pnode *pn) if (NODE_ORDEREDLIST == pn->node) puts(".Bl -enum"); else - puts(".Bl -item"); + puts(".Bl -bullet"); TAILQ_FOREACH(pp, &pn->childq, child) { assert(p->newln); @@ -1214,7 +1245,7 @@ pnode_printvariablelist(struct parse *p, struct pnode assert(p->newln); TAILQ_FOREACH(pp, &pn->childq, child) if (NODE_TITLE == pp->node) { - puts(".Pp"); + pnode_printpara(p, pp); pnode_print(p, pp); pnode_unlink(pp); } @@ -1325,6 +1356,8 @@ pnode_print(struct parse *p, struct pnode *pn) pnode_printmopen(p); fputs("Fd", stdout); break; + case (NODE_INDEXTERM): + return; case (NODE_INFORMALEQUATION): if ( ! p->newln) putchar('\n'); @@ -1380,11 +1413,7 @@ pnode_print(struct parse *p, struct pnode *pn) pnode_unlinksub(pn); break; case (NODE_PARA): - assert(p->newln); - if (NULL != pn->parent && - NODE_LISTITEM == pn->parent->node) - break; - puts(".Pp"); + pnode_printpara(p, pn); break; case (NODE_PARAMETER): /* Suppress non-text children... */