* docbook2mdoc: new function pnode_printpara() to avoid printing redundant
@ 2019-03-22 16:33 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-03-22 16:33 UTC (permalink / raw)
To: source
Log Message:
-----------
new function pnode_printpara()
to avoid printing redundant .Pp, for example after section headers
Modified Files:
--------------
docbook2mdoc:
docbook2mdoc.c
Revision Data
-------------
Index: docbook2mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.53 -r1.54
--- docbook2mdoc.c
+++ docbook2mdoc.c
@@ -690,6 +690,37 @@ pnode_printmclosepunct(struct parse *p,
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, stru
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
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
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);
}
@@ -1214,7 +1245,7 @@ pnode_printvariablelist(struct parse *p,
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);
}
@@ -1380,11 +1411,7 @@ pnode_print(struct parse *p, struct pnod
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... */
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-03-22 16:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22 16:33 docbook2mdoc: new function pnode_printpara() to avoid printing redundant schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).