source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* docbook2mdoc: handle class="monospaced" in NODE_LITERALLAYOUT
@ 2019-03-22 17:01 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-03-22 17:01 UTC (permalink / raw)
  To: source

Log Message:
-----------
handle class="monospaced" in NODE_LITERALLAYOUT

Modified Files:
--------------
    docbook2mdoc:
        docbook2mdoc.c
        extern.h

Revision Data
-------------
Index: extern.h
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/extern.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -Lextern.h -Lextern.h -u -p -r1.30 -r1.31
--- extern.h
+++ extern.h
@@ -152,6 +152,7 @@ enum	nodeid {
 enum	attrkey {
 	/* Alpha-order... */
 	ATTRKEY_CHOICE = 0,
+	ATTRKEY_CLASS,
 	ATTRKEY_CLOSE,
 	ATTRKEY_ID,
 	ATTRKEY_LINKEND,
@@ -166,6 +167,7 @@ enum	attrkey {
  */
 enum	attrval {
 	/* Alpha-order... */
+	ATTRVAL_MONOSPACED,
 	ATTRVAL_NOREPEAT,
 	ATTRVAL_OPT,
 	ATTRVAL_PLAIN,
Index: docbook2mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.59 -r1.60
--- docbook2mdoc.c
+++ docbook2mdoc.c
@@ -77,6 +77,7 @@ struct	pnode {
 
 static	const char *attrkeys[ATTRKEY__MAX] = {
 	"choice",
+	"class",
 	"close",
 	"id",
 	"linkend",
@@ -85,6 +86,7 @@ static	const char *attrkeys[ATTRKEY__MAX
 };
 
 static	const char *attrvals[ATTRVAL__MAX] = {
+	"monospaced",
 	"norepeat",
 	"opt",
 	"plain",
@@ -491,6 +493,21 @@ pnode_unlinksub(struct pnode *pn)
 }
 
 /*
+ * Retrieve an enumeration attribute from a node.
+ * Return ATTRVAL__MAX if the node has no such attribute.
+ */
+enum attrval
+pnode_getattr(struct pnode *pn, enum attrkey key)
+{
+	struct pattr	*ap;
+
+	TAILQ_FOREACH(ap, &pn->attrq, child)
+		if (ap->key == key)
+			return ap->val;
+	return(ATTRVAL__MAX);
+}
+
+/*
  * Retrieve an attribute string from a node.
  * Return defval if the node has no such attribute.
  */
@@ -1369,6 +1386,10 @@ pnode_print(struct parse *p, struct pnod
 		pnode_printmopen(p);
 		fputs("Li", stdout);
 		break;
+	case (NODE_LITERALLAYOUT):
+		assert(p->newln);
+		puts(".Bd -literal");
+		break;
 	case (NODE_MML_MFENCED):
 		pnode_printmathfenced(p, pn);
 		pnode_unlinksub(pn);
@@ -1411,13 +1432,12 @@ pnode_print(struct parse *p, struct pnod
 		pnode_printmopen(p);
 		fputs("Qo", stdout);
 		break;
-	case (NODE_LITERALLAYOUT):
-		/* FALLTHROUGH */
 	case (NODE_PROGRAMLISTING):
-		/* FALLTHROUGH */
 	case (NODE_SCREEN):
 		assert(p->newln);
-		puts(".Bd -literal");
+		printf(".Bd %s\n", ATTRVAL_MONOSPACED ==
+		    pnode_getattr(pn, ATTRKEY_CLASS) ?
+		    "-literal" : "-unfilled");
 		break;
 	case (NODE_REFENTRYINFO):
 		/* Suppress. */
--
 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-03-22 17:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22 17:01 docbook2mdoc: handle class="monospaced" in NODE_LITERALLAYOUT 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).