From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: docbook2mdoc: handle class="monospaced" in NODE_LITERALLAYOUT
Date: Fri, 22 Mar 2019 12:01:40 -0500 (EST) [thread overview]
Message-ID: <e3fc934dd3bc297a@fantadrom.bsd.lv> (raw)
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
reply other threads:[~2019-03-22 17:01 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=e3fc934dd3bc297a@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).