tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* [PATCH docbook2mdoc] Add NODE_EMAIL
@ 2019-03-22 10:33 Stephen Gregoratto
  2019-03-22 12:32 ` Ingo Schwarze
  2019-03-22 20:07 ` Ingo Schwarze
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Gregoratto @ 2019-03-22 10:33 UTC (permalink / raw)
  To: tech

Add support for the <email> node. The official XSL stylesheets enclose 
the address in angle brackets, and so shall we. While we're at it, add a 
missing return statement for NODE_REFENTRYTITLE.

I intend to add more nodes in the future so I'm starting with a small 
addition to get a feel of the code-base. Critique is fully welcome here.
I hope to add <author> node soon, so we can generate a full `.An` block.
For example:

  <author>
    <personname>
      <firstname>Joe</firstname>
      <othername>Bloggo</othername>
      <surname>Bloggs</surname>
    </personname>
    <email>joe@foo.net</email>
  </author>

Would transform into:

  .An Joe So Bloggo Sq Bloggs Aq Mt joe@foo.net

The othername part may be overkill right now. Not sure if this would 
require it's own function like pnode_printrefsect().

Index: docbook2mdoc.c
===================================================================
RCS file: /cvs/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.47
diff -u -p -r1.47 docbook2mdoc.c
--- docbook2mdoc.c	8 Mar 2019 15:18:50 -0000	1.47
+++ docbook2mdoc.c	22 Mar 2019 10:07:15 -0000
@@ -105,6 +105,7 @@ static	const struct node nodes[NODE__MAX
 	{ "constant", 0 },
 	{ "copyright", NODE_IGNTEXT },
 	{ "date", 0 },
+	{ "email", 0 },
 	{ "emphasis", 0 },
 	{ "entry", 0 },
 	{ "envar", 0 },
@@ -1252,6 +1253,10 @@ pnode_print(struct parse *p, struct pnod
 		pnode_printmopen(p);
 		fputs("Dv", stdout);
 		break;
+	case (NODE_EMAIL):
+		pnode_printmopen(p);
+		fputs("Aq Mt", stdout);
+		break;
 	case (NODE_EMPHASIS):
 		pnode_printmopen(p);
 		fputs("Em", stdout);
@@ -1522,6 +1527,7 @@ pnode_print(struct parse *p, struct pnod
 	case (NODE_CODE):
 	case (NODE_COMMAND):
 	case (NODE_CONSTANT):
+	case (NODE_EMAIL):
 	case (NODE_EMPHASIS):
 	case (NODE_ENVAR):
 	case (NODE_FILENAME):
Index: extern.h
===================================================================
RCS file: /cvs/docbook2mdoc/extern.h,v
retrieving revision 1.25
diff -u -p -r1.25 extern.h
--- extern.h	19 Mar 2015 10:04:32 -0000	1.25
+++ extern.h	22 Mar 2019 10:07:15 -0000
@@ -20,6 +20,7 @@ enum	nodeid {
 	NODE_CONSTANT,
 	NODE_COPYRIGHT,
 	NODE_DATE,
+	NODE_EMAIL,
 	NODE_EMPHASIS,
 	NODE_ENTRY,
 	NODE_ENVAR,
Index: rules.c
===================================================================
RCS file: /cvs/docbook2mdoc/rules.c,v
retrieving revision 1.25
diff -u -p -r1.25 rules.c
--- rules.c	19 Mar 2015 10:04:32 -0000	1.25
+++ rules.c	22 Mar 2019 10:07:15 -0000
@@ -71,6 +71,7 @@ isparent(enum nodeid node, enum nodeid p
 		return(0);
 	case (NODE_ACRONYM):
 		switch (parent) {
+		case (NODE_EMAIL):
 		case (NODE_EMPHASIS):
 		case (NODE_ENTRY):
 		case (NODE_FUNCSYNOPSISINFO):
@@ -289,6 +290,7 @@ isparent(enum nodeid node, enum nodeid p
 		return(0);
 	case (NODE_DATE):
 		switch (parent) {
+		case (NODE_EMAIL):
 		case (NODE_EMPHASIS):
 		case (NODE_ENTRY):
 		case (NODE_FUNCSYNOPSISINFO):
@@ -311,8 +313,30 @@ isparent(enum nodeid node, enum nodeid p
 			break;
 		}
 		return(0);
+	case (NODE_EMAIL):
+		switch (parent) {
+		case (NODE_ENTRY):
+		case (NODE_FUNCSYNOPSISINFO):
+		case (NODE_LINK):
+		case (NODE_PARA):
+		case (NODE_PROGRAMLISTING):
+		case (NODE_REFDESCRIPTOR):
+		case (NODE_REFENTRYTITLE):
+		case (NODE_REFNAME):
+		case (NODE_REFPURPOSE):
+		case (NODE_SCREEN):
+		case (NODE_SYNOPSIS):
+		case (NODE_TERM):
+		case (NODE_TITLE):
+		case (NODE_USERINPUT):
+			return(1);
+		default:
+			break;
+		}
+		return(0);
 	case (NODE_EMPHASIS):
 		switch (parent) {
+		case (NODE_EMAIL):
 		case (NODE_EMPHASIS):
 		case (NODE_ENTRY):
 		case (NODE_FUNCSYNOPSISINFO):
@@ -577,6 +601,7 @@ isparent(enum nodeid node, enum nodeid p
 		case (NODE_CODE):
 		case (NODE_COMMAND):
 		case (NODE_CONSTANT):
+		case (NODE_EMAIL):
 		case (NODE_EMPHASIS):
 		case (NODE_ENTRY):
 		case (NODE_ENVAR):
@@ -883,6 +908,7 @@ isparent(enum nodeid node, enum nodeid p
 		return(0);
 	case (NODE_QUOTE):
 		switch (parent) {
+		case (NODE_EMAIL):
 		case (NODE_EMPHASIS):
 		case (NODE_ENTRY):
 		case (NODE_FUNCSYNOPSISINFO):
@@ -920,6 +946,7 @@ isparent(enum nodeid node, enum nodeid p
 		default:
 			break;
 		}
+		return(0);
 	case (NODE_REFMETA):
 		return(parent == NODE_REFENTRY);
 	case (NODE_REFMETAINFO):
@@ -966,6 +993,7 @@ isparent(enum nodeid node, enum nodeid p
 		case (NODE_COMMAND):
 		case (NODE_CONSTANT):
 		case (NODE_EMPHASIS):
+		case (NODE_EMAIL):
 		case (NODE_ENTRY):
 		case (NODE_ENVAR):
 		case (NODE_FILENAME):
@@ -1208,6 +1236,7 @@ isparent(enum nodeid node, enum nodeid p
 	case (NODE_TRADEMARK):
 		switch (parent) {
 		case (NODE_ACRONYM):
+		case (NODE_EMAIL):
 		case (NODE_EMPHASIS):
 		case (NODE_ENTRY):
 		case (NODE_FUNCSYNOPSISINFO):
@@ -1350,6 +1379,7 @@ isparent(enum nodeid node, enum nodeid p
 		return(0);
 	case (NODE_WORDASWORD):
 		switch (parent) {
+		case (NODE_EMAIL):
 		case (NODE_EMPHASIS):
 		case (NODE_ENTRY):
 		case (NODE_FUNCSYNOPSISINFO):
--
 To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-25 18:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22 10:33 [PATCH docbook2mdoc] Add NODE_EMAIL Stephen Gregoratto
2019-03-22 12:32 ` Ingo Schwarze
2019-03-22 20:07 ` Ingo Schwarze
2019-03-23  5:30   ` Stephen Gregoratto
2019-03-23  8:46     ` Ingo Schwarze
2019-03-23 10:18       ` Stephen Gregoratto
2019-04-25 18:33         ` Ingo 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).