+static int mbuf_begintag(struct md_xml *, const char *,
+ enum md_ns, int *, char **);
+static int mbuf_endtag(struct md_xml *,
+ const char *, enum md_ns);
+
+
+static int
+mbuf_begintag(struct md_xml *p, const char *name, enum md_ns ns,
+ int *argc, char **argv)
+{
+ int i;
+
+ if ( ! mbuf_nputs(p, "<", 1))
+ return(0);
+
+ switch (ns) {
+ case (MD_NS_BLOCK):
+ if ( ! mbuf_nputs(p, "block:", 6))
+ return(0);
+ break;
+ case (MD_NS_INLINE):
+ if ( ! mbuf_nputs(p, "inline:", 7))
+ return(0);
+ break;
+ default:
+ break;
+ }
+
+ if ( ! mbuf_puts(p, name))
+ return(0);
+
+ for (i = 0; ROFF_ARGMAX != argc[i]; i++) {
+ if ( ! mbuf_nputs(p, " ", 1))
+ return(0);
+ if ( ! mbuf_puts(p, tokargnames[argc[i]]))
+ return(0);
+ if ( ! mbuf_nputs(p, "=\"", 2))
+ return(0);
+ if ( ! mbuf_putstring(p, argv[i] ? argv[i] : "true"))
+ return(0);
+ if ( ! mbuf_nputs(p, "\"", 1))
+ return(0);
+ }
+ return(mbuf_nputs(p, ">", 1));
+}
+
+
+static int
+mbuf_endtag(struct md_xml *p, const char *tag, enum md_ns ns)
+{
+ if ( ! mbuf_nputs(p, "</", 2))
+ return(0);
+
+ switch (ns) {
+ case (MD_NS_BLOCK):
+ if ( ! mbuf_nputs(p, "block:", 6))
+ return(0);
+ break;
+ case (MD_NS_INLINE):
+ if ( ! mbuf_nputs(p, "inline:", 7))
+ return(0);
+ break;
+ default:
+ break;
+ }
+
+ if ( ! mbuf_puts(p, tag))
+ return(0);
+ return(mbuf_nputs(p, ">", 1));
+}