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 21c39d6f for ; Wed, 3 Apr 2019 06:46:39 -0500 (EST) Date: Wed, 3 Apr 2019 06:46:39 -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: Prints tables containing only one column as .Bl -bullet X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- Prints tables containing only one column as .Bl -bullet -compact. The number of columns is taken from the "cols" attribute. No neat to treat separately from ; the only difference is whether or not it has a title. Treat
as transparent and handle instead. The advantages are that gets a generic handler which also works in other contexts and that other children of <table> are now covered as well. Modified Files: -------------- docbook2mdoc: docbook2mdoc.c node.c node.h parse.c Revision Data ------------- Index: node.h =================================================================== RCS file: /home/cvs/mdocml/docbook2mdoc/node.h,v retrieving revision 1.7 retrieving revision 1.8 diff -Lnode.h -Lnode.h -u -p -r1.7 -r1.8 --- node.h +++ node.h @@ -70,7 +70,6 @@ enum nodeid { NODE_INDEX, NODE_INFO, NODE_INFORMALEQUATION, - NODE_INFORMALTABLE, NODE_INLINEEQUATION, NODE_ITEMIZEDLIST, NODE_KEYSYM, @@ -157,6 +156,7 @@ enum attrkey { ATTRKEY_CHOICE = 0, ATTRKEY_CLASS, ATTRKEY_CLOSE, + ATTRKEY_COLS, ATTRKEY_ID, ATTRKEY_LINKEND, ATTRKEY_OPEN, Index: parse.c =================================================================== RCS file: /home/cvs/mdocml/docbook2mdoc/parse.c,v retrieving revision 1.10 retrieving revision 1.11 diff -Lparse.c -Lparse.c -u -p -r1.10 -r1.11 --- parse.c +++ parse.c @@ -98,7 +98,7 @@ static const struct element elements[] = { "indexterm", NODE_DELETE }, { "info", NODE_INFO }, { "informalequation", NODE_INFORMALEQUATION }, - { "informaltable", NODE_INFORMALTABLE }, + { "informaltable", NODE_TABLE }, { "inlineequation", NODE_INLINEEQUATION }, { "itemizedlist", NODE_ITEMIZEDLIST }, { "keysym", NODE_KEYSYM }, Index: node.c =================================================================== RCS file: /home/cvs/mdocml/docbook2mdoc/node.c,v retrieving revision 1.2 retrieving revision 1.3 diff -Lnode.c -Lnode.c -u -p -r1.2 -r1.3 --- node.c +++ node.c @@ -28,6 +28,7 @@ static const char *const attrkeys[ATTRKE "choice", "class", "close", + "cols", "id", "linkend", "open", Index: docbook2mdoc.c =================================================================== RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v retrieving revision 1.81 retrieving revision 1.82 diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.81 -r1.82 --- docbook2mdoc.c +++ docbook2mdoc.c @@ -540,18 +540,40 @@ pnode_printrow(struct format *p, struct } static void -pnode_printtable(struct format *p, struct pnode *pn) +pnode_printtgroup1(struct format *p, struct pnode *n) { - struct pnode *pp; + struct pnode *nc; + + macro_line(p, "Bl -bullet -compact"); + while ((nc = pnode_findfirst(n, NODE_ENTRY)) != NULL) { + macro_line(p, "It"); + pnode_print(p, nc); + pnode_unlink(nc); + } + macro_line(p, "El"); + pnode_unlinksub(n); +} + +static void +pnode_printtgroup(struct format *p, struct pnode *n) +{ + struct pnode *nc; + + switch (atoi(pnode_getattr_raw(n, ATTRKEY_COLS, "0"))) { + case 1: + pnode_printtgroup1(p, n); + return; + default: + break; + } - pnode_printtitle(p, pn); macro_line(p, "Bl -ohang"); - while ((pp = pnode_findfirst(pn, NODE_ROW)) != NULL) { + while ((nc = pnode_findfirst(n, NODE_ROW)) != NULL) { macro_line(p, "It Table Row"); - pnode_printrow(p, pp); + pnode_printrow(p, nc); } macro_line(p, "El"); - pnode_unlinksub(pn); + pnode_unlinksub(n); } static void @@ -782,10 +804,6 @@ pnode_print(struct format *p, struct pno case NODE_STRUCTNAME: macro_open(p, "Vt"); break; - case NODE_TABLE: - case NODE_INFORMALTABLE: - pnode_printtable(p, pn); - break; case NODE_TEXT: if (pn->bsz == 0) { assert(pn->real != pn->b); @@ -829,9 +847,17 @@ pnode_print(struct format *p, struct pno putchar('e'); } break; + case NODE_TGROUP: + pnode_printtgroup(p, pn); + break; case NODE_TITLE: - if (pn->parent->node == NODE_BOOKINFO) + if (pn->parent->node == NODE_BOOKINFO) { macro_open(p, "Nd"); + break; + } + pnode_printpara(p, pn); + macro_nodeline(p, "Sy", pn, 0); + pnode_unlinksub(pn); break; case NODE_TYPE: macro_open(p, "Vt"); -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv