From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: docbook2mdoc: The <olink> element is woefully underspecified, so the
Date: Sun, 14 Apr 2019 19:34:46 -0500 (EST) [thread overview]
Message-ID: <e3fdd7af888a23f7@fantadrom.bsd.lv> (raw)
Log Message:
-----------
The <olink> element is woefully underspecified, so the various
attributes may be used quite differently in different documents,
but let's try a basic translation anyway.
Modified Files:
--------------
docbook2mdoc:
docbook2mdoc.c
node.c
node.h
statistics.c
Revision Data
-------------
Index: docbook2mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.127 -r1.128
--- docbook2mdoc.c
+++ docbook2mdoc.c
@@ -667,8 +667,40 @@ pnode_printlink(struct format *f, struct
if (TAILQ_FIRST(&n->childq) != NULL)
macro_addnode(f, n, ARG_SPACE | ARG_SINGLE);
pnode_unlinksub(n);
+ }
+}
+
+static void
+pnode_printolink(struct format *f, struct pnode *n)
+{
+ const char *uri, *ptr, *local;
+
+ uri = pnode_getattr_raw(n, ATTRKEY_TARGETDOC, NULL);
+ ptr = pnode_getattr_raw(n, ATTRKEY_TARGETPTR, NULL);
+ local = pnode_getattr_raw(n, ATTRKEY_LOCALINFO, NULL);
+ if (uri == NULL) {
+ uri = ptr;
+ ptr = NULL;
+ }
+ if (uri == NULL) {
+ uri = local;
+ local = NULL;
+ }
+ if (uri == NULL)
return;
+
+ macro_open(f, "Lk");
+ macro_addarg(f, uri, ARG_SPACE | ARG_SINGLE);
+ macro_addnode(f, n, ARG_SPACE | ARG_SINGLE);
+ if (ptr != NULL || local != NULL) {
+ macro_close(f);
+ macro_open(f, "Pq");
+ if (ptr != NULL)
+ macro_addarg(f, ptr, ARG_SPACE);
+ if (local != NULL)
+ macro_addarg(f, local, ARG_SPACE);
}
+ pnode_unlinksub(n);
}
static void
@@ -1178,6 +1210,9 @@ pnode_print(struct format *f, struct pno
case NODE_MML_MSUB:
case NODE_MML_MSUP:
pnode_printmath(f, n);
+ break;
+ case NODE_OLINK:
+ pnode_printolink(f, n);
break;
case NODE_OPTION:
if ((nc = TAILQ_FIRST(&n->childq)) != NULL &&
Index: node.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/node.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -Lnode.c -Lnode.c -u -p -r1.18 -r1.19
--- node.c
+++ node.c
@@ -93,6 +93,7 @@ static const struct nodeprop properties[
{ "mml:msup", CLASS_LINE },
{ "modifier", CLASS_LINE },
{ "note", CLASS_BLOCK },
+ { "olink", CLASS_ENCL },
{ "option", CLASS_LINE },
{ "orderedlist", CLASS_BLOCK },
{ "para", CLASS_BLOCK },
@@ -160,11 +161,14 @@ static const char *const attrkeys[ATTRKE
"href",
"id",
"linkend",
+ "localinfo",
"NAME",
"open",
"PUBLIC",
"rep",
"SYSTEM",
+ "targetdoc",
+ "targetptr",
"url",
"xlink:href"
};
Index: node.h
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/node.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -Lnode.h -Lnode.h -u -p -r1.27 -r1.28
--- node.h
+++ node.h
@@ -101,6 +101,7 @@ enum nodeid {
NODE_MML_MSUP,
NODE_MODIFIER,
NODE_NOTE,
+ NODE_OLINK,
NODE_OPTION,
NODE_ORDEREDLIST,
NODE_PARA,
@@ -176,11 +177,14 @@ enum attrkey {
ATTRKEY_HREF,
ATTRKEY_ID,
ATTRKEY_LINKEND,
+ ATTRKEY_LOCALINFO,
ATTRKEY_NAME,
ATTRKEY_OPEN,
ATTRKEY_PUBLIC,
ATTRKEY_REP,
ATTRKEY_SYSTEM,
+ ATTRKEY_TARGETDOC,
+ ATTRKEY_TARGETPTR,
ATTRKEY_URL,
ATTRKEY_XLINK_HREF,
ATTRKEY__MAX
Index: statistics.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/statistics.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -Lstatistics.c -Lstatistics.c -u -p -r1.33 -r1.34
--- statistics.c
+++ statistics.c
@@ -482,6 +482,9 @@ main(int argc, char *argv[])
table_add("member", "symbol");
table_add("member", "TEXT");
table_add("note", NULL);
+ table_add("olink", "citetitle");
+ table_add("olink", "function");
+ table_add("olink", "TEXT");
table_add("option", "parameter");
table_add("option", "replaceable");
table_add("option", "TEXT");
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2019-04-15 0:34 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=e3fdd7af888a23f7@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).