source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* docbook2mdoc: Parse <abstract> and treat it like a <section>;  when it
@ 2019-04-28 20:27 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-04-28 20:27 UTC (permalink / raw)
  To: source

Log Message:
-----------
Parse <abstract> and treat it like a <section>; 
when it occurs inside an info element, move it out 
and put it before the first section of the page.

Modified Files:
--------------
    docbook2mdoc:
        node.c
        node.h
        reorg.c
        statistics.c

Revision Data
-------------
Index: node.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/node.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -Lnode.c -Lnode.c -u -p -r1.25 -r1.26
--- node.c
+++ node.c
@@ -32,6 +32,7 @@ struct	nodeprop {
 };
 
 static	const struct nodeprop properties[] = {
+	{ "abstract",		CLASS_BLOCK },
 	{ "appendix",		CLASS_BLOCK },
 	{ "arg",		CLASS_ENCL },
 	{ "author",		CLASS_LINE },
Index: node.h
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/node.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -Lnode.h -Lnode.h -u -p -r1.34 -r1.35
--- node.h
+++ node.h
@@ -40,6 +40,7 @@ enum	nodeclass {
  * More DocBook XML elements are recognized, but remapped or discarded.
  */
 enum	nodeid {
+	NODE_ABSTRACT,
 	NODE_APPENDIX,
 	NODE_ARG,
 	NODE_AUTHOR,
Index: statistics.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/statistics.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -Lstatistics.c -Lstatistics.c -u -p -r1.37 -r1.38
--- statistics.c
+++ statistics.c
@@ -366,6 +366,7 @@ main(int argc, char *argv[])
 		table_add("ROOT", "reference");
 		table_add("ROOT", "sect1");
 		table_add("ROOT", "sect2");
+		table_add("abstract", NULL);
 		table_add("acronym", "TEXT");
 		table_add("affiliation", "orgdiv");
 		table_add("affiliation", "orgname");
@@ -373,6 +374,7 @@ main(int argc, char *argv[])
 		table_add("application", "TEXT");
 		table_add("arg", "option");
 		table_add("article", NULL);
+		table_add("articleinfo", "abstract");
 		table_add("articleinfo", "author");
 		table_add("articleinfo", "authorgroup");
 		table_add("articleinfo", "copyright");
@@ -394,6 +396,7 @@ main(int argc, char *argv[])
 		table_add("authorgroup", "othercredit");
 		table_add("blockquote", NULL);
 		table_add("book", NULL);
+		table_add("bookinfo", "abstract");
 		table_add("bookinfo", "authorgroup");
 		table_add("bookinfo", "copyright");
 		table_add("bookinfo", "legalnotice");
Index: reorg.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/reorg.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lreorg.c -Lreorg.c -u -p -r1.3 -r1.4
--- reorg.c
+++ reorg.c
@@ -26,7 +26,7 @@
 static void
 reorg_root(struct pnode *root)
 {
-	struct pnode	*date, *descr, *name, *vol, *nc;
+	struct pnode	*date, *info, *name, *vol, *nc;
 
 	if (root == NULL)
 		return;
@@ -63,10 +63,13 @@ reorg_root(struct pnode *root)
 	/* Insert prologue information at the beginning. */
 
 	if (pnode_findfirst(root, NODE_REFNAMEDIV) == NULL &&
-	    ((nc = pnode_findfirst(root, NODE_BOOKINFO)) != NULL ||
-	     (nc = pnode_findfirst(root, NODE_REFENTRYINFO)) != NULL) &&
-	    (descr = pnode_takefirst(nc, NODE_TITLE)) != NULL)
-		TAILQ_INSERT_HEAD(&root->childq, descr, child);
+	    ((info = pnode_findfirst(root, NODE_BOOKINFO)) != NULL ||
+	     (info = pnode_findfirst(root, NODE_REFENTRYINFO)) != NULL)) {
+		if ((nc = pnode_takefirst(info, NODE_ABSTRACT)) != NULL)
+			TAILQ_INSERT_HEAD(&root->childq, nc, child);
+		if ((nc = pnode_takefirst(info, NODE_TITLE)) != NULL)
+			TAILQ_INSERT_HEAD(&root->childq, nc, child);
+	}
 	TAILQ_INSERT_HEAD(&root->childq, vol, child);
 	TAILQ_INSERT_HEAD(&root->childq, name, child);
 	TAILQ_INSERT_HEAD(&root->childq, date, child);
@@ -215,6 +218,10 @@ reorg_recurse(struct pnode *n)
 		return;
 
 	switch (n->node) {
+	case NODE_ABSTRACT:
+		default_title(n, "Abstract");
+		n->node = NODE_SECTION;
+		break;
 	case NODE_APPENDIX:
 		if (n->parent == NULL)
 			reorg_refentry(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-28 20:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-28 20:27 docbook2mdoc: Parse <abstract> and treat it like a <section>; when it 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).