From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: docbook2mdoc: new function pnode_printpara() to avoid printing redundant
Date: Fri, 22 Mar 2019 11:33:04 -0500 (EST) [thread overview]
Message-ID: <e3fc9149d40d51c9@fantadrom.bsd.lv> (raw)
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
reply other threads:[~2019-03-22 16:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e3fc9149d40d51c9@fantadrom.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).