* docbook2mdoc: Prints tables containing only one column as .Bl -bullet
@ 2019-04-03 11:46 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-04-03 11:46 UTC (permalink / raw)
To: source
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 <informaltable> separately from <table>;
the only difference is whether or not it has a title.
Treat <table> as transparent and handle <tgroup> instead.
The advantages are that <title> 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-04-03 11:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03 11:46 docbook2mdoc: Prints tables containing only one column as .Bl -bullet 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).