source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: docbook2mdoc: implement file inclusion via <xi:include>
Date: Mon, 8 Apr 2019 20:39:40 -0500 (EST)	[thread overview]
Message-ID: <e3fd83d67fa0f529@fantadrom.bsd.lv> (raw)

Log Message:
-----------
implement file inclusion via <xi:include>

Modified Files:
--------------
    docbook2mdoc:
        node.c
        node.h
        parse.c

Revision Data
-------------
Index: node.h
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/node.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lnode.h -Lnode.h -u -p -r1.13 -r1.14
--- node.h
+++ node.h
@@ -69,6 +69,7 @@ enum	nodeid {
 	NODE_GLOSSTERM,
 	NODE_GROUP,
 	NODE_HOLDER,
+	NODE_INCLUDE,
 	NODE_INDEX,
 	NODE_INFO,
 	NODE_INFORMALEQUATION,
@@ -159,6 +160,7 @@ enum	attrkey {
 	ATTRKEY_COLS,
 	ATTRKEY_DEFINITION,
 	ATTRKEY_ENDTERM,
+	ATTRKEY_HREF,
 	ATTRKEY_ID,
 	ATTRKEY_LINKEND,
 	ATTRKEY_NAME,
Index: parse.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/parse.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -Lparse.c -Lparse.c -u -p -r1.25 -r1.26
--- parse.c
+++ parse.c
@@ -213,7 +213,7 @@ static	const struct element elements[] =
 	{ "varname",		NODE_VARNAME },
 	{ "warning",		NODE_WARNING },
 	{ "wordasword",		NODE_WORDASWORD },
-	{ "xi:include",		NODE_DELETE_WARN },
+	{ "xi:include",		NODE_INCLUDE },
 	{ "year",		NODE_YEAR },
 	{ NULL,			NODE_IGNORE }
 };
@@ -641,6 +641,8 @@ static void
 xml_elem_end(struct parse *ps, const char *name)
 {
 	const struct element	*elem;
+	struct pnode		*n;
+	const char		*cp;
 	enum nodeid		 node;
 
 	/*
@@ -670,6 +672,18 @@ xml_elem_end(struct parse *ps, const cha
 			ps->del--;
 		break;
 	case NODE_IGNORE:
+		break;
+	case NODE_INCLUDE:
+		n = ps->cur;
+		ps->cur = ps->cur->parent;
+		cp = pnode_getattr_raw(n, ATTRKEY_HREF, NULL);
+		if (cp == NULL)
+			error_msg(ps, "<xi:include> element "
+			    "without href attribute");
+		else
+			parse_file(ps, -1, cp);
+		pnode_unlink(n);
+		ps->flags &= ~PFLAG_SPC;
 		break;
 	case NODE_DOCTYPE:
 		ps->flags &= ~PFLAG_EEND;
Index: node.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/node.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lnode.c -Lnode.c -u -p -r1.5 -r1.6
--- node.c
+++ node.c
@@ -31,6 +31,7 @@ static	const char *const attrkeys[ATTRKE
 	"cols",
 	"DEFINITION",
 	"endterm",
+	"href",
 	"id",
 	"linkend",
 	"NAME",
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

                 reply	other threads:[~2019-04-09  1:39 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=e3fd83d67fa0f529@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).