From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 8e7d9ce0 for ; Sat, 13 Apr 2019 10:14:02 -0500 (EST) Date: Sat, 13 Apr 2019 10:14:02 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: docbook2mdoc: Improve formatting of and : * Respect the X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- Improve formatting of and : * Respect the repeat attribute even if there is a child macro. * Mark up all children of , not just the first. * Implement the repeat attribute for . * Do the proper was_impl dance for . 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