* docbook2mdoc: Improve formatting of <arg> and <group>: * Respect the
@ 2019-04-13 15:14 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-04-13 15:14 UTC (permalink / raw)
To: source
Log Message:
-----------
Improve formatting of <arg> and <group>:
* Respect the repeat attribute even if there is a child macro.
* Mark up all children of <group>, not just the first.
* Implement the repeat attribute for <group>.
* Do the proper was_impl dance for <group>.
Modified Files:
--------------
docbook2mdoc:
docbook2mdoc.c
Revision Data
-------------
Index: docbook2mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.116 -r1.117
--- docbook2mdoc.c
+++ docbook2mdoc.c
@@ -442,14 +442,13 @@ pnode_printarg(struct format *f, struct
f->flags |= FMT_IMPL;
}
}
-
TAILQ_FOREACH(nc, &n->childq, child) {
if (nc->node == NODE_TEXT)
macro_open(f, "Ar");
pnode_print(f, nc);
- if (isrep && nc->node == NODE_TEXT)
- macro_addarg(f, "...", ARG_SPACE);
}
+ if (isrep && f->linestate == LINE_MACRO)
+ macro_addarg(f, "...", ARG_SPACE);
if (isop) {
if (was_impl)
macro_open(f, "Oc");
@@ -462,53 +461,56 @@ pnode_printarg(struct format *f, struct
static void
pnode_printgroup(struct format *f, struct pnode *n)
{
- struct pnode *nc, *nn;
+ struct pnode *nc;
struct pattr *a;
- int isop, sv;
+ int bar, isop, isrep, was_impl;
isop = 1;
- TAILQ_FOREACH(a, &n->attrq, child)
+ isrep = was_impl = 0;
+ TAILQ_FOREACH(a, &n->attrq, child) {
if (a->key == ATTRKEY_CHOICE &&
- (a->val == ATTRVAL_PLAIN || a->val == ATTRVAL_REQ)) {
+ (a->val == ATTRVAL_PLAIN || a->val == ATTRVAL_REQ))
isop = 0;
- break;
+ else if (a->key == ATTRKEY_REP && a->val == ATTRVAL_REPEAT)
+ isrep = 1;
+ }
+ if (isop) {
+ if (f->flags & FMT_IMPL) {
+ was_impl = 1;
+ macro_open(f, "Oo");
+ } else {
+ macro_open(f, "Op");
+ f->flags |= FMT_IMPL;
}
-
- /*
- * Make sure we're on a macro line.
- * This will prevent pnode_print() for putting us on a
- * subsequent line.
- */
- sv = f->linestate == LINE_NEW;
- if (isop)
- macro_open(f, "Op");
- else if (sv)
- macro_open(f, "No");
- f->flags |= FMT_IMPL;
-
- /*
- * Keep on printing text separated by the vertical bar as long
- * as we're within the same origin node as the group.
- * This is kind of a nightmare.
- * Eh, DocBook...
- * FIXME: if there's a "Fl", we don't cut off the leading "-"
- * like we do in pnode_print().
- */
+ } else if (isrep) {
+ if (f->flags & FMT_IMPL) {
+ was_impl = 1;
+ macro_open(f, "Bro");
+ } else {
+ macro_open(f, "Brq");
+ f->flags |= FMT_IMPL;
+ }
+ }
+ bar = 0;
TAILQ_FOREACH(nc, &n->childq, child) {
- pnode_print(f, nc);
- nn = TAILQ_NEXT(nc, child);
- while (nn != NULL) {
- if (nc->node != nn->node)
- break;
+ if (bar && f->linestate == LINE_MACRO)
macro_addarg(f, "|", ARG_SPACE);
- macro_addnode(f, nn, ARG_SPACE);
- nc = nn;
- nn = TAILQ_NEXT(nn, child);
- }
+ pnode_print(f, nc);
+ bar = 1;
+ }
+ if (isop) {
+ if (was_impl)
+ macro_open(f, "Oc");
+ else
+ f->flags &= ~FMT_IMPL;
+ } else if (isrep) {
+ if (was_impl)
+ macro_open(f, "Brc");
+ else
+ f->flags &= ~FMT_IMPL;
}
- if (sv)
- macro_close(f);
- f->flags &= ~FMT_IMPL;
+ if (isrep && f->linestate == LINE_MACRO)
+ macro_addarg(f, "...", ARG_SPACE);
pnode_unlinksub(n);
}
--
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-04-13 15:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-13 15:14 docbook2mdoc: Improve formatting of <arg> and <group>: * Respect the 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).