source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: docbook2mdoc: Parse <abstract> and treat it like a <section>;  when it
Date: Sun, 28 Apr 2019 15:27:21 -0500 (EST)	[thread overview]
Message-ID: <e3feb3c1be1cb7b2@fantadrom.bsd.lv> (raw)

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

                 reply	other threads:[~2019-04-28 20:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3feb3c1be1cb7b2@fantadrom.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).