diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2008-12-03 19:21:58 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2008-12-03 19:21:58 +0000 |
commit | c68b04faf73c1216350e7e0ad7502734a8cfc21c (patch) | |
tree | 23e1dc762eef7a180fc1d6480d5fcc355572deb6 /xml.c | |
parent | 268539aa79db4cc8381940023764b3d53c9d8c26 (diff) | |
download | mandoc-c68b04faf73c1216350e7e0ad7502734a8cfc21c.tar.gz mandoc-c68b04faf73c1216350e7e0ad7502734a8cfc21c.tar.zst mandoc-c68b04faf73c1216350e7e0ad7502734a8cfc21c.zip |
Major update.
Diffstat (limited to 'xml.c')
-rw-r--r-- | xml.c | 64 |
1 files changed, 56 insertions, 8 deletions
@@ -1,4 +1,4 @@ -/* $Id: xml.c,v 1.10 2008/12/03 14:39:59 kristaps Exp $ */ +/* $Id: xml.c,v 1.11 2008/12/03 19:21:58 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se> * @@ -31,6 +31,41 @@ static ssize_t xml_begintag(struct md_mbuf *, const struct md_args *, enum md_ns, int, const int *, const char **); +static int xml_begin(struct md_mbuf *, + const struct md_args *); +static int xml_end(struct md_mbuf *, + const struct md_args *); + + +static int +xml_begin(struct md_mbuf *mbuf, const struct md_args *args) +{ + size_t res; + + if ( ! ml_puts(mbuf, "<?xml version=\"1.0\" " + "encoding=\"UTF-8\"?>\n", &res)) + return(0); + if ( ! ml_puts(mbuf, "<mdoc xmlns:block=\"block\" " + "xmlns:special=\"special\" " + "xmlns:inline=\"inline\">", &res)) + return(0); + + return(1); +} + + +static int +xml_end(struct md_mbuf *mbuf, const struct md_args *args) +{ + size_t res; + + res = 0; + if ( ! ml_puts(mbuf, "</mdoc>", &res)) + return(0); + + return(1); +} + static ssize_t xml_begintag(struct md_mbuf *mbuf, const struct md_args *args, @@ -46,14 +81,20 @@ xml_begintag(struct md_mbuf *mbuf, const struct md_args *args, if ( ! ml_nputs(mbuf, "block:", 6, &res)) return(-1); break; + case (MD_NS_BODY): + if ( ! ml_nputs(mbuf, "body:", 5, &res)) + return(-1); + break; + case (MD_NS_HEAD): + if ( ! ml_nputs(mbuf, "head:", 5, &res)) + return(-1); + break; case (MD_NS_INLINE): if ( ! ml_nputs(mbuf, "inline:", 7, &res)) return(-1); break; default: - if ( ! ml_nputs(mbuf, "mbuf", 4, &res)) - return(-1); - return((ssize_t)res); + break; } if ( ! ml_nputs(mbuf, toknames[tok], @@ -81,10 +122,16 @@ xml_endtag(struct md_mbuf *mbuf, const struct md_args *args, if ( ! ml_nputs(mbuf, "inline:", 7, &res)) return(-1); break; - default: - if ( ! ml_nputs(mbuf, "mbuf", 4, &res)) + case (MD_NS_BODY): + if ( ! ml_nputs(mbuf, "body:", 5, &res)) + return(-1); + break; + case (MD_NS_HEAD): + if ( ! ml_nputs(mbuf, "head:", 5, &res)) return(-1); - return((ssize_t)res); + break; + default: + break; } if ( ! ml_nputs(mbuf, toknames[tok], @@ -116,6 +163,7 @@ md_init_xml(const struct md_args *args, struct md_mbuf *mbuf, const struct md_rbuf *rbuf) { - return(mlg_alloc(args, rbuf, mbuf, xml_begintag, xml_endtag)); + return(mlg_alloc(args, rbuf, mbuf, xml_begintag, + xml_endtag, xml_begin, xml_end)); } |